编写C#托管code在本地C ++ [英] Writing C# managed code in native C++

查看:788
本文介绍了编写C#托管code在本地C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个管理LIB(使用微软的Web服务)和我 包括它变成一个C ++项目。该项目不使用 / CLR 选项, 所以当我有我的库的头文件VS2005告诉我一个错误 他说我必须使用 / CLR 选项。这样做我有一个不兼容 与 / EHS 命令行选项(错误D8016),但是从 EHS 更改为 没有异常处理没有解决的问题,让我展示同样的错误。

I am developing a managed lib (using Microsoft Web Services) and I am including it into a c++ project. The project doesn't use /clr option, so when I include my library's header file VS2005 show me an error saying I have to use /clr option. Doing this I have a incompatibility with /EHs command line option (error D8016), but changing from EHs to no exception handling not solving problem and keep showing me same error .

任何建议是值得欢迎的。

Any suggestion is welcome.

感谢你在前进。

推荐答案

如果您有非托管C ++ code和要使用管理code,你有几种选择:

If you have unmanaged C++ code and want to use managed code, you have a few options:

  • 更改您的非托管code到C ++ / CLI,通过使用 / CLR 开关。
  • 在写C ++ / CLI包装库。它可以DLL的出口,你在你的非托管code调用非托管功能。
  • 跳过通过<一个包装库,并直接DLL出口非托管函数href="http://sites.google.com/site/robertgiesecke/Home/uploads/csharpprojecttemplateforunmanagedexports"相对=nofollow>这个库。
  • Change your unmanaged code to C++/CLI, by use of the /clr switch.
  • Write a C++/CLI wrapper library. It could DLL-export unmanaged functions which you call in your unmanaged code.
  • Skip the wrapper library and directly DLL-export unmanaged functions via this library.

这篇关于编写C#托管code在本地C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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