problem implementing a com component callback procedure
Hi
I am working with a com component, which I have added a reference to in my C#. I am using windows vista (32 bit) and VS2005.
I have to implement a callback object which handles data being returned from the com object, which derives from an interface called IDeviceEvents which is part of the com component, which I have attempted to do in my c# code:
Code:
unsafe class cFM2Notify : IDeviceEvents
{
public string m_CallbackEvent = "";
public void NotifyData(IFM2DeviceEvents CallbackData)
{
}
public string CallbackEvent
{
get
{
return m_CallbackEvent = CallbackEvent;
}
set
{
CallbackEvent = m_CallbackEvent;
}
}
}
This is a shortened version - there are actually a few more properties and methods that I am required to implement, other than the ones shown.
The code builds ok, however, it falls over when run, a StackOverflowException being generated.
My VB.net colleague has suggested that I make the class com visible by prefixing the cFM2Notify declaration with[ComVisible(true)]. However I still a StackOverflowException being generated.
Any ideas on what I am doing wrong?
Cheers
Simon
Re: problem implementing a com component callback procedure
You're not writing VB here you know : we have the 'return' keyword in C# for returning values from functions.
The problem lies in your CallbackEvent property - it should be :
Code:
public string CallbackEvent
{
get
{
return m_CallbackEvent;
}
set
{
m_CallbackEvent = value;
}
}
If you've coded your other properties the same way then they will need changing too.
Darwen.
Re: problem implementing a com component callback procedure
Hi Darwen
Thanks for the reply, it now works. Rather silly mistake on my part
thanks again
simon