I'm trying to get a WCF client for the following URL (https://api.mbeonline.es/ws/e-link.wsdl) which successfully generates a service reference correctly.
That said when I get to compile the project I a bunch of errors, all being the same though within the auto-generated code file:
Error CS0120 An object reference is required for the non-static field, method, or property 'XXXX.System'
Which is weird. Previously I added the package System.ServiceModel.Primitives
which I read is necessary in order to get the dependency System.ServiceModel
sorted but still I'm not able to get the solution to compile and therefore I cannot use the service reference. Any ideas of what am I missing?
UPDATE
Actually I found what the problem was. Inside some of the generated classes there was a conflict because there was an element called System which was causing the error / conflict with the actual full namespace provided in some of the attributes System.Xml.... all I did was replacing the full namespace and put an using statement with the namespace at the top of the file. All errors gone!
I did contact Visual Studio Support for that issue and that suggesstet the following solution:
The compilation error is due to that the generated code class contains property named "System", it conflicts with the global "System" namespace. You can try to add "global::" keyword to point to the correct referenced .NET type to avoid this confliction. For example, replace:
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
with:
[System.Xml.Serialization.XmlElementAttribute(Form=global::System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]