使用DLLImport导入类 [英] Using DLLImport to import a class

查看:325
本文介绍了使用DLLImport导入类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在dll中有一个类:
例如:

I have an class in dll: For example:

namespace foo {
   public class baa {
      /* ... */
  }
}

如何从dll中导入 baa 类?

how can I imports the baa class from dll? it is possible?

[DllImport(DllName)]
public extern ?? foo() ??

预先感谢。

推荐答案

那是行不通的。非托管DLL导出一个 C 接口,而不是一个 C ++ 接口。对于托管DLL(C#或C ++ / CLI),您根本不需要DllImport。

That's not going to work. Unmanaged DLLs export a C interface, not a C++ one. And for managed DLLs (C# or C++/CLI) you simply don't need DllImport.

恐怕只有导入静态类的函数。

Only functions that are imported into a static class I'm afraid.

这篇关于使用DLLImport导入类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆