Recently encountered some problems in the project process:
The background program dynamically generates some class objects, which are used after Silverlight receives these class objects.
In the actual programming process encountered a difficult problem.
[Operationcontract]
Public object test ()
{
Stringbuilder cs = new stringbuilder ();
CS. appendline ("namespace RunTime ");
CS. appendline ("{");
// CS. appendline ("using system. Data ;");
CS. appendline ("using system. Collections. Generic ;");
CS. appendline ("using system. reflection ;");
CS. appendline ("using system. componentmodel ;");
CS. appendline ("using system. runtime. serialization ;");
CS. appendline ("using system ;");
CS. appendline ("[serializable]");
CS. appendline ("public class testdata ");
CS. appendline ("");
CS. appendline ("{public int iddd {Get; Set ;}}}");
Compilerparameters Options = new compilerparameters ();
Codedomprovider provider = codedomprovider. createprovider ("CSHARP ");
Options. referencedassemblies. Add ("system. dll ");
Options. referencedassemblies. Add ("system. runtime. serialization. dll ");
Assembly = assembly. getassembly (base. GetType ());
Options. referencedassemblies. Add (assembly. Location );
Compilerresults Results = provider. compileassemblyfromsource (options, new string [] {CS. tostring ()});
If (results. errors. haserrors)
{
Throw new exception (results. errors [0]. errortext );
}
Object o = results. compiledassembly. createinstance ("runtime. testdata ");
Return O;
}
Silverlight encounters an exception when accessing the Test method: Not found method error.
Later, it was found that the system. dll of C #3.5 was referenced during dynamic compilation, but it could not be parsed in Silverlight.
The idea is to reference the system. dll of the Silverlight SDK, generate a fixed DLL file during dynamic compilation, and then download it in Silverlight for reflection call.
Although this method can be successful, it has a major drawback: You need to set write permissions for the web directory and install the Silverlight SDK.
I don't know if masters have other good methods?