cancel
Showing results for 
Search instead for 
Did you mean: 

Reference to a non-shared member requires an object reference

Former Member
0 Kudos

Hi Experts,

Currently, I have tried to link my VB project with WSDL for a BAPI in SAP.

After adding web reference, I tried to rebuild project and got following error.

"Reference to a non-shared member requires an object reference"

I have tried to add "SYSTEM" in the statement which has error but it does not help.

(Referring to

Please advise what I can try further to resolve this problem.

Thank you !

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Erika,

Try removing the keyword SYSTEM from the lines. And also if possible can you post here the line of code generating the error.

Regards.

Former Member
0 Kudos

    <System.Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:sap-com:document:sap:rfc:functions")>  _
    Public Class BAPIRET2
        
        '<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public TYPE As String
        
        '<remarks/>
        

I've tried to modify like following

  '<remarks/>
    <System.Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:sap-com:document:sap:rfc:functions")>  _
    Public Class BAPIRET2
        
        '<remarks/>
        <SYSTEM.Xml.Serialization.XmlElementAttribute("SYSTEM", Form:=SYSTEM.Xml.Schema.XmlSchemaForm.Unqualified)> _
        Public TYPE As String   
        

Former Member
0 Kudos

Hi Erika,

Remove the "SYSTEM" keyword as shown below-

<b>Old Code</b>:

'<remarks/>

<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:sap-com:document:sap:rfc:functions")> _

Public Class BAPIRET2

'<remarks/>

<SYSTEM.Xml.Serialization.XmlElementAttribute("SYSTEM", Form:=SYSTEM.Xml.Schema.XmlSchemaForm.Unqualified)> _

Public TYPE As String

<b>Modified :</b>

'<remarks/>

<Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:sap-com:document:sap:rfc:functions")> _

Public Class BAPIRET2

'<remarks/>

<Xml.Serialization.XmlElementAttribute("SYSTEM", Form:=SYSTEM.Xml.Schema.XmlSchemaForm.Unqualified)> _

Public TYPE As String

Regards.

Former Member
0 Kudos

Hi Jitesh,

Thank you very much for your prompt response.

Anyway, I would like to have your advice why the error appears only in the

BAPIRET2 section.

I have also tried as your recommendation but it seems that Xml.Serialization.XmlTypeAttribute is not defined.

Former Member
0 Kudos

Hi Erika,

>>Anyway, I would like to have your advice why the error appears only in the

>>BAPIRET2 section.

Because if you see in the BAPIRET2 Class there is a property defined with the same name:

<b>Public SYSTEM As String</b>

And thats causes the confusion to the compiler. If you just want to check- try renaming -

<b>Public SYSTEM As String</b> to something else

may be <b>Public SYSTEM_TEST As String</b>

And the error should be gone.

Now coming back to resolution- Just check whether the reference.vb file has got a header statement like :

Option Strict Off

Option Explicit On

<b>Imports System</b>

Imports System.ComponentModel

Imports System.Diagnostics

Imports System.Web.Services

Imports System.Web.Services.Protocols

Imports System.Xml.Serialization

And if the above namespaces are already impoted in your reference.vb file then you can safely remove "SYSTEM" keyword as suggested earlier.

Regards.