我有一类称为MyServiceHost.vb:
I have a class called MyServiceHost.vb:
public class MyServiceHost : ServiceHost
{
private Dictionary<int, Service> _activeClients;
public event EventHandler<MessageReceivedEventArgs> MessageReceived;
}
之后以另一种形式我想在我的其他形式,我定义这些行的第二行:
After that in another form I want to have the second line in my other form I defined these lines:
_host = new MyServiceHost(typeof(Service));
_host.MessageReceived += new EventHandler<MessageReceivedEventArgs>(_host_MessageReceived);
_host.Open();
如何把它们写在Vb.net请大家帮忙,以下似乎不工作:
How to write them in Vb.net please help, the followings does not seem to work:
_host = New MyServiceHost(GetType(Service))
_host. += New EventHandler(Of MessageReceivedEventArgs)(AddressOf _host_messageRecieved)
另外请注意,我MyServiceHost.vb类看起来是这样的:
Also note that my MyServiceHost.vb class looks like this:
Dim _activeClients As Dictionary(Of Integer, Service)
Public Event MessageReceived As EventHandler(Of MessageReceivedEventArgs)
什么是错的?
What is wrong?
请尝试使用:
AddHandler _host.MessageReceived, AddressOf _host_messageRecieved