如何删除参考MATLAB的.NET程序集

人气:1,056 发布:2022-09-10 标签: .net c# matlab

问题描述

我已经建立在C#中的DLL。我添加了一个引用这个DLL在MATLAB中,如下图所示。一切工作正常。现在的问题是,当我想更新我的DLL我不得不关闭MATLAB否则我不能重建我的dll,这是相当烦人。我如何在MATLAB可以去除引用这个dll? - 我想有也只是一条线code要做到这一点

 %添加引用的DLL
   CLS = NET.addAssembly('C:\ MyFolder的\ MyDllFolder \斌\调试\ MYDLL.DLL');

   %引用我的课
   mycls = MyNameSpace.MyClass();
 

解决方案

您是否尝试过 cls.delete 然后再添加参考?

我似乎记得清除类是有用的。抱歉,我不能更明确,我没有Matlab的得心应手设立一个例子。

修改

貌似我错了,按照这个链接,你不能卸载从MATLAB程序集。

I have created a dll in c#. I added a reference to this dll in MATLAB as shown below. Everything works fine. The problem is that when I want to update my dll I have to close MATLAB otherwise I cannot rebuild my dll, which is rather annoying. How in MATLAB can I remove the reference to this dll - I thought there would just be a line of code to do this?

   % add reference to dll
   cls = NET.addAssembly('C:\MyFolder\MyDllFolder\bin\Debug\MyDll.dll');

   % reference my class
   mycls = MyNameSpace.MyClass();

解决方案

Have you tried cls.delete and then add the reference again?

I seem to remember clear classes being useful as well. Sorry I can't be more definitive, I don't have Matlab handy to set up an example.

Edit

Looks like I was wrong, according to this link, "you cannot unload an assembly from MATLAB."

155