网站.net matlab,从MATLAB发布.NET程序集

and my call for example is as follows:

NET.addAssembly('C:\MyLibrary.dll');

Everything is fine up to here, I can even debug in VS by attaching to MATLAB process, however there is a small issue. There is no 'removeAssembly' method to disconnect the assembly from MATLAB process. If I want to make a change in VS, I have to restart MATLAB to unlock the DLL which is really a pain in the b~~t. I even tried to use unlocker software with no luck..MATLAB freezes.

Does anyone know how to deal with this?

Solutions1

Unloading an assembly is not possible, it's one of the known limitations

Talk1:

oh no...anyway though thanks for your assistance

Solutions2

You can start a new Matlab instance from Matlab itself with a system call and the Matlab command line options. Then you can test your .NET libraries within the new instance. When the new instance is closed after your test, the .NET libraries are released. With this workaround, you don't need to reopen Matlab completely. Do not load the .NET assembly in the main Matlab instance.

Open a new Matlab instance (whole IDE GUI) on a Windows PC:

log_str = '-logfile "C:\Temp\logfile.txt"';

system_str = [ 'matlab.exe -nosplash ' log_str ];

system(system_str);

Automatically execute an m-File in the new Matlab instance via -r, without the IDE GUI with -nodesktop and have the new instance close itself after your test:

log_str = '-logfile "C:\Temp\logfile.txt"';

my_file = 'C:\Temp\test.m';

system_str = [ 'matlab.exe -nosplash -nodesktop -r "run(''' my_file '''), pause(2), exit" ' log_str ];

system(system_str);

The logfile logs the console output of the Matlab instance. It is optional, but helpful for testing. If you want your child instances to be asynchronous (i.e. returning the handle to the main Matlab instance), you can add ' &' at the end of the system_str.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值