mathnet/mathnet-numerics — Issue #27: Build error in CompositeSolver classes for Silverlight 5
Author: cureos
Created: 2011-11-24 09:14:06+00:00
State: open

After converting the Silverlight project to version 5 (RC) of Silverlight, I get the following build error in some of the `LoadSolverInformationFromAssembly` method overloads in the `CompositeSolver` classes:

*Argument 1: cannot convert from 'System.Reflection.AssemblyName' to 'string'*

The build error apparently occurs in code sections like this:

var assemblyName = new AssemblyName(assemblyFileName);
var assembly = Assembly.Load(assemblyName);

Where the (public) `Assembly.Load` method in SL5 does not support an `AssemblyName` argument.

According to the Silverlight MSDN documentation even for SL4 (http://msdn.microsoft.com/en-us/library/x4cw969y(v=VS.95).aspx), public use of this method is advised against, as the method is claimed to throw a `MethodAccessException`. It seems like this safety barrier has indeed been activated in SL5...

I have solved the problem in my local copy of mathnet-numerics by using the` Assembly.Load(string)` overload instead, with the following formulation:

var assembly = Assembly.Load(assemblyName.FullName);

If I have interpreted the MSDN documentation (http://msdn.microsoft.com/en-us/library/ky3942xh(v=VS.96).aspx) correctly for this overload, I do need the full display name of the assembly, so I thought it would be safest to have the `AssemblyName` object generate it for me.

I do not know if the assembly load feature is covered in the unit tests, either way I get all tests to pass after the above code modifications.