I have a C# project, and I want to use the function of my project in matlab. I've added
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
befor every classes in my project and make the out put type class library. but when I use of dll in matlab,
temp = NET.addAssembly('../../foo')
and then foo.Classes, there is no class!
what should i do?! plz help me :)
Sample regarding above comment
To use a class from a .NET assembly using NET.addAssembly(...), there is no need to make the class COM Visible but the class, as well as the methods you want to access to, have to be public.
.NET code
namespace foo
{
public class SampleClass
{
// Constructor
public SampleClass() { }
// Static example
public static string StaticMethod() { return "Hello from static method."; }
// Instance example
public string InstanceMethod() { return "Hello from instance method."; }
}
}
Usage from Matlab
% Loading the .NET assembly
NET.addAssembly('..\..\Foo.dll');
% Call of a static method
foo.SampleClass.StaticMethod()
% Call of an instance method
instance = foo.SampleClass();
instance.InstanceMethod();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With