Wcf: "System.ServiceModel.EndpointIdentity.CreateUpnIdentity" method for .net standard?

Created on 17 Dec 2019  路  5Comments  路  Source: dotnet/wcf

Hello, unfortunately the method "System.ServiceModel.EndpointIdentity.CreateUpnIdentity" does not exist for .net standard 2.0. I need this method for creating a EndpointAddress:

EndpointAddress myEndpoint = new EndpointAddress(new Uri(wcfEndpoint.Endpoint), EndpointIdentity.CreateUpnIdentity(wcfEndpoint.Identity));

What can I do to make this also work on .net standard?

Most helpful comment

Try this:
c# EndpointAddress myEndpoint = new EndpointAddress(new Uri(wcfEndpoint.Endpoint), new UpnEndpointIdentity(wcfEndpoint.Identity));

All 5 comments

Try this:
c# EndpointAddress myEndpoint = new EndpointAddress(new Uri(wcfEndpoint.Endpoint), new UpnEndpointIdentity(wcfEndpoint.Identity));

I also had the feeling that I could use this, but I was not sure.
So if I use this, will there be any side effects that I should know about?

No side effects. You can see the code of the CreateUpnIdentity static method here. I'll paste it here for convenience:
c# public static EndpointIdentity CreateUpnIdentity(string upnName) { return new UpnEndpointIdentity(upnName); }
So instead of calling a static method which just constructs an object for you and returns it, you can directly construct the object and you get identical results.

As an aside, part of some of the pain and difficulty people have with using WCF is there's about 20 ways to do the exact same thing. I'm trying to minimize that with the .NET Core implementation as much as is reasonable which sometimes means small but compatible code changes need to be done.

Let us know if you have any other questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hongdai picture hongdai  路  5Comments

DotNetPart picture DotNetPart  路  6Comments

cristicatalan picture cristicatalan  路  4Comments

kevinoid picture kevinoid  路  6Comments

scottmchargue picture scottmchargue  路  3Comments