简体   繁体   中英

Is AppDomain.GetAssemblies() really supported in Silverlight 4?

In MSDN, it is said that AppDomain.GetAssemblies() is supported in Silverlight 4 .

In my project, when I target the version 4 of Silverlight (I triple checked), I can't access to the GetAssemblies() method on AppDomain as shown in the screenshot below:

在Silverlight 4中的AppDomain类上找不到GetAssemblies()方法

If I try anyway, it won't compile. I can workaround this using the following piece of code:

dynamic domain = AppDomain.CurrentDomain;
var assemblies = domain.GetAssemblies();

It compiles and seem to be working fine but only under Silverlight client 5.X and Silverlight 4.0.60351 and above from my tests. It doesn't work for below versions of the client. The project in question is the entry point of my Silverlight application.

Googling on this topic mainly says that it is supported...

So my questions are:

  • a) Is it really supported and if so how can I use it to ensure it will always work as long as my clients are using any of the 4.X version?
  • b) How can I use AppDomain.CurrentDomain.GetAssemblies() in the IDE without the above workaround? Is there something I missed?

In case it can be useful, I have the following installed on my desktop:

  • Silverlight client 5.1.10411
  • Silverlight SDK 3, 4 and 5
  • Silverlight 4 Toolkit April 2010
  • Silverlight 4 Tools for VS2010

I didn't try to uninstall/reinstall anything (yet) to avoid losing a whole day in this tedious task...

--

Edit: It appears that GetAssemblies() method is not present on AppDomain class in mscorlib.dll for SL4. So I guess MSDN documentation is incorrect and the runtime SL4 client has been patched at some point for some reason (compatibility with SL5-compiled applications?)...

I also stumpled upon these (see my comment on MSDN page ) behavior or wrong documentation in the MSDN and tried many diffrent ways to get the method call GetAssemblies in Siverlight 4. The solution for me was to install Silverlight 5 and change my silverlight project to work with Silverlight 5.

My suggestion is that the method GetAssemblies was added later, by a patch or silverlight update to the silverlight runtime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM