开发者

Can I load a silverlight dll (reflection only) into a .net application?

I realize the difference in SL and .net CLR and Class Library, and I don't want to execute any code (just query some attributes and check whether some types implement an interface declared in a shared assembly).

But I cannot load the SL dll with Assembly.LoadFrom, because it doesn't found the dependencies (like System.Windows.dll and such)开发者_如何学编程. I've tried the Assembly.ReflectionOnlyLoadFrom, but that gives me pretty much the same error (cannot load dependencies) just with different wording...

Is there ANY way to reflect an SL assembly from outside of SL?


Try copying the dependencies (System.Windows.dll, etc.) to the same directory as the Silverlight assembly you are trying to load.

The loader/fusion has to be able to locate and load the correct dependent assemblies (even for "reflection only") because vital metadata (such as method signatures inherited from base classes) may only reside in those dependencies.


I've switched back to LoadFrom instead of ReadOnlyLoadFrom. At least NOW it found my own assemblies, and it's only missing System.Windows and so on.
So I've subscribed to AppDomain.Current.AssemblyResolve, and passed my SL installation folder as a parameter to my app. So now, for every unresolved Assembly, I look it up by name from the SL directory (c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜