Variable inaccessible due to protection level

I am writing a VB.Net

Private Function generateXMLSchema()
    Dim generatedXmlSchema As String = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glob="http://sap.com/xi/SAPGlobal20/Global"><soapenv:Header/>" & _
        "<soapenv:Body>" & _
            "<glob:RouteBundleMaintainRequest_sync_V1>" & _
                "<Route actionCode="01">" & _
                    "<Name>tEST 250502</Name>" & _
                    "<RouteTypeCode>2</RouteTypeCode>" & _
                "</Route>" & _
            "</glob:RouteBundleMaintainRequest_sync_V1>" & _
        "</soapenv:Body>" & _
    "</soapenv:Envelope>"

    Return generatedXmlSchema
End Function

At Return generatedXmlSchema I am getting an error : generatedXmlSchema is not Declared. It may be inaccessible due to protection level

Can anybody tell me the issue?


Updated with Double Quote, Still the same error

Private Function generateXMLSchema()
    Dim genXmlSchema As String = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:glob=""http://sap.com/xi/SAPGlobal20/Global"><soapenv:Header/>" & _
        "<soapenv:Body>" & _
            "<glob:RouteBundleMaintainRequest_sync_V1>" & _
                "<Route actionCode="01">" & _
                    "<Name>tEST 250502</Name>" & _
                    "<RouteTypeCode>2</RouteTypeCode>" & _
                "</Route>" & _
            "</glob:RouteBundleMaintainRequest_sync_V1>" & _
        "</soapenv:Body>" & _
    "</soapenv:Envelope>"

    Return genXmlSchema
End Function

you must double quote every occurrence of a quote as a string delimiter:

"http://schemas.xmlsoap.org/soap/envelope/" -> ""http://schemas.xmlsoap.org/soap/envelope/""

"http://sap.com/xi/SAPGlobal20/Global" -> ""http://sap.com/xi/SAPGlobal20/Global""

"01" -> ""01""

that said, this function is Private so it must be called within the same Class it belongs to

all that above pour the following:

Public Class Class1

    Sub main()
        Console.WriteLine(generateXMLSchema())
    End Sub

    Private Function generateXMLSchema()
        Dim generatedXmlSchema As String = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:glob=""http://sap.com/xi/SAPGlobal20/Global""><soapenv:Header/>" &
            "<soapenv:Body>" &
                "<glob:RouteBundleMaintainRequest_sync_V1>" &
                    "<Route actionCode=""01"">" &
                        "<Name>tEST 250502</Name>" &
                        "<RouteTypeCode>2</RouteTypeCode>" &
                    "</Route>" &
                "</glob:RouteBundleMaintainRequest_sync_V1>" &
            "</soapenv:Body>" &
        "</soapenv:Envelope>"

        Return generatedXmlSchema
    End Function

End Class
链接地址: http://www.djcxy.com/p/65220.html

上一篇: 如何以编程方式获取当前的跟踪开关?

下一篇: 由于保护级别而变得不可访问