异常创建一个WCF服务使用MsmqIntegrationBinding
-
21-09-2019 - |
题
我的机器是视窗7最终(64位)。我已经安装MSMQ并检查它是否工作正常(跑MSMQ一些示例代码)。
当我尝试创建一个WCF服务使用MsmqIntegrationBinding类,我得到以下异常:
“发生错误,同时打开队列:。所述队列不存在或您没有足够的权限来执行该操作(-1072824317,0xc00e0003)不能从队列发送的消息或接收到的确保MSMQ安装并运行。另外确保队列可与所需的访问模式和授权打开“。
我运行在管理员模式下的Visual Studio,并通过使用URL ACL明确授予的权限对自己说: netsh的HTTP添加urlacl URL = HTTP:// +:80 / 用户= DOMAIN \用户
下面是代码:
public static void Main()
{
Uri baseAddress = new Uri(@"msmq.formatname:DIRECT=OS:AJITDELL2\private$\Orders");
using (ServiceHost serviceHost = new ServiceHost(typeof(OrderProcessorService), baseAddress))
{
MsmqIntegrationBinding serviceBinding = new MsmqIntegrationBinding();
serviceBinding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None;
serviceBinding.Security.Transport.MsmqProtectionLevel = System.Net.Security.ProtectionLevel.None;
//serviceBinding.SerializationFormat = MsmqMessageSerializationFormat.Binary;
serviceHost.AddServiceEndpoint(typeof(IOrderProcessor), serviceBinding, baseAddress);
serviceHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("The service is running in the following account: {0}", WindowsIdentity.GetCurrent().Name);
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown the service.
serviceHost.Close();
}
}
您可以请帮助?
解决方案
请确保您在MSMQ创建的“订单”队列。
在Windows Server 2008中,您可以从服务器管理器这样做(右键点击我的电脑,选择管理),然后特点 - >消息队列 - >专用队列。右键单击专用队列,并添加“订单”队列存在。
您可能还需要检查聂雅伦的文章:的诊断常见的队列错误。这表明,你的错误只能是:“的队列不存在,或者您指定的队列名称不正确”。所有其他错误情况会抛出一个不同的异常。
不隶属于 StackOverflow