Win 7 DllImport C#奇数错误,对内存位置的访问无效? [英] Win 7 DllImport C# Odd error, Invalid access to memory location?

查看:76
本文介绍了Win 7 DllImport C#奇数错误,对内存位置的访问无效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用DllImport从我的C#应用​​程序访问C ++ dll中的某些功能。

I am using DllImport to access some functions in a C++ dll from my C# application.

此代码在我的开发笔记本电脑(Windows 7 64位, dll本身是32位的,所以我运行以32bit托管dll的进程,并且运行良好。但是,当我尝试在目标计算机上运行完全相同的进程时,也就是Windows 7 64bit Ultimate,我从进程中收到错误对内存位置的无效访问。。

This code works fine on my dev laptop, which is Windows 7 64bit, the dll itself is 32 bit, so I run the process hosting the dll in 32bit and it works well. However when I try to run the exact same process on my target machine, which is again, Windows 7 64bit Ultimate i get the error 'Invalid access to memory location.' from the process.

我不确定是什么问题,我已经查看了网络上的大量资源,但没有一个能为我解决问题。我不明白为什么它可以在我的开发箱上正常运行,但不能在目标机上正常运行?

I'm not sure what the problem is, i've looked at loads of resources on the net and none of them have solved it for me. I dont understand why it works fine on my dev box, but not on the target?

dll本身很好,dll附带的示例都可以正常工作我的目标框(正在执行DllImport的C#应用​​程序)。

The dll itself is fine, the examples that come with the dll all work fine on my target box (which are C# apps doing DllImport).

还有其他人遇到这个问题吗?现在已经战斗了两天!

Has anyone else had this problem? Been fighting it for two days now!

异常: {无法加载DLL'CLEyeMulticam.dll':对内存位置的无效访问。(来自HRESULT的异常:0x800703E6)}

推荐答案

我在这里遇到了同样的问题本地加载效果很好。从.net加载会出现错误无法加载DLL'my.dll':对内存位置的无效访问

I had the same problem here Native loading works good. Loading from .net gives error Unable to load DLL 'my.dll': Invalid access to memory location

问题出在DEP功能中。当我仅对基本程序打开DEP时,它没有任何效果。但是,当我完全关闭DEP并重新启动服务器时,错误消失了。我已经完成的另一件事-安装.net 4.0的最新更新

The problem was in DEP feature. When I switched on DEP for essential programs only, it gave no effect. But when I completely switched off DEP, and rebooted my server, error has gone. The one more thing I've done - installed latest updates for .net 4.0

还有一件值得注意的事-我没有看到有关DEP的任何错误,只是用内存错误。

The one notable thing - i didn't see any errors about DEP, just closing with "memory" error.

这篇关于Win 7 DllImport C#奇数错误,对内存位置的访问无效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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