Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 作为NetworkService运行时WCF EndpointNotFoundException_C#_Wcf_Net.pipe - Fatal编程技术网

C# 作为NetworkService运行时WCF EndpointNotFoundException

C# 作为NetworkService运行时WCF EndpointNotFoundException,c#,wcf,net.pipe,C#,Wcf,Net.pipe,我有一个由IIS托管的net.Pipe WCF服务(现在,在我的VS2010中): (Global.asax): 我有一个控制台应用程序客户端: static void Main(string[] args) { var factory = new ChannelFactory<IDoSomethingContract>(); var defaultCredentials = factory.Endpoint.Behaviors.Find<ClientCredenti

我有一个由IIS托管的net.Pipe WCF服务(现在,在我的VS2010中): (Global.asax):

我有一个控制台应用程序客户端:

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();
}
static void Main(字符串[]args)
{
var factory=新的ChannelFactory();
var defaultCredentials=factory.Endpoint.Behaviors.Find();
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=新的端点地址(“net。pipe://localhost/helloworld");
factory.Endpoint.Binding=serviceBinding;
var love=factory.CreateChannel(ep);
Console.WriteLine(love.Do());
Console.ReadKey();
}
现在,当我以用户主体的身份运行它时,一切都很好(因此我可以在操作中使用PrincipalPermission)

但是,如果我自己创建一个“网络服务”命令行提示符(使用psexec),并尝试运行客户端(显然是在服务运行的情况下),我会得到EndpointNotFoundException异常


要让网络服务看到我的命名管道,我需要做些什么吗?

以下文章可能对您有用


我曾考虑删除此内容,但由于有人发表了评论,我在这里找到了答案:

基本上,因为我是以自己的帐户运行我的dev服务器,所以服务是在会话名称空间中发布的。一旦我将它作为网络服务发布在真实的IIS上,它就可以在全局名称空间中看到,所以我可以看到它

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();
}