Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在matlab代码中使用C#dll函数_C#_Matlab_.net Assembly - Fatal编程技术网

在matlab代码中使用C#dll函数

在matlab代码中使用C#dll函数,c#,matlab,.net-assembly,C#,Matlab,.net Assembly,我有一个C#项目,我想在matlab中使用我的项目的功能。 我补充说 [ClassInterface(ClassInterfaceType.AutoDual)] [ComVisible(true)] 在我的项目中的每个类之前,创建输出类型类库。 但是当我在matlab中使用dll时 temp = NET.addAssembly('../../foo') 然后foo.Classes,就没有课了! 我该怎么办?!请帮助我:)关于上述评论的示例 要使用NET.addAssembly(…)使用.NE

我有一个C#项目,我想在matlab中使用我的项目的功能。 我补充说

[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
在我的项目中的每个类之前,创建输出类型类库。 但是当我在matlab中使用dll时

temp = NET.addAssembly('../../foo')
然后
foo.Classes
,就没有课了! 我该怎么办?!请帮助我:)

关于上述评论的示例

要使用
NET.addAssembly(…)
使用.NET程序集中的类,无需使该类COM可见,但该类以及要访问的方法必须是公共的

.NET代码

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."; }
    }
}
来自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();

使用
NET.addAssembly
不需要使类COM可见,但您的类至少需要是
public
hmm,tnQ。但现在我无法访问的方法!好的,您想要访问的方法也必须是
public
…请参阅我答案中的示例代码。