如何重新发明WcfSvcHost.exe?

时间:2015-10-24 21:20:06

标签: c# .net wcf msmq

我正在发帖,因为我在2015年10月17日的帖子上没有取得多大成功: My query in Microsoft Forums。我在Sample WCF/MSMQ demo that produces DLL that works with WcfSvcHost跟随这个例子。我正在使用简化的"无安全性"代码的版本。我只对App.Config进行了微小的更改(比如更改计算机名称并添加了一个限制:

<serviceThrottling maxConcurrentCalls="1" maxConcurrentInstances="1"/>

这是我的问题:

如何重新发明WcfSvcHost.exe,以便我可以使用服务控制管理器(SCM或SC)或命令提示符来运行我的WCF服务。此命令有效:

  WcfSvcHost.exe /Service:MSMQNoSecurityService.dll
       /config:MSMQNoSecurityService.dll.config

Microsoft明确声明此wcfSvcHost.exe专门用于调试,而不用于生产。请参阅下面的源代码并堆栈跟踪我尝试重新发明wcfSvcHost.exe。问题是WcfSvcHost正在读取XML并做一些我在源代码中没有做的特殊事情。那是什么?有人能告诉我那是什么吗?显然,我需要读取该XML文件并从中提取信息,以便对WCF / Windows API进行一些函数调用,但是哪些函数调用?

谢谢。

齐格弗里德

这是我的源代码不起作用:

namespace HostMSMQNoSecurity {
class Program {
    static void Main(string[] args) {
        var baseAddress = "net.msmq://km/private/TestQueue";
        using (var host = new System.ServiceModel.ServiceHost(typeof(MSMQService))) {
            host.AddServiceEndpoint(typeof(IMSMQService),  new System.ServiceModel.NetMsmqBinding(), baseAddress);
            host.Open(); // Exception is throw here
            Console.WriteLine("Service host running...... Hit return to exit");
            Console.ReadLine();
            host.Close();
        }
    }
}

这是堆栈跟踪:

Unhandled Exception: System.InvalidOperationException: Binding validation failed because the binding's MsmqAuthenticationMode property is set to WindowsDomain but MSMQ is installed with Active Directory integration disabled. The channel factory or service host cannot be opened.
   at System.ServiceModel.Channels.MsmqVerifier.VerifySecurity(MsmqTransportSecurity security, Nullable`1 useActiveDirectory)
   at System.ServiceModel.Channels.MsmqVerifier.VerifyReceiver(MsmqReceiveParameters receiveParameters, Uri listenUri)
   at System.ServiceModel.Channels.MsmqTransportBindingElement.BuildChannelListener[TChannel](BindingContext context)
   at System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[TChannel]()
   at System.ServiceModel.Channels.MessageEncodingBindingElement.InternalBuildChannelListener[TChannel](BindingContext context)
   at System.ServiceModel.Channels.BinaryMessageEncodingBindingElement.BuildChannelListener[TChannel](BindingContext context)
   at System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[TChannel]()
   at System.ServiceModel.Channels.Binding.BuildChannelListener[TChannel](Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, BindingParameterCollection parameters)
   at System.ServiceModel.Description.DispatcherBuilder.MaybeCreateListener(Boolean actuallyCreate, Type[] supportedChannels, Binding binding, BindingParameterCollection parameters, Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, ServiceThrottle throttle, IChannelListener& result, Boolean supportContextSession)
   at System.ServiceModel.Description.DispatcherBuilder.BuildChannelListener(StuffPerListenUriInfo stuff, ServiceHostBase serviceHost, Uri listenUri, ListenUriMode listenUriMode, Boolean supportContextSession, IChannelListener& result)
   at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
   at System.ServiceModel.ServiceHostBase.InitializeRuntime()
   at System.ServiceModel.ServiceHostBase.OnBeginOpen()
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open()
   at HostMSMQNoSecurity.Program.Main(String[] args) in c:\Users\siegfried\Documents\WinOOP\Examples\WCF\C#\CodeProject\MSMQ Service With No Security\MSMQNoSecurityService\HostMSMQNoSecurity\Program.cs:line 14

Compilation exited abnormally with code 127 at Wed Oct 21 19:49:00

0 个答案:

没有答案