Chuck Savage
Chuck Savage

Reputation: 11955

Can't reference System.ServiceModel.EndpointNotFoundException

I'm trying to catch this exception:

System.ServiceModel.EndpointNotFoundException

But visual studio isn't finding it. There's no little red dash at the end, and if I try doing a using on the System.ServiceModel namespace, there is no ServiceModel in System. Though from System.ServiceModel Namespace it is in the .Net Framework class library.

Is there a reason I cannot reference it?

I get the error when my application cannot access my web-service.

Edit: Target framework is: 3.5 Client framework is not checked.

Edit: I'd added the System.ServiceModel namespace, but apparently (it wasn't obvious at the time), I'd added it to a class library instead of the program. That was the whole bother. When suggested that I close and start a new project, add the library, it worked, so I went back and looked. VS was different on re-open and it was obvious I'd added System.ServiceModel to the library and not the main project.

Thanks for the help!

Upvotes: 1

Views: 11942

Answers (4)

actinade
actinade

Reputation: 55

Add Reference to SYSTEM.SERVICEMODEL

I had this same problem, I had a VS2012 win forms project .NET 3.5 client profile. I wanted to integrate with UPS API via VS2010 Console project .NET 3.5 I hacked it apart, grabbed a dll and the pertianent .cs page... it was using System.ServiceModel but my VS2012 project did not understand this...

Adding a reference to SYSTEM.SERVICEMODEL solved this for me

  • version:3.0.0.0
  • path: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v3.5\Profile\Client\System.ServiceModel.dll

Upvotes: 0

Cody Gray
Cody Gray

Reputation: 244951

(Added at the request of the asker, in response to discussions in comments.)

If you've definitely added the reference, and you're definitely targeting .NET 3.0+, then this will work.

I just created a new project targeting .NET 3.5 (full) in VS 2008, added the reference to System.ServiceModel, and everything works exactly as expected.

Something else must be wrong. Try seeing if you can do the same thing in a new, blank project.

Upvotes: 2

Hans Passant
Hans Passant

Reputation: 942119

Two requirements:

  • Add a reference to System.ServiceModel.dll
  • Target .NET framework 3.0 or higher

The latter is probably your issue. Project + Properties, Application tab, Target framework setting in the C# IDE.

Upvotes: 3

Jeff Swensen
Jeff Swensen

Reputation: 3573

Have you tried adding the assembly reference to System.ServiceModel to your project?

Edit Just in case this is the issue, here's instructions on how to do so:

Upvotes: 4

Related Questions