[问题]

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. spring cloud 学习(8) - sleuth & zipkin 调用链跟踪

    业务复杂的微服务架构中,往往服务之间的调用关系比较难梳理,一次http请求中,可能涉及到多个服务的调用(eg: service A -> service B -> service C... ...

  2. [Go] 单元测试/性能测试 (go test)

    特征 Golang 单元测试对文件名和方法名,参数都有很严格的要求.例如: 1.文件名必须以 _test.go 结尾 2.方法名必须是 Test 开头 3.方法参数必须是 t *testing.T 或 ...

  3. PHP项目收藏

    API接口管理系统 Github上的PHP资源汇总大全 Github.com上有哪些比较有趣的PHP项目 SOAP NuSOAP - SOAP Toolkit for PHP [官网] [教程] 通用 ...

  4. 轮子科技的.NET Core分享

    2016年8月11日 应轮子科技一众好友的邀请,在轮子科技给大家做了一个无责任的瞎聊段落,聊聊.NET的Core的一些内容. 恩,演讲者就只有我一个了,讲师是微软的 MVP 杨守斌,就是因为这个,所以 ...

  5. C#把数组中的某个元素取出来放到第一个位置

    如何取出数组中符合某种条件的元素,然后放在数组最前面,即索引为0的位置? 思路大致如下:→找到符合条件的数组元素,把之赋值给一个临时变量temp,并记下该数组元素的索引位置,假设是index→在源数组 ...

  6. TStream实现多表查询

    TStream实现多表查询 function TynFiredac.QuerySQLS(const ASQL, ASQL2: string; AStorageFormat: string = 'bin ...

  7. Nginx rewrite URL examples with and without redirect address

    原文地址: http://www.claudiokuenzler.com/blog/436/nginx-rewrite-url-examples-with-without-redirect-addre ...

  8. UnityShader之光照

    .基本概念 1.光源:unity支持的光源有四种 1)平行光Directional Light 2)点光源Point Light 3)聚光灯光源Spot Light 4)区域光光源Area Light ...

  9. ios之如何读取plist

    - (NSDictionary*)contactsInfoFromPlistNamed:(NSString*)plistName { NSString *path = [[NSBundle mainB ...

  10. Process 'command '/Users/lidaqiang/Library/Android/sdk/build-tools/27.0.3/aapt'' finished with non-zero exit value 1

    Process 'command '/Users/lidaqiang/Library/Android/sdk/build-tools/27.0.3/aapt'' finished with non-z ...