3

引用 .NET 4.0 的 System.ServiceModel 和 System.ServiceModel.Web 库时,我无法实例化 WebHttpBinding 类。我可以在引用 3.5 库时实例化该类。文档说 4.0 支持 WebHttpBinding 那么我做错了什么?

new ChannelFactory<INotesService>
(new WebHttpBinding(),
new EndpointAddress("http://localhost:3380/Service.svc"))

当我点击 CTRL + . 在 WebHttpBinding 上,它没有找到它的命名空间。

http://msdn.microsoft.com/en-us/library/system.servicemodel.webhttpbinding.aspx

4

1 回答 1

4

是的,它肯定在 .NET 4 中,并且它的命名空间没有改变或类似的东西。

有趣的是,它从 System.ServiceModel.Web.dll 移到了 System.ServiceModel.dll,类型从 System.ServcieModel.Web.dll 永久转发。因此,您应该能够将任何 3.5 项目转换到 4.0 并让它正常工作。

所以,你的项目绝对应该有效。如果目标框架建议不起作用,您可以粘贴您收到的错误消息吗?

于 2011-04-19T06:00:47.503 回答