1
我有一個類叫做MyServiceHost.vb:WCF的問題或事件hadling問題
public class MyServiceHost : ServiceHost
{
private Dictionary<int, Service> _activeClients;
public event EventHandler<MessageReceivedEventArgs> MessageReceived;
}
之後以另一種形式我想有第二線在我的其他形式,我定義這些行:
_host = new MyServiceHost(typeof(Service));
_host.MessageReceived += new EventHandler<MessageReceivedEventArgs>(_host_MessageReceived);
_host.Open();
如何把它們寫在Vb.net請大家幫忙,以下內容似乎不工作:
_host = New MyServiceHost(GetType(Service))
_host. += New EventHandler(Of MessageReceivedEventArgs)(AddressOf _host_messageRecieved)
另外請注意,我MyServiceHos t.vb類看起來像這樣:
Dim _activeClients As Dictionary(Of Integer, Service)
Public Event MessageReceived As EventHandler(Of MessageReceivedEventArgs)
什麼是錯?
你嘗試以下[C#到VB轉換工具(http://www.developerfusion.com/tools/convert/csharp-to-vb/)? – Vitaliy 2011-03-12 19:31:13
是的,仍然沒有工作。我無法在vbcode – FidEliO 2011-03-12 19:38:04
中以我的表單形式訪問messagerecieved事件我不確定這是否有幫助,但[here](http://social.msdn.microsoft.com/Forums/eu/wcf/thread/8eb6f396-1774-49f7 -9ac5-29797947ad92)與從C#到VB的WCF轉換類似的問題 – Vitaliy 2011-03-12 20:07:57