惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
C
Cybersecurity and Infrastructure Security Agency CISA
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
T
Threat Research - Cisco Blogs
C
Cisco Blogs
Recent Announcements
Recent Announcements
S
Securelist
N
Netflix TechBlog - Medium
The Register - Security
The Register - Security
P
Privacy & Cybersecurity Law Blog
宝玉的分享
宝玉的分享
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
LINUX DO - 热门话题
T
Tor Project blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
月光博客
月光博客
AWS News Blog
AWS News Blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LINUX DO - 最新话题
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
H
Help Net Security
Spread Privacy
Spread Privacy
PCI Perspectives
PCI Perspectives
Project Zero
Project Zero
I
Intezer
T
The Blog of Author Tim Ferriss
有赞技术团队
有赞技术团队
The Last Watchdog
The Last Watchdog
C
Check Point Blog
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
MyScale Blog
MyScale Blog
V
Vulnerabilities – Threatpost
Recorded Future
Recorded Future
T
Tenable Blog
Jina AI
Jina AI
D
DataBreaches.Net
阮一峰的网络日志
阮一峰的网络日志

博客园 - laue

个人网站地址 whatwhat的安装 - laue - 博客园 用WordPress架设的一个blog Windows Update的存放文件夹 在windows 2003中使用PI Activeview 转贴 WOW的采药,炼金及相关 使用C#进行基于PI的开发(三)——应用PISDK和PIAPI从PI数据库读取数据 使用C#进行基于PI的开发(二)--常用对象的学习 使用C#进行基于PI的开发(一) demo 推荐一个Web 2.0 的个人门户网站 google 发布 Google Web Toolkit 远程桌面连接windows 2000 得到数据库中某表的主键 PetShop 4.0 学习笔记(一) asp.net NOTE Transact SQL 常用语句以及函数(转) sqlparameter的使用 常用下载地址收藏
在VS 2008中使用非托管DLL以及DEP
laue · 2008-01-20 · via 博客园 - laue

最近使用VS2008编译原来一个可以正常运行的程序时,出现下列错误,错误出现在使用未托管DLL处

找了很多地方,最后在MSDN论坛得到提示。
解决方案在这篇帖子
http://blogs.msdn.com/ed_maurer/archive/2007/12/14/nxcompat-and-the-c-compiler.aspx
简单的说出现这个错误的原因是vs2008的c#编译器生成的PE文件头增加了NXCOMPAT位,这个与DEP有关,DEP用于防止恶意软件注入进程。那么也就是说位托管的DLL在内存中属于为标记成为可执行的,因而出现了上述的错误。所以解决方案就是消除PE中的这个位。

启动Visual Studio 2008 Command Prompt,输入:
editbin.exe /NXCOMPAT:NO <your binary>

如果使用VS2008,则可以在工程属性中添加一个Post-build命令:
原文是这样的命令:
call $(DevEnvDir)..\tools\vsvars32.bat
editbin.exe /NXCOMPAT:NO $(TargetPath)

但是在我这里直接引用仿佛不行,我修改成为下面这样
call "(VS安装文件夹)\Common7\Tools\vsvars32.bat"
editbin.exe /NXCOMPAT:NO $(TargetPath)

第一行为设置VS环境,这个设置主要是为了后一行的editbin.exe 命令而服务的。

同时在这样添加以后,还需要在工程属性页的Debug选项中选中下面这个选项。

要不在调试的时候仍然会出现错误。

我为了解决这个问题找了好几天,放在首页希望大家能够有个记忆,在遇到这个问题时候能够想起来。