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!
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:
- How To: Add or Remove References in Visual Studio
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.
(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.
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
精彩评论