Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebHttpBinding in .NET 4.0?

I'm unable to instantiate the WebHttpBinding class when referencing the System.ServiceModel and System.ServiceModel.Web libraries for .NET 4.0. I can instantiate the class when referencing the 3.5 libraries. The documentation says WebHttpBinding is supported in 4.0 so what am I doing wrong?

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

When I hit CTRL + . on WebHttpBinding it doesn't find the namespace for it.

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

like image 536
Craig G. Avatar asked May 24 '26 07:05

Craig G.


1 Answers

Yes, it is definitely in .NET 4, and its namespace was not changed or anything like that.

Interestingly, it was moved from System.ServiceModel.Web.dll to System.ServiceModel.dll, with the type getting type-forwarded from System.ServcieModel.Web.dll perpetually. So, you should be able to transition any 3.5 projects to 4.0 and have it just work.

So, your project should definitely work. If the target framework advice doesn't work, can you paste the error messages you get?

like image 71
krisragh MSFT Avatar answered May 26 '26 19:05

krisragh MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!