【发布时间】:2009-12-23 11:57:53
【问题描述】:
我的机器是 Windows 7 Ultimate(64 位)。我已经安装了 MSMQ 并检查它是否工作正常(为 MSMQ 运行了一些示例代码)。
当我尝试使用 MsmqIntegrationBinding 类创建 WCF 服务时,出现以下异常:
“打开队列时出错:队列不存在或您没有足够的权限执行该操作。(-1072824317, 0xc00e0003)。无法从队列发送或接收消息。请确保MSMQ已安装并正在运行。还要确保可以使用所需的访问模式和授权打开队列。"
我正在管理员模式下运行 Visual Studio,并通过 URL ACL 使用以下命令明确授予自己权限: netsh http 添加 urlacl url=http://+:80/user=DOMAIN\user
下面是代码:
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();
}
}
你能帮忙吗?
【问题讨论】:
标签: wcf msmqintegrationbinding