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
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.
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.
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\".
This
behavior is by design.
Steps to Reproduce the Behavior
- 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 - Save the file as Test.vb.
- Open the Visual Studio .NET or in Visual Studio 2005 command prompt. Change the
directory path to the directory that contains Test.vb.
- 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. - Run Test.exe.
- Notice the output.
Only BOOLVALUE is
True is displayed. STRING is Hello is not
displayed.
For more information, visit the following MSDN Web
Sites:
APPLIES TO
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET 2003 Standard Edition
- Microsoft Visual Basic .NET 2002 Standard Edition
| 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
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please