开发者

accessing a webservice through class library in .net3.5 vs2008

I had a webservice which i was directly accessing from my webform. I used a service reference in my wesite and used a serviceclient on my webform which worked fine.

Now i removed the service reference from my website and created a class library hich consumes this webservice the same way usinfg a service reference and service client in the class.

when i try to use this class library now it gives me an error that no default endpoint found for the contract. Also i had changed the names开发者_如何学运维pace of my class library and also changed it in settings and assembly files. the dll still has the old name :( I've added a reference of this class library in my website.

where am i going wrong.


If you put a WCF service reference into a class library, then you will get an app.config with the binding information created in that class library. Unfortunately when you reference the library, that config information isn't loaded.

You need to copy the portion of the app.config in the class library to your main application's config area. That will make it available when the service is called.


The service reference still needs to be added to the webform project as well, because the client connects using the settings in the web.config of the project that is running, not the class library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜