[问题]

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. Linux/CentOS实现交换机-简单的交换机实现

    个人理解: 1.交换机的核心在于Mac地址学习,使其能在全双工/半双工下进行转发工作. 2.对于专业的交换机来说,使用的是专业的网络芯片并自己实现里面的协议,比如说华为的,为什么能卖那么贵,贵在于网络 ...

  2. spring-boot 速成(7) 集成dubbo

    github上有一个开源项目spring-boot-starter-dubbo 提供了spring-boot与dubbo的集成功能,直接拿来用即可.(记得给作者点赞,以示感谢!) 下面是使用步骤,先看 ...

  3. 使用ptrace向已运行进程中注入.so并执行相关函数(转)

    1. 简介 使用ptrace向已运行进程中注入.so并执行相关函数,其中的“注入”二字的真正含义为:此.so被link到已运行进程(以下简称为:目标进程)空间中,从而.so中的函数在目标进程空间中有对 ...

  4. WiX: uninstall older version of the application

    I have installer generated by WiX and I want it to ask: "You have already installed this app. D ...

  5. UITableView分割线样式与颜色

    tv.separatorStyle = UITableViewCellSeparatorStyleSingleLine;   //设置样式 tv.separatorColor = [UIColor c ...

  6. [shiro学习笔记]第四节 使用源码生成Shiro的CHM格式的API文档

    版本号为1.2.3的shiro API chm个事故文档生成. 获取shiro源码 编译生成API文档 转换成chm格式 API 获取shiro源码 shiro官网: http://shiro.apa ...

  7. Unity3D——SendMessage方法的使用

    SendMessage效率不高,因为每次调用的时候都会去遍历检测自身或者子节点上要调用的方法. 一.方法 GameObject自身的Script SendMessage("函数名" ...

  8. 使用系统自带的 UIRefreshControl 实现下拉刷新

    UIRefreshControl 为 UITableViewController 中的一个属性,从以下可以看出, IOS6.0 以上才支持. @property (nonatomic,retain) ...

  9. libcurl上传文件

    libcurl参数很多,一不小心就容易遇到问题.曾经就遇到过一个很蛋疼的问题:libcurl断点下载>>   这里主要汇总一下,libcurl上传的二种方式: 1.直接上传文件,类似for ...

  10. ios之单例模式

    原帖地址:http://www.galloway.me.uk/tutorials/singleton-classes/ 本文为博主自行翻译,转载请注明出处:http://blog.csdn.net/i ...