Results 1 to 6 of 6

Thread: [02/03] pre-processor directive

  1. #1

    Thread Starter
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    [02/03] pre-processor directive

    Is there a concept of a pre-processor directive in .NET?

    any code samples
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [02/03] pre-processor directive

    It's called conditional compilation in VB.NET and it's done much the same way as it is in C:
    VB Code:
    1. #If DEBUG Then
    2.         MessageBox.Show("This is a Debug build.")
    3. #Else
    4.         MessageBox.Show("This is a Release build.")
    5. #End If
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: [02/03] pre-processor directive

    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.
    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
    I wish to change the http:// with variables. If I try changing the one inside the namespace, the vb file does not compile.

    Any ideas?

    Cheers,
    Abhijit
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [02/03] pre-processor directive

    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:
    1. Dim MyWebService as New WebServiceClassName
    2. MyWebService.URL = "http://www.developmentserver.com/service.asmx"
    3. 'or
    4. MyWebService.URL = "http://www.productionserver.com/service.asmx"

  5. #5

    Thread Starter
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: [02/03] pre-processor directive

    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
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [02/03] pre-processor directive

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width