Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I have to use a c++ DLL in c# and I have to import in my c# program this function defined in the c++ DLL:
void rtdGetSkillsetListResult(bool success, const st 问问题
问问题 2013-04-04T10:55:56.200 284 次 This question shows research effort; it is useful and clear 1 This question does not show any research effort; it is unclear or not useful Bookmark this question. Show activity on this post. I have to use a c++ DLL in c# and I have to import in my c# program this function defined in the c++ DLL: void rtdGetSkillsetListResult(bool success, const std::list <skillset_info> skillsetList) How can I "translate" in c# const std::list <skillset_info> where skillset_info has defined in c++ dll with the following structure: struct skillset_info { std::string code; bool standby; }; Thanks a lot! Managed C# code cannot consume unmanaged C++ objects like std::list. So you cannot use the unmanaged DLL directly from C#. The simplest solution will be to make a C++/CLI layer that adapts from unmamaged to managed. Another option would be to adapt the unmamaged code so that it was callable with p/invoke but I think that would involve more effort than C++/CLI. c#c++marshallingdllimport 4 1 回答 1 This answer is useful 3 托管 C# 代码不能使用非托管 C++ 对象,例如std::list. 因此,您不能直接从 C# 使用非托管 DLL。 最简单的解决方案是制作一个从未损坏到托管的 C++/CLI 层。 另一种选择是调整未损坏的代码,以便可以使用 p/invoke 调用它,但我认为这比 C++/CLI 需要更多的努力。 于 2013-04-04T11:01:48.033 回答 Related 2 licensing - 安装 Win CE 6.0 许可证 3 class - visual basic 6 类图像 1 ruby-on-rails - redis 数据库大小(2N 或 N^2) 2 sql - 计算在多个网站上订购的用户的订单数量 1 facebook-graph-api - 为什么洞察力与图表不匹配? 1 asp.net - 如何降低 asp.net gridview 控件的整体高度? 1 macros - 跨 CMakeLists 的 CMake 宏 2 c++ - 多个相似的函数编码风格 3 android - Android SqlLite 没有这样的列 _id 异常 1 c# - 自定义管道组件 SSIS 错误:HREF 0xC0048021 Reference php × 1429865 c/c++ × 756500 nginx × 49975 mongodb × 159057 mybatis × 3233 anaconda × 13410 pycharm × 14671 python × 1902243 vscode × 56040 docker × 110988 github × 49000 flask × 49129 ffmpeg × 24037 jmeter × 16910 matplotlib × 63493 bootstrap × 54641
void rtdGetSkillsetListResult(bool success, const std::list <skillset_info> skillsetList)
How can I "translate" in c#
const std::list <skillset_info>
where skillset_info has defined in c++ dll with the following structure:
struct skillset_info { std::string code; bool standby; };
Thanks a lot!
Managed C# code cannot consume unmanaged C++ objects like std::list. So you cannot use the unmanaged DLL directly from C#.
std::list
The simplest solution will be to make a C++/CLI layer that adapts from unmamaged to managed.
Another option would be to adapt the unmamaged code so that it was callable with p/invoke but I think that would involve more effort than C++/CLI.
托管 C# 代码不能使用非托管 C++ 对象,例如std::list. 因此,您不能直接从 C# 使用非托管 DLL。
最简单的解决方案是制作一个从未损坏到托管的 C++/CLI 层。
另一种选择是调整未损坏的代码,以便可以使用 p/invoke 调用它,但我认为这比 C++/CLI 需要更多的努力。