我想从非托管C++调用我的.NET代码.我的进程入口点是基于.NET的,所以我不必担心托管CLR.我知道可以使用.NET包装器来完成.NET对象,但是我想访问托管类的各个静态方法,因此COM不是我最短/最简单的路径.
谢谢!
这是我的另一个问题,也引用了这个问题作为参考: 如何从Un-managed C++调用托管C++方法
我已经成功创建了一个C#COM文件.现在我需要一个关于如何在非托管C++中实现它的简单解释.
我正在关注这个例子,但是c ++部分很弱. http://www.codeproject.com/Articles/7859/Building-COM-Objects-in-C
这是我的COM文件
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace cSharpRiJHarn
{
[Guid("ED1483A3-000A-41f5-B1BC-5235F5897872")]
public interface DBCOM_Interface
{
[DispId(1)]
String encrypt(string s);
[DispId(2)]
String decrpyt(string s);
}
[Guid("A6BCEC1D-B60C-4c97-B9AD-1FE72642A9F8"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface DBCOM_Events
{
}
[Guid("7C13A8C6-4230-445f-8C77-0CA5EDECDCB5"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(DBCOM_Events))]
public class RijndaelLink : DBCOM_Interface
{
public String encrypt(String s)
{
return Rijndael.EncryptString(s);
}
public String decrpyt(String s)
{
return Rijndael.DecryptString(s);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我只想要一个非常基本的例子来使用非托管代码.请在你的答案中包括:
谢谢你的帮助!