繁体   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