How does Silverlight normally access the class objects dynamically compiled by WCF?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.