I am programming a ArcGIS Pro 3.1 AddIn with C#.
The following line
var pipeFactory = new ChannelFactory<IWCFStarter>(new NetNamedPipeBinding(),
new EndpointAddress("net.pipe://localhost/SomeAdress"));
throws this exception:
Exceptioninfo:
Type: System.TypeLoadException
ExceptionMessage:
Could not load type 'System.ServiceModel.ExceptionHelper' from assembly 'System.ServiceModel.Primitives, Version=4.9.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Source: System.ServiceModel.NetNamedPipe
Stack:
at System.ServiceModel.NetNamedPipeBinding..ctor()
at ARCBAR.InfoWindow.updateAddin_Click(Object sender, RoutedEventArgs e) in C:\ARCBAR\ARCBAR\InfoWindow.xaml.cs:line 35
But the project has the NuGetPagages added:
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.ServiceModel.NetNamedPipe" Version="6.0.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
</ItemGroup>
In another project the same thing works perfectly fine. And I cant find any meaningful differences in the dependencies and nuGet-Packages.
Updates:
With the help of Oliver, Zdeněk Jelínek and Panagiotis Kanavos I found a solution (unfortunately a bad one):
I started ArcGIS Pro 3.1 without loading my addIn and used "Debug/Attach to process" + "debug/Windows/modules" to see which assamblies are loaded by ArcGIS itself without my AddIn.
So I found out that ArcGIS itself loads "System.ServiceModel.Primitives.dll" in version 4.900.21.52002 from "C:\Program Files\ArcGIS\Pro\bin\System.ServiceModel.Primitives.dll"
I need System.ServiceModel.NetNamedPipe and this needs System.ServiceModel.Primitives in Version 6.0.0.
So I replaced "C:\Program Files\ArcGIS\Pro\bin\System.ServiceModel.Primitives.dll" with the 6.0.0 Version from my bin/release-folder.
This seems to work at first glance.
But for obvious reasons this is not a very good solution. I prefere not to change any installed files from ArcGIS-Pro.