I am playing with vc++.net and wrapping the joy* api into a class. The method I want to use is to have a msgloop and event structure in the class so that when it is used in vb.net or C# the user won't need to worry about a callback function.

the C++ Concept is very simple.
Code:
#using <mscorlib.dll>

using namespace System;

namespace IO{
	
	[event_source(managed)]
	public __gc class JoyStick{
	public:
		__event void ButtonPress();

		void RaiseButtonPress(){
			ButtonPress();
		}

	};
}
compiles fine...

left this out before
VB Code:
  1. Module x
  2.     Private xx As New Magiaus.IO.JoyStick()
  3.     Sub Main()
  4.  
  5.         xx.__Delegate_ButtonPress.CreateDelegate(Type.GetType("Magiaus.IO.JoyStick"), xx, "Msg", True)
  6.         xx.RaiseButtonPress()
  7.  
  8.     End Sub
  9.  
  10.     Sub Msg()
  11.         MsgBox("Test")
  12.     End Sub
  13. End Module

But, when I get into VB.Net and I try to setup a delegate using the __Delegate_ButtonPressed method that is shown in my intelsense I get a can't be null error. It just ccued to me that it could be because its void but I don't think so.

If any of you guys have done anything like this let me know. personally i was hopeing that i could just use AddHandler somehow... i have exmple of useing this c++ to c++ but nothing on doing it in vb.net or c#... I know it should work. But if it proves to hard I will just change the design i have and make a QueryState method or something.

Any sugestions on the object structure appriciated.