This blog is usually a place for answers, but today I have a web service question that has stumped me and the experts I’ve consulted thus far. Here is my challenge:
When a client connects to a C# web service, how can it bind to a specific DLL in the web service “bin” folder?
The gritty details… I have a shared assembly (shared.dll) that is referenced both by a C# WinForms client (client.exe) and a C# Web Service (service.dll).
When I upload the service to the Web, naturally both service.dll and shared.dll are uploaded to the “bin” folder. Defined in service.dll is a class called “DataService” that provides the web service methods I need. To access this web service, client.exe uses code in shared.dll to construct and use a DataService object. Therefore, the following proxy class is generated in Reference.cs for shared.dll:
public partial class DataService :
The problem occurs when I attempt to execute a method on the DataService object from client.exe. It throws the following exception:
The type ‘MyNamespace.DataService’ is ambiguous:
it could come from assembly ‘binservice.dll’
or from assembly ‘binshared.dll’.
Please specify the assembly explicitly in the type name.
I understand the ambiguity. There is the proxy definition for DataService in shared.dll (that inherits from SoapHttpClientProtocol). Then there’s the full class definition of DataService in service.dll. The web service doesn’t know which to choose and throws an exception.
My question is, how can I resolve this ambiguity? How do I explicitly tell the web service to use the DataService definition in service.dll? The DataService.asmx file only has a Class attribute, but nowhere to specify a specific assembly.