简体   繁体   English

如何创建可用于c ++和c#的dll?

[英]How can I create a dll that can be used for both c++ and c#?

I need to develop a library that can be used for both c++ application and also by c# universal store app. 我需要开发一个库,该库可用于c ++应用程序以及c#通用商店应用程序。
My research so far: 到目前为止,我的研究:

  • Developing in c++ wont help because c# uwp will only accept PCL. 使用c ++开发将无济于事,因为c#uwp仅接受PCL。

  • Developing as PCL in c# cannot be added to c++ applications. 在c#中作为PCL开发不能添加到c ++应用程序中。

(I am not sure about the second case. Correct me if I am wrong.) (我不确定第二种情况。如果我错了,请纠正我。)
Is there way to developing a common library ? 有没有办法开发公共图书馆? or I have to develop it in those two platforms separately. 或者我必须在这两个平台上分别开发它。

如果创建C ++库,则可以从C ++中使用它(显然),并且可以为此C ++库创建一个C ++ / CX包装器,该包装器可以在C#中使用。

You can also use COM objects. 您也可以使用COM对象。 You can then import the library in Visual Studio and then they will be available as regular objects. 然后,您可以在Visual Studio中导入库,然后它们可以作为常规对象使用。

https://msdn.microsoft.com/en-us/library/ms973800.aspx https://msdn.microsoft.com/zh-CN/library/ms973800.aspx

From the CPP point of view to create COM objects the "atl" is probably the best approach. 从CPP的角度来看,创建COM对象的“ atl”可能是最好的方法。

https://msdn.microsoft.com/en-us/library/727z646z.aspx https://msdn.microsoft.com/zh-CN/library/727z646z.aspx

COM objects can be hard to implement but they can be imported in many languages and compilers. COM对象可能难以实现,但可以用多种语言和编译器导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM