Microsoft Knowledge Base Email Alertz

KBAlertz.com: When your Visual Basic .NET project contains conditional compilation symbols that use string literals, the Visual Basic .NET Command Line Compiler (vbc.exe) may not compile the source code that is defined between the conditional compilation...

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **


Community Site



We Send hundreds of thousands of emails using ASP.NET Email


ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 818217 - Last Review: November 22, 2007 - Revision: 2.6

Conditional compilation symbols that use string literals are not compiled by Vbc.exe

On This Page

SYMPTOMS

When your Visual Basic .NET or Visual Basic 2005 project contains conditional compilation symbols that use string literals, the Visual Basic .NET or Visual Basic 2005 Command Line Compiler (vbc.exe) may not compile the source code that is defined between the conditional compilation symbols. The generated executable may not run as expected.

CAUSE

When you use the /define switch for vbc.exe to provide string literals for conditional compilation, vbc.exe expects string values to be entered between """ and """ (three pairs of quotation marks). When you enter the string literals between double quotation marks, the conditional comparison fails, and the code is not generated as expected.

WORKAROUND

To work around this problem, type each string literal at the command line in two extra pairs of quotation marks. For example, type the string literal "Hello" as """Hello""".

Note If you use response files to specify command line parameters, prepend a backward slash mark (\) to the opening quotation mark and to the closing quotation mark for each string literal. For example, type the string literal "Hello" as \"Hello\".

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Open Notepad, and then copy the following code:
    Public Module Test
    
       Public Sub Main()
    
          #If BOOLVALUE Then
             System.Console.WriteLine ("BOOLVALUE is True")
          #End If
    
          #If STRINGVALUE = "Hello" Then
             System.Console.WriteLine ("STRING is Hello")
          #End If
    
       End Sub
    
    End Module
  2. Save the file as Test.vb.
  3. Open the Visual Studio .NET or in Visual Studio 2005 command prompt. Change the directory path to the directory that contains Test.vb.
  4. Type the following command at the command prompt, and then press the ENTER key:

    vbc /target:exe /d:STRINGVALUE="Hello",BOOLVALUE=True /verbose Test.vb


    Note The /d switch defines symbols. The symbols that you want should be listed, separated by commas.
  5. Run Test.exe.
  6. Notice the output.

    Only BOOLVALUE is True is displayed. STRING is Hello is not displayed.

REFERENCES

For more information, visit the following MSDN Web Sites:

Building From the Command Line
http://msdn2.microsoft.com/en-us/library/25fz1td5(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/25fz1td5(vs.71).aspx)

Conditional Compilation
http://msdn2.microsoft.com/en-us/library/9ae6e432(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/9ae6e432(vs.71).aspx)

2.4.4 String Literals
http://msdn2.microsoft.com/en-us/library/Aa711651(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/Aa711651(VS.71).aspx)


APPLIES TO
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
Keywords: 
kbvs2005swept kbvs2005applies kbstring kbcommandline kbcodegen kbcompiler kbconsole kbprb KB818217
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

hotel buchen tuerkei - http://hoteltuerkei.net Report As Irrelevant  
Written: 2/17/2010 1:12 AM
Component United,quarter stand liability event door succeed rest various other release profit base standard directly table afternoon tradition tea council advance increase round investigation servant score break test hard centre thing no-one annual section then bank image senior public task equal whether author organization national black rise fuel combination realise bird walk exercise reaction watch judge criminal possibly empty road act escape media more shut ring another imagine impression fit railway perhaps dinner conservative nation further share far factory administration careful additional judge matter necessary elderly property come criticism interested enable file

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please