Why do both types use the same XML type name

written by Rob Aquila on Tuesday, October 14 2008

When trying to hit an asp.net page that consumes a Web Service I ran into this error. System.InvalidOperationException: Types 'Client.WebReference1.ClassA' and 'Common.ClassA' both use the XML type name, 'ClassA', from namespace 'http://localhost/WebServices'. Use XML attributes to specify a unique XML name and/or namespace for the type.  I was puzzled by this error and didn't understand what was going on at first.  After some investigation I figured out the issue.

Basically what is happening is that I have a single class called ClassA that is passed around in method calls to a asmx web service that I am referencing in a piece of client code.  Also in that piece of client code I am referencing the dll that contains the Common.ClassA implementation.  The web service must also reference this dll.  When I added the asmx web service reference to my client project, Visual Studio created the asmx proxies for me.  In doing so it created a new object called ClassA under the namespace of the web service reference name.  So in this example case, Client.WebReference1.ClassA.  In order to fix this you must go into the web service reference file that was generated by Visual Studio and remove the new class definitions.  I have also seen this happen to enum types.  You might also have to add 'using Common.ClassA' on the top of this file, depending on your situation.

Similar Posts

  1. Configure App.config Application Settings During MSI Install
  2. MS Deploy Basics
  3. Corrupt Cab Files In My Virtual PC Environment

Comments are closed