Version 4.0 of the .NET Framework introduced a new runtime activation policy, which enables an application to activate multiple versions of the common language runtime (CLR) in the same process. (See here for more information.)
Because of this support for side-by-side runtimes, .NET 4.0 has changed the way that it binds to older mixed-mode assemblies, such as the NMath Kernel assembly, which is written in C++\CLI and uses the Intel Math Kernel Library internally.
When using NMath in .NET 4.0 applications, the NMath Kernel fails to load, because it was built against an earlier version of .NET and includes unmanaged code. The error is:
System.TypeInitializationException : The type initializer for 'CenterSpace.NMath.Core.NMathKernel' threw an exception. ----> CenterSpace.NMath.Core.KernelLoadException : Could not load kernel assembly NMathKernelx86
There are two solutions:
- Activate the v2.0 runtime activation policy by adding the following lines to your app.config when using runtime v4.0:
<configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> </configuration>
See here for more information on the <startup> element.
- Request assemblies for .NET 3.5 from Centerspace Technical Support. (see below for correction)
In the next release of NMath, the shipping assemblies will be built against .NET 3.5. (Assemblies for .NET 2.0 will remain available upon request.) << see below for correction
This issue can only be solved with the application config change or with assemblies built with .NET 4.0.
If you are widely deploying your application, you should probably target .NET 3.5 or earlier. In this case, the application config is the best solution.
If you know your application will be run within .NET 4.0 or later and don’t wish to make the application config change, please contact us at firstname.lastname@example.org. We can send you NMath assemblies built and tested with .NET 4.0.
Since we don’t use any .NET 3.5 features and it’s too early to target .NET 4.0 with a class library, we will be targeting .NET 2.0 in the next release (expected in June, 2010).
We have released new versions of our products today that are built using Visual Studio 2010 and target .NET 3.5 (client profile) or greater. The issue above no longer exists. Please contact email@example.com for your upgrade.