Home

Highly Type object to Util.Compile error

edited September 2017
I'm having an issue passing in a highly type object to another script with the following code. I have extracted out my real logic into a test script that replicates the error.

In my parent script I have the following code
 void Main()
    {
	var test = new TestObject { t1 = "asdf", t2 = 3 } ;

	var compiledQuery = Util.Compile(@".\SubTestQuery.linq", false);
	var retVal = compiledQuery.Run(QueryResultFormat.Html, test);
	retVal.AsString();
   }

[Serializable]
public class TestObject
{
	public string t1 { get; set; }
	public int t2
	{
		get; set;
	}
}

in the SubTestQuery script I have the following code

async Task Main(TestObject input)
{
	"In sub query".Dump();
	await  doSomething();
}

async Task<int> doSomething()
{
	return 1;
}



// Define other methods and classes here

[Serializable]
public class TestObject
{
	public string t1 { get; set; }
	public int t2
	{
		get; set;
	}
}


but I get the following error

System.Runtime.Serialization.SerializationException
Unable to find assembly 'query_fewoae, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.


but if I place the TestObject class into my extensions I am able to run the parent script just fine. Is it possible to not have this class extension? I wish to pass around my scripts and it would be easier to define it in my scripts

Comments

  • if someone could tell me the tag to get the code blocks looking nice that would be great. I didnt see anything in the Simple HTML link for code blocks and the 4 spaces format from stack overflow doesnt seem to work
  • Are you saying that it works fine if you define TestObject in My Extensions? If so, this is expected behaviour. The class needs to be available to both queries, and it has to be (numerically) the same type. This means you must either define it in My Extensions, or in an assembly that both queries reference.

    To tag for code, click the 'C' (code) icon on the toolbar.
  • Thanks Joe, It does I was just hoping to have the class defined in each script so I could keep those in my scripts and share them with my team.

    I was hoping that this could work like web traffic in which you can define the client and server data model in their own system. Perhaps I will go down the assembly route.
Sign In or Register to comment.