468,491 Members | 2,078 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,491 developers. It's quick & easy.

conditional compile and #IF CONFIG

I'm using conditonal compile with statement #IF CONFIG
This works if I use #IF CONFIG = "Debug" or #IF CONFIG= "Release"

But if I define an other compilation profile, eg. "BestRelease", and I use
#IF CONFIG = "BestRelease", compiler doesn't recognize the true condition
and doesn't compile statements inside #IF... #END IF block.

Is this a bug?
Any other way to have conditional compile in a project, using only a single
variable (I need to test compilation profile in different asp net codebehind
pages, but I want to write only one #CONST profile=...)

thanks
Nov 20 '05 #1
5 7459
Hi Trapulo,

Thanks for posting in the community.

From your description, I understand that when you use #IF CONFIG =
"BestRelease", the compiler doesn't recognize the true condition and
doesn't compile statements inside #IF... #END IF block.
Please correct me if there is any misunderstand.
Is this a bug?

I think it is not a bug, "Config" is a string datatype, which corresponds
to the current setting in the Configuration Manager.

To use the #IF CONFIG = "BestRelease" conditional compilation, I suggest
you to add a new solution configuration "BestRelease" in the Project
Properties.../Configuration Manager/Active Solution Configuration

Please apply my suggestion above and let me know if it helps resolve your
problem.
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 20 '05 #2

"Gary Chang" <v-******@online.microsoft.com> wrote in message
news:Pt*************@cpmsftngxa07.phx.gbl...
From your description, I understand that when you use #IF CONFIG =
"BestRelease", the compiler doesn't recognize the true condition and
doesn't compile statements inside #IF... #END IF block.
Please correct me if there is any misunderstand.


That's right
Either VS desinger doesn't recognize it, not only compiler. Inside the block
I declare some constants, and if I set in release configuration mode I
havent errors, but if I set project in "BestRelease" mode the desinger
reports error where I read this constants.
Is this a bug?

I think it is not a bug, "Config" is a string datatype, which corresponds
to the current setting in the Configuration Manager.

To use the #IF CONFIG = "BestRelease" conditional compilation, I suggest
you to add a new solution configuration "BestRelease" in the Project
Properties.../Configuration Manager/Active Solution Configuration

Please apply my suggestion above and let me know if it helps resolve your
problem.


This is what I made before write the post. But this doesn't work!
I have this code:
#If CONFIG = "Release" Or CONFIG = "Debug" Then

Public Const rootFolderName As String = "one"

Public Const activeBrand As brand = brand.one

#ElseIf CONFIG = "Release_two" Then

Public Const rootFolderName As String = "two"

Public Const activeBrand As brand = brand.two

#End If

If I select Release o Debug configuration profile, all ok.

If I select Release_two, all acceses to two constants reports an error.

However I solved. I noticed that using a third configuration profile I've on
my project, this code works. So I deleted Release_two configuration profile,
and I've created a new Release_two profile copying data from the working
one. Now The code above is working. Any idea of the mistake I made?

I've an other problem. If now I open active solution configuraration, I find
all old profile I don't use. I've tried to delete them (with <Edit...> ->
delete), but if I close and reopen property page, the come back. Any
suggestion?

however.. thanks


Nov 20 '05 #3

"Gary Chang" <v-******@online.microsoft.com> wrote in message
news:jn**************@cpmsftngxa07.phx.gbl...
I've an other problem. If now I open active solution configuration, I findall old profile I don't use. I've tried to delete them (with <Edit...> ->
delete), but if I close and reopen property page, the come back. Any
suggestion?


Yes, I can repro the same problem, it seem a issue, I will consult this
problem to the product team member, and reply if got any response!


Thanks, I'll wait for your solution!

Nov 20 '05 #4
According to the product group this is by design.
We deliberately do not remove project configurations when a solution
configuration is removed. This is to prevent the unintentional deletion of
project configurations.

Thanks,
Susan Huffaker
Microsoft Developer Support

Nov 20 '05 #5
There is one more thing I should say. There is a difference between a
Solution Configuration and a Project Configuration.

If you delete the Solution Configuration, the Project Configuration will
remain in place. They're separate configurations.

To delete the Project Configuration:

Open the Configuration Manager.
Click on the drop-down list under the "Configuration" column- NOT the
"Active Solution Configuration" combo box.
Select <Edit...> and remove the Project configuration.

Hope this helps!
Susan Huffaker
Microsoft Developer Support
Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by chris han | last post: by
2 posts views Thread by FireStarter | last post: by
6 posts views Thread by Marc Jennings | last post: by
3 posts views Thread by John | last post: by
10 posts views Thread by Dave | last post: by
4 posts views Thread by =?Utf-8?B?Sm9obiBCZXNjaGxlcg==?= | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.