Silverlight Dynamic Loading DLL

Source: Internet
Author: User
Keywords Dynamic loading so that the writing debugging can
Tags button click control debugging dynamic loading loading project simple

Problem

There was a problem with the project at hand today, and to describe the problem, I built a simple project with the following structure:

The problem is this:

There is a button in the 1,silverlightapplication1, click on the pop-up window ; silverlightApplication6 only one canvas to place the control reflected from the SilverlightApplication1.dll.

SilverlightApplication1 SilverlightApplication1.dll files are dynamically loaded in 2,silverlightapplication6.

3, if you start a new instance on RIA to debug, you can normally pass. The effect is:

4, but starting a new instance on the Web to debug will be an error: Prompts for security errors.

Solutions

After repeated testing, but also constantly modify the policy file, and finally determined that the DLL is the loading path of the problem, the wrong way to write a lot, colleagues also gave a focus on the correct way of writing, listed in one of the correct wording, in such a file structure:

We can write the loading method like this:

Public MainPage ()
{
InitializeComponent ();
WebClient Web = new WebClient ();
Web. openreadcompleted + = new Openreadcompletedeventhandler (web_openreadcompleted);
Web. OpenReadAsync (New Uri ("SilverlightApplication1.dll", Urikind.relativeorabsolute));
}

void Web_openreadcompleted (object sender, Openreadcompletedeventargs e)
{
Assemblypart part = new Assemblypart ();
Assembly Assembly = part. Load (E.result);

UserControl UC = assembly. CreateInstance ("Silverlightapplication1.box") as UserControl;
THIS.CANVAS1.CHILDREN.ADD (UC);
}

SOURCE Download: Silverlightdyndll

Related Article

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.