简体   繁体   中英

Matlab .NET assembly with C#

Im having a very strange issue with integrating a matlab .NET Assembly with C#. When I try using the DLL in a console application project everything works just fine. When I change the project to a class library (without changing anything but adding a constructor to the class) I get an exception when attempting to load an Instance of the Matlab Object. The exception I get is:

System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception. ---> System.Exception: Trouble initializing libraries required by .NET Assembly.

   at MathWorks.MATLAB.NET.Utility.MWMCR..cctor()
   --- End of inner exception stack trace ---
   at MtlObj..cctor()}

Any help would be appreciated!

Thanks

Can you check what the differences are in the .csproj file after you changed it? (on file level)

And also you can try to remove the reference and add it, maybe the Console application adds something to the Reference tag that a class library is not expecting.

Did you register your DLL? Are you calling the methods correctly?

Please check this thread - C# - Passing variables to Matlab

Are you sure your making all these steps?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM