Groups | Blog | Home
all groups > vb.net > february 2007 >

vb.net : Calling C# DLL from VB.NET


tim8w via DotNetMonster.com
2/28/2007 6:06:19 PM
I'm trying to setup a SelectionChangeHandler for a call to a DLL written in
C#. In the C# DLL, the public declaration is as follows:

public event SelectionChangedHandler SelectionChanged;


To call this from C# I do the following:

ofdPicture.SelectionChanged += new ExtensibleDialogs.
OpenFileDialog.SelectionChangedHandler(ofdPicture_SelectionChanged);

where ofdPicture_SelectionChanged is the name of my function in the C#
calling program.


If I try to use the same line in VB.NET I get the following error:

'Event SelectionChanged(path As String)' is an event, and cannot be called
directly. Use a 'RaiseEvent' statement to raise an event.

Any idea on how to set this up correctly?

--
Message posted via http://www.dotnetmonster.com
tim8w via DotNetMonster.com
2/28/2007 6:35:01 PM
Herfried,


Thanks. I did the following and it worked great!

AddHandler ofdPicture.SelectionChanged, AddressOf
ofdPicture_SelectionChanged

and when I was done with it:

RemoveHandler ofdPicture.SelectionChanged, AddressOf
ofdPicture_SelectionChanged

--
Message posted via http://www.dotnetmonster.com
Herfried K. Wagner [MVP]
2/28/2007 7:09:21 PM
"tim8w via DotNetMonster.com" <u31412@uwe> schrieb:
[quoted text, click to view]

Check out the documentation on 'AddHandler', 'RemoveHandler', 'WithEvents',
and 'Handles'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
AddThis Social Bookmark Button