How to fix NET C# System.TypeInitializationException using a DLL built by Matlab on 64bit Windows 8?
23 ビュー (過去 30 日間)
古いコメントを表示
I'm not able to create an application on my Computer that references a .NET Assembly built using Matlab Builder NE. I'm on Windows 8 64bit, have a 64bit Matlab 2013a and I'm using Visual Studio 2012.
I followed the instructions in the Video for the makeSqr example: http://www.mathworks.de/videos/using-matlab-builder-ne-68758.html
It all works fine except I', missing the Mathworks .NET MWArray API in the GAC list of assemblies. I manually add a reference to D:\Program Files\MATLAB\MATLAB Compiler Runtime\v81\toolbox\dotnetbuilder\bin\win64\v2.0\MWArray.dll
The program compiles fine, but Initializing my class obj = new MLTest();
i get the following exception: System.TypeInitializationException wurde nicht behandelt. HResult=-2146233036 Message=Der Typeninitialisierer für "com.demo.MLTest" hat eine Ausnahme verursacht. Source=demo TypeName=com.demo.MLTest StackTrace: bei com.demo.MLTest..ctor() bei BuilderNEMainApp.Program.Main(String[] args) in c:\Users\Irgenfs\Documents\Visual Studio 2012\Projects\BuilderNEMainApp\BuilderNEMainApp\Program.cs:Zeile 33. bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart() InnerException: System.TypeInitializationException HResult=-2146233036 Message=Der Typeninitialisierer für "MathWorks.MATLAB.NET.Utility.MWMCR" hat eine Ausnahme verursacht. Source=demo TypeName=MathWorks.MATLAB.NET.Utility.MWMCR StackTrace: bei com.demo.MLTest..cctor() InnerException: System.TypeInitializationException HResult=-2146233036 Message=Der Typeninitialisierer für "MathWorks.MATLAB.NET.Arrays.MWArray" hat eine Ausnahme verursacht. Source=MWArray TypeName=MathWorks.MATLAB.NET.Arrays.MWArray StackTrace: bei MathWorks.MATLAB.NET.Utility.MWMCR..cctor() InnerException: System.BadImageFormatException HResult=-2147024885 Message=Es wurde versucht, eine Datei mit einem falschen Format zu laden. (Ausnahme von HRESULT: 0x8007000B) Source=MWArray StackTrace: bei MathWorks.MATLAB.NET.Arrays.MWArray.mclmcrInitialize2(Int32 primaryMode) bei MathWorks.MATLAB.NET.Arrays.MWArray..cctor() InnerException:
Any ideas how to fix this?
0 件のコメント
回答 (1 件)
Friedrich
2013 年 11 月 22 日
Hi,
sounds like a bittedness issues. Is your VS 2012 Project configured as x64 project? If not, please do so and recompile.
2 件のコメント
Friedrich
2013 年 11 月 25 日
"Es wurde versucht, eine Datei mit einem falschen Format zu laden. "
Indicates some bittedness issue. Can you run a compiled exe (compiled with MATLAB compiler directly) on that machine? If yes, can you try setting up a C/C++ project and incoorperate a DLL compiled with MATLAB COmpiler (see the matrixdriver example in the doc) and see if that works.
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB Compiler SDK についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!