Try
Dim messageQueuePath As String = ".\private$\EmailQueue"
_msmqQueue = New MessageQueue(messageQueuePath)
_msmqQueue.Formatter = New BinaryMessageFormatter()
_msmqQueue.MessageReadPropertyFilter.SetAll()
_msmqQueue.ReceiveCompleted += New ReceiveCompletedEventHandler(msmqQueue_ReceiveCompleted)
_msmqQueue.BeginReceive()
Console.WriteLine("Enter 'A' to Exit ")
While Console.ReadKey().Key <> ConsoleKey.A
Thread.Sleep(0)
End While
Catch oEx As Exception
Console.WriteLine(oEx.Message)
Console.ReadKey()
End Try
Thank's for your reply, but if you convert this sentence _msmqQueue.ReceiveCompleted+=newReceiveCompletedEventHandler(msmqQueue_ReceiveCompleted);
by this one : AddHandler _msmqQueue.ReceiveCompleted,AddressOf msmqQueue_ReceiveCompleted
Where is the '+=' operator ?
Is there a risk without this operator to lost some informations?
cheickna
Member
144 Points
96 Posts
Problem to convert C# code to VB.Net
Nov 18, 2012 10:44 PM|LINK
Hello,
I tried to convert a C# code to VB.Net code into my asp.net app but i get an error message about how call an Event.
The C# code is following :
try { string messageQueuePath = @".\private$\EmailQueue"; _msmqQueue = new MessageQueue(messageQueuePath); _msmqQueue.Formatter = new BinaryMessageFormatter(); _msmqQueue.MessageReadPropertyFilter.SetAll(); _msmqQueue.ReceiveCompleted+=new ReceiveCompletedEventHandler(msmqQueue_ReceiveCompleted); _msmqQueue.BeginReceive(); Console.WriteLine("Enter 'A' to Exit "); while(Console.ReadKey().Key!=ConsoleKey.A) { Thread.Sleep(0); } } catch(Exception oEx) { Console.WriteLine(oEx.Message); Console.ReadKey(); }I transformed all parts of this code except this :
The error message ask me to use RaiseEvent to call ReceiveCompleted because it is an Event when i use this conversion :
I used AddressOf to avoid another error but i always have tne Event Error.
Thank's a lot for any help
David Anton
Contributor
3704 Points
638 Posts
Re: Problem to convert C# code to VB.Net
Nov 19, 2012 04:21 AM|LINK
http://www.tangiblesoftwaresolutions.com
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter
iGulfam
Contributor
4794 Points
947 Posts
Re: Problem to convert C# code to VB.Net
Nov 19, 2012 04:28 AM|LINK
Try Dim messageQueuePath As String = ".\private$\EmailQueue" _msmqQueue = New MessageQueue(messageQueuePath) _msmqQueue.Formatter = New BinaryMessageFormatter() _msmqQueue.MessageReadPropertyFilter.SetAll() _msmqQueue.ReceiveCompleted += New ReceiveCompletedEventHandler(msmqQueue_ReceiveCompleted) _msmqQueue.BeginReceive() Console.WriteLine("Enter 'A' to Exit ") While Console.ReadKey().Key <> ConsoleKey.A Thread.Sleep(0) End While Catch oEx As Exception Console.WriteLine(oEx.Message) Console.ReadKey() End Tryhttp://converter.telerik.com/
http://www.developerfusion.com/tools/convert/csharp-to-vb/
My BLOG
cheickna
Member
144 Points
96 Posts
Re: Problem to convert C# code to VB.Net
Nov 19, 2012 09:48 AM|LINK
hello,
Thank's for your reply, but if you convert this sentence
_msmqQueue.ReceiveCompleted+=new ReceiveCompletedEventHandler(msmqQueue_ReceiveCompleted);
by this one :
AddHandler _msmqQueue.ReceiveCompleted, AddressOf msmqQueue_ReceiveCompleted
Where is the '+=' operator ?
Is there a risk without this operator to lost some informations?
Thank's in advance for your reply
David Anton
Contributor
3704 Points
638 Posts
Re: Problem to convert C# code to VB.Net
Nov 19, 2012 07:46 PM|LINK
There's no risk - VB does things differently than C#. Simple as that.
http://www.tangiblesoftwaresolutions.com
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter