vs2010 matlab2014b-vs2010 调用MATLAB2014b 的NET Assembly 报错

作者:操作系统    发布时间:2020-01-26 19:00     浏览次数 :

[返回]

最近在做一个unity的工程,用的vs2017写的c#其中我在c#里调用了自己写的Matlab的dll文件,引入了addNative.dll和MWArray.dll后运行时抛出异常:System.Exception:MWArrayassemblyfailedtobeinitialized---System.NotImplementedException:Therequestedfeatureisnotimplemented.atSystem.Security.Principal.WindowsIdentity.GetCurrent(BooleanifImpersonating)[0x00000]in/Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Security.Principal/WindowsIdentity.cs:166atMathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(System.StringfunctionName,Int32numArgsOut,Int32numArgsIn,MathWorks.MATLAB.NET.Arrays.MWArray[]argsIn)[0x00000]infilenameunknown:0atMathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(Int32numArgsOut,System.StringfunctionName,MathWorks.MATLAB.NET.Arrays.MWArray[]argsIn)[0x00000]infilenameunknown:0atMathWorks.MATLAB.NET.Utility.MWMCR.setBuilderUserData()[0x00000]infilenameunknown:0atMathWorks.MATLAB.NET.Utility.MWMCR..ctor(System.StringcomponentId,System.StringcomponentPath,System.IO.StreamembeddedCtfStream,BooleanisLibrary)[0x00000]infilenameunknown:0ataddNative.Add..cctor()[0x00000]infilenameunknown:0---Endofinnerexceptionstacktrace---ataddNative.Add..ctor()[0x00000]infilenameunknown:0

Unity3d和matlab联合使用初始化报错
测试在C# 3.5 .net上可以使用,但是在unity3d内就一直初始化报错。。。
下面是错误代码 Unity版本是5.5
NotImplementedException: The requested feature is not implemented.
System.Security.Principal.WindowsIdentity.GetCurrent (Boolean ifImpersonating) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Security.Principal/WindowsIdentity.cs:166)
MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction (System.String functionName, Int32 numArgsOut, Int32 numArgsIn, MathWorks.MATLAB.NET.Arrays.MWArray[] argsIn)
MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction (Int32 numArgsOut, System.String functionName, MathWorks.MATLAB.NET.Arrays.MWArray[] argsIn)
MathWorks.MATLAB.NET.Utility.MWMCR.setBuilderUserData ()
MathWorks.MATLAB.NET.Utility.MWMCR..ctor (System.String componentId, System.String componentPath, System.IO.Stream embeddedCtfStream, Boolean isLibrary)
tracker_run.Tracker..cctor ()
Rethrow as Exception: MWArray assembly failed to be initialized
tracker_run.Tracker..ctor ()
Test.Start () (at Assets/Scripts/Test.cs:9)

vs2010 调用MATLAB2014b 的NET Assembly 报错
用matlab2014b 写好m文件用打包为NET Assembly 程序集,选择是Framework4.0
编译没有问题,用VS2010 的win32 控制台程序 调用也没有问题,但是用VS2010的 webapplication 调用就报如下错误:

[BadImageFormatException: 试图加载格式不正确的程序。 (异常来自 HRESULT:0x8007000B)]
MathWorks.MATLAB.NET.Arrays.MWArray.mclmcrInitialize2(Int32 primaryMode) +0
MathWorks.MATLAB.NET.Arrays.MWArray..cctor() +560

[TypeInitializationException: “MathWorks.MATLAB.NET.Arrays.MWArray”的类型初始值设定项引发异常。]
MathWorks.MATLAB.NET.Utility.MWMCR..cctor() +1824

下一篇:没有了