SAP web service reference in .NET naming conflict issue
-
14-02-2021 - |
Question
i have a .net issue when im trying to consume SAP ws , the element system cusing this error
error CS0120: An object reference is required for the nonstatic field, method, or property 'Bapiret2.System'
their is a solution as described here BUT im want to find a solution that doesn't required to change the WSDL
or this one , http://ddkonline.blogspot.com/2009/09/sap-to-microsoft-net-integration-fixes.html
do you have any experience with that and how you solve it?
thanks miki
OTHER TIPS
Since this issue is caused by naming conflict in .NET and SAP, another workaround for this issue without changing SAP configuration:
Add an alias for System.XML as below in Reference.cs
using SysXml = System.Xml;
Then, replace all the System.Xml where report the error with "SysXml" as below (please note that the word "SysXml" is originally "System.Xml" after adding the service, which caused this issue)
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=SysXml.Schema.XmlSchemaForm.Unqualified)]
public string Type {
get {
return this.typeField;
set {
this.typeField = value;
}
}