4

I'm trying to add an external service reference in a C# .Net 4.0 project where the service wsdl contains a type called "System", which results in something like this:

Namespace issue

As you can see, everywhere in Reference.cs where the "System" namespace is referenced, it instead believes it to be this System class instead, resulting in errors all over the place.

What would be the best way of resolving this naming issue?

John
  • 17,163
  • 16
  • 65
  • 83
  • I believe the actual class name doesn't really matter and you could manually rename it to anything like `System2` or whatever else. – Wiktor Zychla Aug 07 '14 at 19:31
  • I figured it knew how to parse the xml based upon the class names; is that set somewhere else? – John Aug 07 '14 at 19:33
  • You could name your namespaces i.e. `using compModel = System.ComponentModel` and then `public partial class System : object, compModel.INotifyPropertyChanged {`.... – entropic Aug 07 '14 at 19:35

1 Answers1

3

You can rename the generated System class (and all references to it) in the Reference.cs file, then add a [XmlRoot(ElementName = "System")] attribute to it so it will be (de)serialized properly.

You'll of course lose these changes when you regenerate the proxy.

Community
  • 1
  • 1
CodeCaster
  • 147,647
  • 23
  • 218
  • 272