簡體   English   中英

作為NetworkService運行時,WCF EndpointNotFoundException

[英]WCF EndpointNotFoundException when running as NetworkService

我有一個由IIS托管的net.Pipe WCF服務(目前在我的VS2010中):(Global.asax):

 protected void Application_Start()
{
  AreaRegistration.RegisterAllAreas();

  WebApiConfig.Register(GlobalConfiguration.Configuration);
  FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
  RouteConfig.RegisterRoutes(RouteTable.Routes);

  ServiceHost svcHost = new ServiceHost(typeof(DoSomethingService), new Uri("net.pipe://localhost/helloworld"));
  var serviceBinding = new NetNamedPipeBinding { MaxReceivedMessageSize = int.MaxValue, MaxConnections = 2048 };
  var sect = new NamedPipeTransportSecurity { ProtectionLevel = ProtectionLevel.EncryptAndSign };
  var sec = new NetNamedPipeSecurity { Mode = NetNamedPipeSecurityMode.Transport, Transport = sect };
  serviceBinding.Security = sec;

  svcHost.AddServiceEndpoint(typeof(IDoSomethingContract), serviceBinding, "");
  svcHost.Open();
}

我有一個控制台應用程序客戶端:

static void Main(string[] args)
{
  var factory = new ChannelFactory<IDoSomethingContract>();

  var defaultCredentials = factory.Endpoint.Behaviors.Find<ClientCredentials>();
  factory.Endpoint.Behaviors.Remove(defaultCredentials); 
  factory.Credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
  factory.Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
  var serviceBinding = new NetNamedPipeBinding { MaxReceivedMessageSize = int.MaxValue, MaxConnections = 2048 };
  var sect = new NamedPipeTransportSecurity { ProtectionLevel = ProtectionLevel.EncryptAndSign };
  var sec = new NetNamedPipeSecurity { Mode = NetNamedPipeSecurityMode.Transport, Transport = sect };
  serviceBinding.Security = sec;
  var ep = new EndpointAddress("net.pipe://localhost/helloworld");
  factory.Endpoint.Binding = serviceBinding;
  var love = factory.CreateChannel(ep); 
  Console.WriteLine(love.Do());

  Console.ReadKey();
}

現在,當我以用戶主體身份運行此程序時,一切工作都很好(因此我可以在操作中使用PrincipalPermission)。

但是,如果我創建一個“網絡服務”命令行提示符(使用psexec),並嘗試運行客戶端(顯然正在運行該服務),則會收到EndpointNotFoundException異常。

網絡服務需要做些什么才能看到我的命名管道?

我正在考慮刪除此內容,但由於有人發表了評論-我在這里找到了答案: http : //social.msdn.microsoft.com/Forums/vstudio/en-US/fcb7254a-15b5-4be4-bf67-34d500bdce2d/wcf- netpipe端點未找到,異常whitout提升的用戶權限,UAC啟用?論壇= WCF

基本上,由於我以自己的帳戶運行開發服務器,因此該服務已在會話名稱空間中發布。 一旦在實際的IIS上將其作為網絡服務發布,它就可以在全局命名空間中看到,因此可以看到它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM