> Hi,
>
> I have a C# Exe and a VC++ ATL com dll.
> Now I have added the the VC++ ATL com dll to my C# Exe using Add
reference.
> I can able to call a function in VC++ dll from my C# code.
>
> I have another function in my C# code which has to be called from VC++
something
> like a callback.
>
> Let me explain it clearly.
> VC++...
>
> #import "D:\\ComCalling\\CSharpExe\\obj\\Debug\\CSharpExe.tlb"no_namespace
> IComTestPtr g_CSharpPtr;
>
> STDMETHODIMP CTest::SetValue(BSTR bstrValue)
> {
> AFX_MANAGE_STATE(AfxGetStaticModuleState())
> CString csProgId = bstrValue;
> MessageBox ( NULL, csValue, "Title", MB_OK );
> //Now I wanted to call a callback function in C# as something like as
shown below...
> //CreateInstance always creates a new instance, I wanted just a
callback to the running C# exe which initiated this dll.
> HRESULT hr = g_CSharpPtr.CreateInstance ( __uuidof ( Form1 ) );
>
> if ( hr == 0 )
> {
> CString csTemp ( "Message From C# Exe" );
> g_CSharpPtr->Display ( csTemp.AllocSysString ( ) );
> }
> return S_OK;
> }
>
> C# code...
> public delegate bool CallBack ( );
> public interface IComTest
> {
> void Display ( string sMessage );
> }
> [ClassInterface ( ClassInterfaceType.None )]
> public class Form1 : System.Windows.Forms.Form, IComTest
> {
> public void Display ( string sMessage )
> {
> MessageBox.Show ( sMessage );
> }
> private void button1_Click(object sender, System.EventArgs e)
> {
> TestClass obj = new TestClass ( );
> obj.SetValue ( "Form1" );
> The following two lines of code might be the solution, but I don't no how
to pass a function pointer to the VC++ dll.
> // CallBack objCallBack = new CallBack ( CallBackFunction );
> // obj.SetCallBackPointer ( objCallBack );
> }
>
> }
>
> Can anyone please help me out to achieve the goal.
>
> Expecting your kind co-operation.
>
> Thanks in advance
> --------------------------------
> From: Suyambulingam T S M
>
> -----------------------
> Posted by a user from .NET 247 (
http://www.dotnet247.com/)
>
> <Id>m8f+yd7NJ02QDYBRvG/90Q==</Id>