简体   繁体   English

将单个C#dll导入C ++项目?

[英]Importing singed C# dll into C++ project?

I'm trying to import .net dll into C++ project. 我正在尝试将.net dll导入C ++项目。 c++ code constains following code: C ++代码包含以下代码:

#include "stdafx.h"
#import "RemoteAgentLibs.tlb" named_guids raw_interfaces_only
int main() {
    HRESULT init = CoInitialize( NULL );
    if (init != S_OK) return 1;

    ImportedNamespace::_ClassNamePtr myclass;
    myclass = new ImportedNamespace::_ClassNamePtr("ImportedNamespace.ClassName");
    myclass->MyMeyhod();
}

Everything works fine untill I check the "Sign the assembly" in properties of my .NET project. 一切正常,直到我在.NET项目的属性中选中“对程序集签名”。 In .NET project I get warning: 在.NET项目中,我得到警告:

Warning 3 "path to dll" does not contain any types that can be unregistered for COM Interop. 警告3“ dll的路径”不包含可以为COM Interop取消注册的任何类型。

Warning 3 "path to dll" does not contain any types that can be registered for COM Interop. 警告3“ dll的路径”不包含可以为COM Interop注册的任何类型。

In C++ project I get error: 在C ++项目中,出现错误:

error C2039: 'MyMethod' : is not a member of 'ImportedNamespace::_ClassNamePtr' 错误C2039:“ MyMethod”:不是“ ImportedNamespace :: _ ClassNamePtr”的成员

Could somebody tell me why there is a problme with importing strong name signed dlls? 有人可以告诉我为什么导入强名称签名的dll有问题吗? or is there any other way to import my dll into c++ project and add dll to GAC 还是有其他方法将我的dll导入c ++项目并将dll添加到GAC

Did you look SWIG ? 你看起来快了吗? I think it's a good solution you just have to write a wrapper for your need... 我认为这是一个很好的解决方案,您只需要编写一个包装即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM