using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace MyInterop
{
/// <summary>
/// Summary description for Class1.
/// </summary>
///
[Guid("3E0E2EB2-CC13-40fb-9346-34809CB2418C")]
public interface IMyDotNetInterface
{
void ShowDialog ();
}
[ClassInterface(ClassInterfaceType.None)]
[Guid("3A13EB34-3930-4e06-A3EB-10724CCC2F4B")]
public class MyDotNetClass:IMyDotNetInterface
{
public MyDotNetClass ()
{
}
public void ShowDialog ()
{
MessageBox.Show ("I am a Managed DotNET C# COM Object Dialog");
}
}
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace MyInterop
{
/// <summary>
/// Summary description for Class1.
/// </summary>
///
[Guid("3E0E2EB2-CC13-40fb-9346-34809CB2418C")]
public interface IMyDotNetInterface
{
void ShowDialog ();
}
[ClassInterface(ClassInterfaceType.None)]
[Guid("3A13EB34-3930-4e06-A3EB-10724CCC2F4B")]
public class MyDotNetClass:IMyDotNetInterface
{
public MyDotNetClass ()
{
}
public void ShowDialog ()
{
MessageBox.Show ("I am a Managed DotNET C# COM Object Dialog");
}
}
}
// Call_CSharp_COM.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#import "D:\ManagedCOM\ManagedCOM\MyInterop\bin\Debug\com.MyInterop.tlb" named_guids raw_interfaces_only
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
MyInterop::IMyDotNetInterfacePtr pDotNetCOMPtr;
HRESULT hRes = pDotNetCOMPtr.CreateInstance(MyInterop::CLSID_MyDotNetClass);
if (hRes == S_OK)
{
pDotNetCOMPtr->ShowDialog ();
}
CoUninitialize ();
return 0;
}