Thursday, January 13, 2011

ASP.Net Web Service Reference error

I've encountered interesting error when dealing with web-services in Web Site (ASP.Net 4.0).
Scenario:
MyWeb - ASP.Net 4.0 web site project
MyService - ASP.Net WCF service
MyCode.dll - library share user by both, MyWeb and MyService.

Now, the issue is when you change MyCode, recompile MyService and do "Update Service Reference" in the MyWeb. What I found, that I start getting compilation errors saying that the client class from the MyService reference is not known (as if the reference was missing).

Cause: The MyWeb project was referencing the MyCode library not as a project, but rather as DLL reference.

Solution: Quite obvious - either use project reference or update the DLL used by the web-site.

This behavior is to be expected, however if you don't realize that you're not using same DLL version from both MyService and MyWeb, it can be quite confusing.

No comments: