Is there a concept of a pre-processor directive in .NET?
any code samples :wave:
Printable View
Is there a concept of a pre-processor directive in .NET?
any code samples :wave:
It's called conditional compilation in VB.NET and it's done much the same way as it is in C:DEBUG is defined by default in a Debug build and TRACE is defined by default in both Debug and Release builds. You can define additional constants for a specific configuration in the Property Pages for the project under Configuration Properties -> Build.VB Code:
#If DEBUG Then MessageBox.Show("This is a Debug build.") #Else MessageBox.Show("This is a Release build.") #End If
Hi Jim,
Here is my specific problem. I have a got a wsdl (a) for a webservice running on server1 and another wsdl (b) for a webservice running on server2.
I used the wsdl utility to convert both into vb files. Both webservices have the same input / output parameters.
I wish to change the http:// with variables. If I try changing the one inside the namespace, the vb file does not compile.Code:<System.Web.Services.Protocols.SoapDocumentMethodAttribute("document/http://devlserver:CreateQLOpty", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Bare)> _
Public Function CreateQLOpty(<System.Xml.Serialization.XmlElementAttribute([Namespace]:="http://devlserver")> ByVal QL_spcTO_spcEMCOT_CreateQLOpty_Input As QL_spcTO_spcEMCOT_CreateQLOpty_Input) As <System.Xml.Serialization.XmlElementAttribute("QL_spcTO_spcEMCOT_CreateQLOpty_Output", [Namespace]:="http://devlserver")> QL_spcTO_spcEMCOT_CreateQLOpty_Output
Dim results() As Object = Me.Invoke("CreateQLOpty", New Object() {QL_spcTO_spcEMCOT_CreateQLOpty_Input})
Return CType(results(0),QL_spcTO_spcEMCOT_CreateQLOpty_Output)
End Function
Any ideas?
Cheers,
Abhijit
yes, when you declare your webservice object in the code where you are using it, the object will have a .url property, you can change this at runtime to whichever server you need.
VB Code:
Dim MyWebService as New WebServiceClassName MyWebService.URL = "http://www.developmentserver.com/service.asmx" 'or MyWebService.URL = "http://www.productionserver.com/service.asmx"
I did try doing that Matt, but now the trouble seems to be namespaces. The compilation did take place, but it still makes a call to http://devlserver instead of http://sptserver
I always set my namespaces to the production server even when in dev, and use the code I showed you to point myself between servers..
I am not an expert on webservices, I have just started using them, but I can tell you that I have gotten it working dev to production to dev using that code, and using the namespaces how I mentioned