Alen Lee
Alen Lee

Reputation: 2509

How to load assembly dynamically by Assembly.Load in Windows phone 8?

Now I have a problem, I want to load assembly dynamically depend on the platform(x86,ARM). I create a conditional compilation symbol _M_ARM to distinguish between x86 and ARM.

So I use System.Reflection.Assembly.LoadFrom(@"MP3/ARM/Mp3EncLib.dll"), but occur an exception that Assembly.LoadFrom is not support on Windows Phone.

So I use another method System.Reflection.Assembly.Load(@"MP3/ARM/Mp3EncLib.dll"), but it throw an exception which is

Additional information: Could not load file or assembly 'MP3/ARM/Mp3EncLib.dll, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The given assembly name or codebase was invalid

private void Application_Launching(object sender, LaunchingEventArgs e)
{
#if _M_ARM
    System.Reflection.Assembly.Load(@"MP3/ARM/Mp3EncLib.dll");
#else 
    System.Reflection.Assembly.Load(@"MP3/X86/Mp3EncLib.dll");
#endif
}

This is my solution enter image description here

Anybody know how to use the method. Or better way

Upvotes: 4

Views: 999

Answers (2)

Christian Findlay
Christian Findlay

Reputation: 7692

From everything I have read on the internet, this is still not possible even in UWP.

I have created a feature request here: https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/18145291-dynamically-load-assembly

It would be appreciated if you vote this feature up. Meantime, I think the only answer is the answer mentioned above which only really works in the scenario where you are able to put the DLL in the AppX package at deployment time.

Upvotes: 0

Den
Den

Reputation: 1912

I believe you must fully qualify the assembly like SomeCompany.SomeNamespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.

Upvotes: 1

Related Questions