首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MsmqIntegrationBinding创建WCF服务时出现异常

使用MsmqIntegrationBinding创建WCF服务时出现异常
EN

Stack Overflow用户
提问于 2009-12-23 19:57:53
回答 1查看 4K关注 0票数 2

我的机器是Windows7旗舰版(64位)。我已经安装了MSMQ,并检查了它是否工作正常(运行了一些MSMQ的示例代码)。

当我尝试使用MsmqIntegrationBinding类创建一个WCF服务时,我得到了以下异常:

“打开队列时出错:队列不存在或您没有足够的权限执行该操作。(-1072824317,0xc00e0003)。无法从队列发送或接收消息。请确保MSMQ已安装并正在运行。同时确保队列可以使用所需的访问模式和授权打开。”

我正在管理员模式下运行visual studio,并使用以下命令通过URL ACL显式地向自己授予权限: netsh http add urlacl url=http://+:80/ user=DOMAIN\user

代码如下:

代码语言:javascript
复制
 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();
        }
    }

你能帮帮忙吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-12-23 20:02:32

确保您已经在MSMQ中创建了"Orders“队列。

在Windows Server2008中,您可以从服务器管理器(右键单击“我的电脑”并选择“管理”)执行此操作,然后选择“Feature -> Message Queuing -> Private Queues”。右键单击Private Queues并在那里添加您的"Orders“队列。

你可能还想看看Nicholas Allen的文章:Diagnosing Common Queue Errors。它表明您的错误只能是:“该队列不存在,或者您可能错误地指定了队列名称”。所有其他错误情况都会抛出不同的异常。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1952370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档