NET assembly unload conundrum

20 ビュー (過去 30 日間)
Paul Kelly
Paul Kelly 2013 年 4 月 9 日
コメント済み: Carlo 2024 年 2 月 16 日
I am trying to develop a C# class in Visual Studio and test it in Matlab. I can load the NET assembly and use it okay, but a problem arises if I change the NET code.
If I load the NET assembly into Matlab from the Visual Studio debug folder I can't rebuild the assembly in Visual Studio.
If I copy the dll into a local folder and load into Matlab from there I can only load once. Subsequent times I get the following error: "The process cannot access the file because it is being used by another process." In other words it won't let me copy the new dll because the old one is still in use.
So at the moment if I change the assembly code I have to close Matlab and reopen it to test the new assembly. This is adding quite a lot of time to my development.
I believe my version of Matlab (2010a) cannot unload NET assemblies. Does anyone know of another way around this?

採用された回答

Fab
Fab 2013 年 7 月 19 日
According to Matlab's support rebooting is the only solution to this problem for the current Matlab Version (8.1.0.604, R2013a):
"The ability to unload an assembly is not available in MATLAB at this point of time. This may be addressed in one of the future releases. Currently, to work around this issue, restart MATLAB."

その他の回答 (5 件)

Cameron
Cameron 2016 年 2 月 2 日
I am also having this same problem with R2015b. Any resolution??

Ivan
Ivan 2016 年 7 月 19 日
The same problem in R2016a

imme werus
imme werus 2017 年 4 月 24 日
編集済み: imme werus 2017 年 4 月 24 日
I think it is also the same for 2016b, is that true ?

Markus Finkeldey
Markus Finkeldey 2017 年 10 月 10 日
編集済み: Markus Finkeldey 2017 年 10 月 10 日
It seems that the .NET support of Matlab is very limited even in R2017a, makes it a hell of a workload if you want to access a c# library instead of a pure c library.
  1 件のコメント
Paul Kelly
Paul Kelly 2017 年 10 月 10 日
True. For me the real issue was that because I was developing C# applications and testing them using Matlab, every time I made a change I had to restart Matlab. The answer was to find other ways to test the C# code. It was a pity because Matlab gave me a lot of possibilities.

サインインしてコメントする。


Travis Leith
Travis Leith 2019 年 10 月 30 日
This is still an issue going into 2020 :(
  3 件のコメント
Roofus Milton
Roofus Milton 2019 年 11 月 15 日
Yup. Wolfram has great integration. I suspect their approach creates a new AppDomain and subsequently loads the requested assemblies. LINQPad has remained my default testing tool.
Carlo
Carlo 2024 年 2 月 16 日
Still a problem in matlab 23!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by