Give you a small example, if you have a bit of foundation, you should be able to comprehend by analogy.
| 12345678910111213141516171819202122232425262728 |
usingSystem.Messaging;// 建一个类publicclassPerson{ publicstringFirstName { get; set; } publicstringLastName { get; set; }}//写入消息部分Person p = newPerson(){ FirstName = "Bruce", LastName = "Lee"}; System.Messaging.Message msg = newSystem.Messaging.Message(); msg.Body = p; MessageQueue msgQ =newMessageQueue(".\\Private$\\TestQueue"); msgQ.Send(msg);//读出消息部分MessageQueue msgQ = newMessageQueue(".\\Private$\\TestQueue");msgQ.Formatter = newXmlMessageFormatter(newType[] { typeof(Person) });varmessage = (Person)msgQ.Receive().Body;Console.WriteLine("FirstName: "+ message.FirstName + ", LastName: "+ message.LastName);Console.WriteLine("Message received ......"); |
Ask:
Prompt for missing references, importing which
Chase Answer:
Using System.Messaging;
Quoting this, I'm not writing it.
Ask:
Written, or wrong .... Hint does not exist messaging
Chase Answer:
You add the quote Ah, right click on your project, add the reference (Add Reference ...), and then select the framework under the System.Messaging, and then add to the online tutorial, how to add DLL reference.
C # queues