简体   繁体   English

在C#中使用vc ++类库

[英]use vc++ class library in c#

i have created a simple "public ref class" in the vc++ project, which is configured to generate a dynamik library. 我在vc ++项目中创建了一个简单的“ public ref类”,该项目配置为生成动态库。 In the c# Project (simple console application) i added the vc++ project as to the References and doing a "using myVC++library". 在c#项目(简单控制台应用程序)中,我添加了vc ++项目作为参考,并进行了“使用myVC ++库”。 But when i try to create an object from the vc++ dll i always get: System.BadImageFormatException was unhandled 但是,当我尝试从vc ++ dll创建对象时,总是得到:未处理System.BadImageFormatException

any clues or helpfull tutorials on this? 有任何线索或有用的教程吗?

TIA TIA

Is your c# project set to build for "Any CPU" - if it is, and you're on a 64-bit OS, then the load will fail. 是否将c#项目设置为针对“任何CPU”构建-如果是,并且您使用的是64位OS,则加载将失败。

The VC++ dll will be 32-bit only, and 64-bit app can't run it. VC ++ dll仅是32位,而64位应用程序无法运行它。

You could change your c# build to target x86 instead. 您可以将c#构建更改为目标x86。

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

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