.Net Framework assembly is not found at runtime, although it has been loaded.
10 ビュー (過去 30 日間)
古いコメントを表示
Hi,
we are using a custom .Net Framework assembly. To make it work under Matlab we are loading the dll file (and all it´s dependencies) by calling
NET.addAssembly
At runtime we then get the message:
"The file or assembly “System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” or a dependency of it could not be found. The system cannot find the specified file"
But the System.Runtime.CompilerServices.Unsafe.dll version 4.0.4.1 was loaded beforehand (to be sure we checked the version with ildasm.exe).
If we add the assembly to the gac everthing is ok.
Does anyone know what is happening?
0 件のコメント
回答 (1 件)
Satwik
2025 年 1 月 15 日
Hi Frank,
If 'NET.addAssembly' function is invoked with the name of the .NET assembly file and without the path to the file, then MATLAB or MCR (in case if the deployed application is executed) searches for the file in the Global Assembly Cache (GAC). It does not search for it in the "ctfroot" folder.
So, adding the file as dependent to the deployed application and using the following line of code may not work as expected.
asm = NET.addAssembly('Utilities.dll');
To workaround this issue, place the .NET assemblies in the 'distrib' folder of the package created from the 'deploytool' and replace the following code:
asm = NET.addAssembly('Utilities.dll');
with
if(isdeployed)
path=[pwd,'\utilities.dll']; //pwd is the distrib folder
else
path="\\PATH\Utilities.dll";
end
asm = NET.addAssembly(path);
I hope this helps resolve the issue!
1 件のコメント
Les Beckham
2025 年 1 月 15 日
I don't know if this approach will work or not. But I do know that you should NEVER use path as a variable name in Matlab. Change to a different variable name such as:
if (isdeployed)
asmpath=[pwd,'\utilities.dll']; % pwd is the distrib folder
else
asmpath="\\PATH\Utilities.dll";
end
asm = NET.addAssembly(asmpath);
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!