(c# 调用c++dll)an unhandled exception of type 'system.runtime.interopservices.comexception'

问题发生场景:

    win10 64bit操作系统,vs2008

    c++开发的dll文件,c#创建WindowsFormsApplication或者ConsoleApplication

    托管方式调用c++dll文件,通过添加引用->COM,选择以及注册的dll文件

    c#代码中增加如下代码

        MyFun  myfun = new MyFun();

        myfun.test();


    在运行到new的时候就提示如题的错误


解决方法:

c#工程中,右键->属性,更改platform target为X86,重新编译后调用成功



猜你喜欢

转载自blog.csdn.net/aidansen/article/details/80978922