我是 VB6 和 MSMQ 的新手。我在网上浏览了很多教程,但似乎我的问题没有解决方案。
我设法从 C# 发送到 C# 或 VB6 到 VB6,但不是从 VB6 到 C#,反之亦然。所以我想知道这是一种方法,还是没有办法进行这种交流。
例如:我想将此发送到 MSMQ
Dim PropBag As PropertyBag
Set PropBag = New PropertyBag
PropBag.WriteProperty "Customer", "Bob"
PropBag.WriteProperty "Product", "MoeHairSuit"
PropBag.WriteProperty "Quantity", 4
并在 C# 中获取详细信息,有“给定编码中的无效字符。第 1 行,位置 1。” 使用 XmlMessageFormatter 时出错
Message mes = mq.Receive(new TimeSpan(0, 0, 3));
mes.Formatter = new XmlMessageFormatter(new String[] { "System.String,mscorlib" });
result = mes.Body.ToString();
我也尝试从流中读取,但它在我的字符串中出现了一个奇怪的符号。下面是代码,这是输出“늓\0\0\b\b휖ꭑ(\0customer\0Bob\0\b\a剂틠4\0product\v\0MoeHairSuit\b调⫳ᄂ.quantity\0 "
Message mes;
mes = mq.Receive(new TimeSpan(0, 0, 3));
mes.BodyStream.Position = 0;
byte[] b = new byte[mes.BodyStream.Length];
mes.BodyStream.Read(b, 0, (int)mes.BodyStream.Length);
UnicodeEncoding uniCoder = new UnicodeEncoding();
result = uniCoder.GetString(b);
我收到此异常“无法反序列化作为参数传递的消息。无法识别序列化格式。” 使用 ActiveXMessageFormatter 时,如下所示
mes = mq.Receive(new TimeSpan(0, 0, 3));
mes.Formatter = new ActiveXMessageFormatter();
result = mes.Body.ToString();
你们知道怎么做吗?先谢谢了