.NET changes between 2017b and 2018a
9 views (last 30 days)
Show older comments
I have some code where I use a .dll created with vb.net inside VS2013 to use with matlab:
net = NET.addAssembly('SOME_PROJECT.dll');
AssemblyType = net.AssemblyHandle.GetType('SOME_PROJECT.ComClass');
try
result = System.Activator.CreateInstance(AssemblyType);
catch e
e.message;
if(isa(e, 'NET.NetException'))
eObj = e.ExceptionObject
end
end
This works fine in matlab 2017b and will yield 'result' but in 2018a I get a SEHException
e =
NetException with properties:
ExceptionObject: [1×1 System.Runtime.InteropServices.SEHException]
identifier: 'MATLAB:NET:CLRException:AddSuperClasses'
message: 'Message: External component has thrown an exception.↵Source: dotnetcli↵HelpLink: '
cause: {}
stack: [0×1 struct]
What changes between 2017b and 2018a could cause this? What can I do to fix this?
2 Comments
zapaiz
on 1 Jun 2018
Edited: zapaiz
on 4 Jun 2018
I have the same problem passing from 2017b (where there script was running correctly) to 2018a:
NET.addAssembly(plc-full-path);
plc.objCom=PoohPlcLink.PoohFinsETN;
The second line throws an error:
NetException with properties:
ExceptionObject: [1×1 System.Runtime.InteropServices.SEHException]
identifier: 'MATLAB:NET:CLRException:AddSuperClasses'
message: 'Message: Eccezione lanciata da un componente esterno.↵Source: dotnetcli↵HelpLink: '
cause: {}
stack: [3×1 struct]
The NetExeption is contained in the attached workspace.
thrunken
on 1 Jun 2018
Edited: thrunken
on 1 Jun 2018
I found this post while searching for a solution to my own similar problem. Below is some C# code and a MATLAB script I wrote. I've been able to reproduce the exception I've been getting when using another dll. The script works in 2017b, but not 2018a.
C# code:
namespace SimpleDLL
{
public class OuterClass
{
public class NestedClass
{
public NestedClass() { }
}
public class InheritedNestedClass : NestedClass
{
public InheritedNestedClass() { }
}
// Returns without error in MATLAB 2018a
public NestedClass GetNestedClass()
{
return new NestedClass();
}
// Throws an error in MATLAB 2018a
public InheritedNestedClass GetInheritedNestedClass()
{
return new InheritedNestedClass();
}
}
}
MATLAB script:
dll = NET.addAssembly('SimpleDLL.dll');
outerClass = SimpleDLL.OuterClass();
% Does not throw exception
nested = outerClass.GetNestedClass();
% Throws exception
inheritedNested = outerClass.GetInheritedNestedClass();
The exception is:
Error using SimpleDll (line 6)
Message: External component has thrown an exception.
Source: dotnetcli
HelpLink:
I can return a nested class (class within a class), but I cannot return a class that inherits from the same nested class. I am using .NET Framework 4.6.1 if that matters. There seems to be no difference in what MathWorks has reported as limitations in .NET support between 2018a and 2017b, so I'm confused as to what the problem could be.
Accepted Answer
thrunken
on 4 Jun 2018
Edited: thrunken
on 18 Jun 2018
I posted a comment here and discovered that my problem is caused by a known bug in MATLAB 2018a. https://www.mathworks.com/support/bugreports/1759533
Could this be your problem?
Edit: They fixed the bug, install 2018a Update 3.
4 Comments
zapaiz
on 8 Jun 2018
Good to know. Sadly I'm using a third party dll, I had to switch back to 2017b.
More Answers (1)
Antony Pohl
on 8 Jun 2018
I have the same problem, but it's a deal breaker for me as I am heavily invested in Win Forms GUI and a custom VB .dll that I call frequently.
At the most basic level you can't even open a simple form. I can't believe that made it passed the testers into a published product Very bad on Matlab.
Example:
------
asm = NET.addAssembly('System.Windows.Forms');
import System.Windows.Forms.*
a = Form; <---- this produces the above mentioned dotnetcli error.
--------
0 Comments
See Also
Categories
Find more on Deploy to .NET Applications Using MWArray API in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!