EEFileLoadException * __ptr64 - 从C ++托管DLL C#中抛出的异常 [英] C# exception thrown from a C++ managed dll - EEFileLoadException * __ptr64

查看:2787
本文介绍了EEFileLoadException * __ptr64 - 从C ++托管DLL C#中抛出的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一个普通的C#控制台程序多数民众赞成消费产生作为一个C ++ CLI项目的构建输出一个DLL得到这个错误。在那里,我有一个简单的 DumbThing 公开引用类的静态方法。我想简单地调用该函数或至少实例化一个很小的DumbThing对象,并看到,C#可以调用code,它从一个C ++ CLI出生DLL得到,但它不工作,因为它抛出了让我为难,甚至是错误更多:

I get this error from within a normal C# console program that's consuming a DLL produced as the build output of a C++ CLI project. There I have a simple DumbThing public ref class with a static method. I'd like to simply call that function or at least instantiate one tiny DumbThing object and see that C# can call code that it gets from a C++ CLI born DLL, but it's not working as it throws an error that puzzles me even more:

First-chance exception at 0x000007fefd2acacd (KernelBase.dll) in DumbTest.exe: Microsoft C++ exception: EEFileLoadException * __ptr64 at memory location 0x007fc228..

更新:下面的原始异常,还有另外一个第一次机会异常:

UPDATE: below the original exception, there's another first chance exception:

First-chance exception at 0x77cace3b (ntdll.dll) in DumbTest.exe: 0xC0000005: Access violation reading location 0xffffffffffffffff.

一个同事向我指出,这可能是一个编译时的问题(一些选项),但我没有任何线索,这可能会导致它。任何人都可以请提供一些出发点提示吗?

A colleague pointed out to me that it might be a compile time issue (some options), but I don't have any clues what could cause it. Could anyone please provide some starting point hints?

推荐答案

这可能是一个位元的问题。如果你编译你的C ++ / CLI项目针对特定平台,要确保你的C#项目已相应地设置了平台。默认为C#项目是任何CPU,这使JIT编译器生成一个64位架构的x64 code。如果你的C ++ / CLI项目是专为x86的话,就不会被加载到64位计算机上的64位进程。

It's probably a bitness issue. If you compiled your C++/CLI project for a specific platform, be sure that your C# project has set its platform accordingly. Default for C# projects is "Any CPU" which causes the JIT compiler to generate x64 code on a 64-bit architecture. If your C++/CLI project was built for x86 then it can't be loaded into a x64 process on a 64-bit machine.

这篇关于EEFileLoadException * __ptr64 - 从C ++托管DLL C#中抛出的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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