End Google Ads 201810 - BS.net 01 --> First, let me say that I am not a C# programmer. Complete newb here... Don't hate me because I'm beautiful...

I am trying to create a drop-dead simple application that will set a function callback address in the C++ COM dll to point to a C# function in the demo application. (This is for a sample application to demonstrate our API to potential users.) I have it working for both C++ and Visual Basic, but thus far, C# success is eluding me.

Here is what I have done...
Created a simple form with three text boxes that will be filled with XYZ values when everything works.
Within the namespace of my app (TestCSharpApp... so I lack imagination... sue me...) I have created a delegate function like this.

public delegate void coordCallbackFunction(double x, double y, double z, int buttonNumber );

In my public partial class Form1 : Form class, I have the function I want to call.
public void coordHandler(double x, double y, double z, int buttonNumber)
{
xCoord.Text = x.ToString();
yCoord.Text = y.ToString();
zCoord.Text = z.ToString();
}


Finally, In the form load function I have this code.

MyCOMInterfaceLib.MyCOMClassClass myApi = new MyCOMInterfaceLib.MyCOMClassClass();
myApi.coordCallback += new coordCallbackFunction(this.coordHandler);

I realize that myApi will go away right after setting up the callback, but I am just trying to get it to compile. I'll worry about details later.

When I compile the program I get this error...

Error 1 Cannot implicitly convert type 'TestCSharpApp.coordCallbackFunction' to 'MyCOMInterfaceLib._IMyCOMClassEvents_coordCallbackEventHandler' C:\Temp\TestCSharpApp\Form1.cs 38

I have included the MyComInterfaceLib in my list of references. I can call functions from the COM dll and that works fine. The problem is setting the callback function using delegates.

It may not mean much, but the callback functions work fine in VB.Net, so I don't think the problem is in the COM dll.

Thank you for any help.