[问题]

Hello all

 
 

I'm writing a managed C++ dll with will be acting as an intermediate between a lot of old unmanaged legacy C/C++ and a new C# WPF ui. While trying to compile it I'm getting this error:

fatal error C1189: #error: Building MFC application with /MD[ d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[ d]

 
 

If I define _AFXDLL under the project properties Preprocessor Definitions I get this error:

fatal error C1189: #error: WINDOWS.H already included.  MFC apps must not #include <windows.h>


If I change the threading from /MD[ d] I get this error:

Command line error D8016: '/MTd' and '/clr' command-line options are incompatible

 
 

The problem seems to be the inclusion of "stdafx.h", which I need for common windows data types I'm going to marshal. What am I doing wrong?

 

【答案】

Project + Properties, General.  Ensure Use of MFC is set to "Use MFC in a Shared Library".

 

From: https://social.msdn.microsoft.com/Forums/vstudio/en-US/553fa850-5e6e-4ecb-a4eb-bbd81f8ff6b6/managed-c-dll-define-afxdll-or-do-not-use-md-d?forum=vcgeneral

Managed C++ dll: #define _AFXDLL or do not use /MD[ d]?的更多相关文章

  1. #error: Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

    转载:https://www.cnblogs.com/cvwyh/p/10570920.html 错误 在使用VS编译文件时出现了如下错误: #error: Building MFC applicat ...

  2. error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

    今天在开发过程中遇到了C1189 error.找了好久解决办法,最后自己解决了...... 方法:工程右键->属性 编辑预处理器定义: 再次运行,就解决了.

  3. 其原因可能是堆被损坏,这说明**.exe中或它加载的任何DLL中有Bug

    最近在写一个写日志文件的线程时,调用了HeapAlloc/HeapFree 申请/释放堆缓冲内存.调用HeapFree释放有个条件就是,日志的空闲缓冲队列中内存块超过100个.在测试的时候,发现调用H ...

  4. C++调用C#生成的DLL文件的各种问题

    C++调用C#生成的DLL文件: 首先选择建立一个C#的类库,然后再按照需求编写需要的函数 之后,对于C++调用过程需要注意的几点: 1.使用#using <....some.dll>指出 ...

  5. Error C1189: #error: Please use the /MD switch for _AFXDLL builds

    在VS 2013中编译程序时出现错误: 错误提示1: error C1189: #error : Building MFC application with /MD[d] (CRT dll versi ...

  6. c++MFC工程修改在共享DLL中使用MFC为使用标准Windows库的解决办法

    由于创建MFC工程时,默认是在共享DLL中使用MFC,如果将此选项改成使用标准Windows库,会报如下错误 c:\program files\microsoft visual studio 9.0\ ...

  7. Error C1189: #error: Please use the /MD switch for _AFXDLL builds(转)

    原文转自 https://www.cnblogs.com/zwh0214/p/6048360.html 在VS 2013中编译程序时出现错误: 错误提示1: error C1189: #error : ...

  8. fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC sha

    调试程序时出现以下问题:d:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): fatal e ...

  9. 共享MFC dULL

    >------ 已启动生成: 项目: OSGtest, 配置: Debug Win32 ------1>正在编译...1>AddScene.cpp1>main.cpp1> ...

随机推荐

  1. Supported Values for @SuppressWarnings(转)

    Update July 2011: This list has been reviewed and made current with the most recent Eclipse 3.7 rele ...

  2. 中国移动CMPP协议、联通SGIP协议、电信SMGP协议短信网关

    移动cmpp协议 英文缩写:CMPP (China Mobile Peer to Peer) 中文名称:中国移动通信互联网短信网关接口协议 说明:为中国移动通信集团公司企业规范.规范中描述了中国移动短 ...

  3. 一种高效的序列化方式——MessagePack

    最近在弄一些数据分析方面的内容,发现很多时候数据瓶颈在模块之间的数据序列化和反序列化上了,原来项目中用的是Json,找了一圈发现Json.net在Json序列化库中已经是性能的佼佼者了,便准备从序列化 ...

  4. LPC-LINK 2

    LPC-Link 2 is an extensible, stand-alone debug adapter that can be configured to support various dev ...

  5. AI 实验--v_JULY_v

    http://blog.csdn.net/v_JULY_v http://www.julyedu.com/

  6. 解决ubuntu上在androidstudio中启动emulator闪退的问题(1)

    作者 彭东林 pengdonglin137@163.com 平台 Ubuntu14.04 64 androidstudio 2.3.3 现象 在创建好模拟器后,点击启动时,模拟器界面刚出来就闪退了 解 ...

  7. win7设置电脑锁屏时间

    方法/步骤 1 小编用的win7电脑,进入控制面板先~ 2 选择系统与安全选项. 3 如图所示,箭头所指,可以设置锁屏时间,不过电源选项中还有个设置开启屏幕输入密码的设置,第一个就是. 4 如图所示, ...

  8. WordPress主题开发:评论框

    方法一:调出内置评论框: 文章开启评论: 页面开启评论:(注意:如果使用的是插件,点快速编辑是没有“允许评论”可勾选的) 在对应的地方,插入 <?php comments_template(); ...

  9. go 删除数组元素

    golang中对一个slice进行“slice”可以取片段得到一个新的slice,那么如何用简洁的代码删除slice中的一个元素呢? a := []int{0, 1, 2, 3, 4} //删除第i个 ...

  10. 行尸走肉第一季/全集The Walking Dead迅雷下载

    本季The Walking Dead 1 第一季(2010)看点:<行尸走肉>讲述了警察瑞克在一次执法行动中因中弹负伤而不省人事,当他从昏迷中苏醒后却惊讶地发现,这个世界已然天翻地覆.周遭 ...