无法引用 System.ServiceModel.EndpointNotFoundException

发布于 2024-11-04 23:04:31 字数 660 浏览 1 评论 0原文

我试图捕捉这个异常:

System.ServiceModel.EndpointNotFoundException

但视觉工作室没有找到它。末尾没有红色破折号,如果我尝试在 System.ServiceModel 命名空间上使用 using,则 System.Web 中没有 ServiceModel。虽然来自 System.ServiceModel 命名空间 它位于.Net Framework 类库中。

有什么原因我无法参考它吗?

当我的应用程序无法访问我的网络服务时,我收到错误消息。

编辑: 目标框架是:3.5 未检查客户端框架。

编辑:我添加了 System.ServiceModel 命名空间,但显然(当时并不明显),我将其添加到类库而不是程序中。这就是整个麻烦所在。当建议我关闭并开始一个新项目,添加库时,它起作用了,所以我回去看了看。 VS 在重新打开时有所不同,很明显我已将 System.ServiceModel 添加到库而不是主项目中。

感谢您的帮助!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

好倦 2024-11-11 23:04:31

您是否尝试过将对 System.ServiceModel 的程序集引用添加到您的项目中?

编辑以防万一出现问题,以下是有关如何操作的说明:

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:

喜爱纠缠 2024-11-11 23:04:31

两个要求:

  • 添加对 System.ServiceModel.dll 的引用
  • 目标 .NET Framework 3.0 或更高版本

后者可能是您的问题。 C# IDE 中的项目 + 属性、应用程序选项卡、目标框架设置。

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.

愁杀 2024-11-11 23:04:31

(根据提问者的要求添加,以回应评论中的讨论。)

如果您肯定添加了参考文献,并且您肯定 em> 面向 .NET 3.0+,那么这个将会工作。

我刚刚在 VS 2008 中创建了一个针对 .NET 3.5(完整)的新项目,添加了对 System.ServiceModel 的引用,一切都按预期运行。

肯定还有其他问题。尝试看看是否可以在新的空白项目中做同样的事情。

(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.

浅语花开 2024-11-11 23:04:31

添加对 SYSTEM.SERVICEMODEL 的引用

我遇到了同样的问题,我有一个 VS2012 win 表单项目 .NET 3.5 客户端配置文件。
我想通过 VS2010 控制台项目 .NET 3.5 与 UPS API 集成
我将它拆开,抓取了一个 dll 和相关的 .cs 页面...它使用 System.ServiceModel 但我的 VS2012 项目不理解这一点...

添加对 SYSTEM.SERVICEMODEL 的引用为我解决了这个问题

  • 版本:3.0.0.0
  • 路径: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v3.5\Profile\Client\System.ServiceModel.dll

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文