I ran into problems in MATLAB R2010b when creating a DLL that uses .NET-integration and enumerations with encapsulate data.
Example:
- There is a .NET Assembly which is used in MATLAB, let's call it "MyAssembly" (MyAssembly.dll).
There Matlab Enumerations Class "OpenMode"
This class uses the .NET enumeration: "MyAssembly.OpenMode" In such a way to access the .NET-enumeration via Matlab-enumeration (In my case it is necessary for cast types):classdef OpenMode methods function obj = OpenMode(netType) obj.Net = netType; end end properties Net end enumeration ReadOnly (MyAssembly.OpenMode.ReadOnly) ReadWrite (MyAssembly.OpenMode.ReadWrite) end end
netElem = OpenMode.ReadOnly.Net; cls = class(netElem) cls = MyAssembly.OpenMode
The Matlab-Function, that should be exported:
function retVal = MyFunction(inputs) NET.addAssembly('MyAssembly.dll'); flag = OpenMode.ReadOnly; netFlag = flag.Net; % Some code... end
- Add .NET Assembly in Matlab (checking)
NET.addAssembly('MyAssembly.dll')
- Try to compile the Dll:
...and get the error:mcc -B csharedlib:MyLib MyFunction
Depfun error: 'Undefined variable "MyAssembly" or class "MyAssembly.OpenMode.ReadOnly".' ??? Error using ==> mcc Error executing mcc, return status = 1 (0x1).
The mcc compiler does not detect in code enumeration that "MyAssembly" exists, but here is a function will be compiled successfully:
function retVal = MyFunction(inputs)
netflag = MyAssembly.OpenMode.ReadOnly;
% Some code...
end
If you have faced similar problems in MATLAB and found a solution, please tell me what to do.
Thanks!
Regards, iroln