C# 在WPF应用程序中托管NamedPipe不会创建管道
我在.NET3.5上,我有两个WPF项目,它们应该以两种方式相互通信。我认为命名管道可以通过WCF完成这项工作,从而使双工模式变得非常简单。 但是,我在一个应用程序中启动了一个名为“管道主机”的WCF,但在另一个应用程序中看不到它。也C# 在WPF应用程序中托管NamedPipe不会创建管道,c#,wpf,wcf,named-pipes,wcf-hosting,C#,Wpf,Wcf,Named Pipes,Wcf Hosting,我在.NET3.5上,我有两个WPF项目,它们应该以两种方式相互通信。我认为命名管道可以通过WCF完成这项工作,从而使双工模式变得非常简单。 但是,我在一个应用程序中启动了一个名为“管道主机”的WCF,但在另一个应用程序中看不到它。也 pipelist.exe | findstr "MainApplication" 其中MainApplication是管道名称,不返回任何内容(pipelist.exe是SysInternals中的实用程序) 我有以下app.config: <?xml v
pipelist.exe | findstr "MainApplication"
其中MainApplication是管道名称,不返回任何内容(pipelist.exe是SysInternals中的实用程序)
我有以下app.config:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="MainApplication" behaviorConfiguration="Default">
<endpoint address="" binding="netNamedPipeBinding" name="MainApplication" contract="IMainApplication" />
<endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/MainApplication" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>
我错过了什么?
我没有得到任何异常,但是当我尝试向第二个项目添加服务引用时,我找不到管道,也不能用pipelist.exe列出它
我错过了一些基本的东西吗?我将ServiceCommunications方法更改为
private void ServiceCommunications()
{
var host = new ServiceHost(typeof(MainApplication));
host.Open();
while (keepAlive)
{
// Do nothing
}
host.Close();
}
它解决了这个问题。是windows服务吗?好的。应用程序本身工作正常吗(除了缺少管道)?是的。这可能是因为我最初是以管理员的身份运行应用程序来帮助创建管道的。然而,即使我现在可以添加服务引用,我仍然无法使用pipelist.exe | findstr“main应用程序”找到我的服务
private void ServiceCommunications()
{
var host = new ServiceHost(typeof(MainApplication));
host.Open();
while (keepAlive)
{
// Do nothing
}
host.Close();
}