Matlab 无法加载 .NET 程序集
当我尝试通过键入以下内容在 Matlab 中加载我的 .NET 程序集 foo.dll 时,
asm = NET.addAssembly('fullpath\foo.dll');
出现以下错误:“无法加载文件或程序集 'file:///fullPath\foo.dll' 或其依赖项之一。此程序集由比当前加载的运行时更新的运行时构建,无法加载来源:mscorlib HelpLink:“
我有 Matlab R2010a,并且尝试为 .NET Framework 4.0 和 .NET Framework 构建程序集。 3.0没有成功。
编辑
我做了几次测试,现在也许我已经部分发现了这个问题。在上面的示例中,我尝试通过提供完整路径来添加私有程序集。然后我记得之前也在 GAC 中注册了相同的程序集(针对 .NET 4.0)(通过 gacutil /i foo.dll 命令)。因此,我从 GAC 中删除了该程序集 (gacutil /u foo
),现在至少我能够添加针对 .NET 3.0 的私有程序集,但如果我想针对 .NET 4.0,则仍然不能添加该程序集。
我认为之前,当我尝试为 .NET 3.0 添加私有程序集时,Matlab 仍在尝试为 GAC 中安装的 .NET 4.0 添加程序集,因为存在一些冲突。 但是,我仍然不明白为什么我不能使用 .NET 4.0 。
When I try to load in Matlab my .NET assembly foo.dll by typing:
asm = NET.addAssembly('fullpath\foo.dll');
I get the following error: "Could not load file or assembly 'file:///fullPath\foo.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. Source: mscorlib HelpLink:"
I've Matlab R2010a and I tried to build the assembly both for .NET framework 4.0 and .NET framework 3.0 with no success.
EDIT
I did several tests and now maybe I've partly discovered the problem. In the above example I was trying to add a private assembly by giving the full path. I then remembered to have also previously registered the same assembly (targeted for .NET 4.0) in the GAC (through the gacutil /i foo.dll
command). Hence I removed the assembly from the GAC (gacutil /u foo
) and now at least I'm able to add the private assembly targeted for .NET 3.0 but still not if I want to target .NET 4.0.
I presume that before, when I was trying to add a private assembly for .NET 3.0, Matlab was still trying to add the assembly for .NET 4.0 installed in the GAC, because of some conflict.
However, I still do not understand why I cannot use .NET 4.0 .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法重现该错误。这是我使用的示例:
MyClass.cs
MATLAB
我尝试了不同的.NET 目标框架 4.0/3.5/3.0,它们都工作正常。请注意,程序集一旦加载就无法卸载,释放 .NET 资源的唯一方法是重新启动 MATLAB...
I can't reproduce the error. This is the example I used:
MyClass.cs
MATLAB
I tried different .NET target frameworks 4.0/3.5/3.0, and they all worked fine. Note that you can't unload an assembly once loaded, and the only way to release the .NET resources is to restart MATLAB...