Configure Service Reference… - Object reference is

2019-05-21 08:57发布

问题:

I am working with Visual Studio 2013, .NET4.5.

Originally I was WCF service consumer but due to lack of resources in team that deals with subsystem I took over development of both sides of WCF service. So I got Code of the WCF service that I need to call and now trying to plug it in to debug it on my local system.

Issue: Service that I need to call works on localhost fine I can get wsdl and browse to it.

However when I try in Visual Studio 2013 'Configure Service Reference...' and Try to change url from dev server to local it gives me Object reference is not set to an instance of an object error.

Has anyone experienced something similar? What is causing this? How do I fix it?

回答1:

Solved myself by deleting Service Reference, and then adding new Service Reference with given URL.



回答2:

I know this is a bit late but I had a similar problem and I fixed it by adding an identity element to the app.config file for the service's endpoint. Example:

<identity>
  <userPrincipalName value="username@domain" />
</identity>

The for me it worked even with an empty value for userPrincipalName:

<identity>
  <userPrincipalName value="" />
</identity>

Full endpoint element:

<endpoint address="net.tcp://localhost:9876/my-service/tcp" ... >
  <identity>
    <userPrincipalName value="" />
  </identity>
</endpoint>