conditional compile and #IF CONFIG

T

Trapulo

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
 
G

Gary Chang

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.
--------------------
 
T

Trapulo

Gary Chang said:
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.
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
 
G

Gary Chang

Hi Trapulo,

Thanks for your quickly reply!
This is what I made before write the post. But this doesn't work!
I have tested your sample code with a new solution configuration
"BestRelease"(with default setting) and set it as active solution
configuration, your code builds as expected under VS.NET 2002 and VS.NET
2003.

So if your VS.NET has such problem, I suggest to review the
YourprojectName.sln, YourprojectName.vbproj file, to check is there a valid
solution configuration applied to your project.

I've an other problem. If now I open active solution configuration, 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?

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!

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.
--------------------
 
T

Trapulo

Gary Chang said:
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!
 
S

Susan Huffaker

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
 
S

Susan Huffaker

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top