views:

552

answers:

1

I have a VS2010 (RTM) solution which contains:

WCF Service project
Console WCF client project
Class project for DataContracts and members
Class project for some simple classes

I successfully added a service reference in the console client project and ran the client. I then did a long dev cycle repeatedly modifying the service then updating console service reference. I then changed the namespace and assembly names for the projects as well as the .cs using references and app.config. I of course missed some things as it would not build so I eventually removed the project references and the service reference, cleaned and built successfully.

I then attempted to add the service reference again, it discovered it but threw the “Object reference not set to an instance of an object” when OK'ing. Fix in answer below...

+2  A: 

Posting my own fix as I couldn't find it elsewhere:

Stackoverflow'ing/Googling didn't get me anywhere so I eventually opened the solution file in notepad and found that the entry referencing my console project had a project dependency on the WCF Service project.

After I removed that ProjectSection, I was able to add the service reference and was back in business.

In trying to reproduce the problem, adding the service reference to the project adds the service project dependency but removing the service reference does not. I presume changing the namespace was the culprit with it not finding the dependency reference?

Anyway, HTH. 2 hours wasted...

Andy
I had the same issue as this as well; however, my project file didn't contain the reference. What I ended up doing to resolve my issue was to ensure my console app was using .net 4 instead of v3.5. Figured I'd add such here as well in case someone else stumbles across this.
JamesEggers