Reputation: 786
I want to achieve IPC between unmanaged VC++ COM Excel addin and managed C# console application. Currently I achieve IPC between maanged C# applications using NetNamedPipeBinding. I now want to achieve IPC between unmanaged and managed applications using NetNamedPipeBinding.
I tried using WWSAPIs and followed the sample at CodeProject to achieve the same. As mentioned at MSDN reference link1, link2 and link3 NetNamedPipeBinding is available for WWSAPIs and shipped with Windows 8 SDK.
Following is the code sample of my C# Console application
Uri baseAddress = new Uri("net.pipe://localhost/Server");
serverHost = new ServiceHost(this, baseAddress);
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
binding.Security.Mode = NetNamedPipeSecurityMode.None;
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy12;
serverHost.Description.Behaviors.Add(smb);
serverHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexNamedPipeBinding(), "mex");
serverHost.AddServiceEndpoint((typeof(IAdd)), binding, baseAddress);
serverHost.Open();
IAdd is the interface which is defined as follows
[ServiceContract]
public interface IAdd
{
[OperationContract]
void PerformAddition(int val1, int val2);
}
Then I start the service and execute the following command to generate wsdl and xsd files.
svcutil /t:metadata net.pipe://localhost/Server
After this I use WsUtil to create the required header files. However, when I try to create header files I get the following warning :
warning WSUTIL0089 No supported policy setting has been found in the input metadata. The service may be using a binding configuration not supported by WWSAPI, such as message security setting. See documentation for the list of configurations supported by WWSAPI.
Now If I change the binding type in my C# console application to WSHttpBinding or NetTcpBinding then I am successfully able to create the header files using WsUtil.
I cannot use WsHttpBinding as it required administrative previliges to start the service and typically my managed application will run with non administrative previliges. I also read on MSDN that Net Named Pipe Binding is optimized for IPC on same machine which is ideally my case.
If required I can share the sample code for my unamanged C++ and managed C#.
Any Help regarding acheiving NetNamedPipeBinding between unmanaged C++ and managed C# would be appreciated
P.S: I cannot port my unmanaged VC++ COM addin to managed VSTO application
Upvotes: 4
Views: 1185