From what I can tell and what I have read, a #Const only relates to the Class in which it was declared. Is there any way to do something like this globally? Any ideas on possible ways to extend it globally?
Thanks in advance!!
Printable View
From what I can tell and what I have read, a #Const only relates to the Class in which it was declared. Is there any way to do something like this globally? Any ideas on possible ways to extend it globally?
Thanks in advance!!
you can declare them globally to an assembly in the settings...
in the settings, under the compile tab, click the advanced compile options...
whatever you define here will be global to the assembly..
http://www.vbforums.com/attachment.p...id=52769&stc=1
http://www.vbforums.com/attachment.p...id=52770&stc=1
Aha. I had just checked my 2003 Enterprise Architect version and it was available there. It appears that this is something else that they left out of the Express version. I guess it is time to buy a full version of Visual Studio 2005.
Any chance you can see those values declared in your AssemblyInfo file or somewhere like that? At least I could try to force my values into the source file behind that screen.
they are stored in the vbproj file, so I would THINK you should be able to edit your vbproj file manually to include any conditional compile constant you want.
it is under a node for <PropertyGroup> here is the node from the vbproj file where I made my screen shots for you
VB Code:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <DefineDebug>true</DefineDebug> <DefineTrace>true</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <DocumentationFile>RougeApp.xml</DocumentationFile> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> <DefineConstants>Monkey=True</DefineConstants> </PropertyGroup>
I would think the only line you need to concern yourself with is the <DefineConstants> one...
He is what I have found... There are 2 configuration sections in my 2005 Express vbproj file (this was an upgraded project from 2003, so that may explain the 2nd configuration section). However, 2005 only operates off of the <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> section. If I put values in there, they DO show up with intelisense when I type #If.
This doesn't make changing these values very easy, but at least I can limp along for right now.
does 2005 express have the option to change between debug and release modes?
I wonder if I can install 2005 Express along side VS 2005 Team Suite.
It would probably help me when answering questions when people are using it.
No. A friend just sent me a screenshot of the Compile tab from his version and Express doesn't have any of the Configuration Modes available. (I would send a screenshot, but don't any site space easily available to put it on.)
You probably cannot run both, but you could run Virtual PC and install it there.
PS - You have to stop answering all of my questions. The system will not allow me to make any more adjustments to your reputation until I give reputation to other people.
It's ok.. I was on this forum long before reputation points where turned on ;)
Hey, you know you can post screen shots right on here don't you?
All you need to do is take your screen shot, paste it in mspaint (save it as a jpg because bmp will be big, unless you need all the color that bmp has over jpg)
then just attach it. If you are doing a quick reply, click "Go Advanced" to get the option to add an attachment.
If you only upload a single image file, then it will automatically be displayed in your forum post. If you do more than one (like I did above) then you have to first post it, then you can edit your post and wrap the links to your attachments in [img] tags...
Oh well. I looked all over the message section and only saw the ability to link it. If I had scrolled down further, I would have seen that.
again, speaking from my use with the full version.. but try this.
in the IDE go to tool -> options
once in the options screen, make sure you check the checkbox at the bottom left that says "Show all settings" (if you have it of course)
Then if you have a Projects and Solutions node in the treeview on the left, see if you have an option to check "Show Advanced Build configurations"
That is what I had to do to be able to explicitly move between debug/release versions (like 2003)
Checking those boxes gave me the ability to change the Configuration between debug and release, but still no advanced options.
does it fix your issue of only being able to use debug mode and still use the constant you manually added to the vbproj file?
I can use Debug and Release, now. But I was only using Release apparently, which did everything fine for me. And, it will let me use the Constants in there. I just have to edit the vbproj file manually. It's isn't great, but it works.
Any chance that there is a way to conditionally set the Assembly Name and Application Icon?
This application will be put into two different office locations. The home office will need to be able to run both applications, so it would be nice to name them a little differently and to have a different icon.
I haven't found such a mechanism, so I may just write another app that makes the changes to the VBPROJ file.
The Express version does give me the ability to set different "Configurations". I created 2 new configurations, one specific to each office and then editted the VBPROJ file to add <AssemblyName> and <ApplicationIcon> nodes to the XML there. It appears to work fine.
The only problem that I have seen with it is that when I "Publish" the application, it is going to give a different build number to each office. That isn't perfect, but it will work for me.
you can manually control your build numbers if you wanted... that way they would match.
Just a note in case someone else tries to force the Publish to do what they want. Here is what I have learned so far. I am going to post the relevant VBPROJ file pieces and then explain below.
Note: This relates to VB 2005.
Note: The four lines of code under each Configuration section are lines that I added to the VBPROJ file manually.Code:<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...
<AssemblyName>MyApp</AssemblyName>(1)
<ApplicationIcon>Images\MyApp.ico</ApplicationIcon>(2)
<PublishUrl>\\Server\MyApp\</PublishUrl>(3)
<ProductName>MyApp - Something</ProductName>(4)
<PublisherName>Publisher</PublisherName>(5)
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-City1|AnyCPU' ">
<AssemblyName>MyApp - City1</AssemblyName>(1)
<ApplicationIcon>Images\City1.ico</ApplicationIcon>(2)
<PublishUrl>IGNORED BY ClickOnce</PublishUrl>
<ProductName>IGNORED BY ClickOnce</ProductName>
...
<DefineConstants>Location="CITY1"</DefineConstants>
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-City2|AnyCPU' ">
<AssemblyName>MyApp - City2</AssemblyName>(1)
<ApplicationIcon>Images\City2.ico</ApplicationIcon>(2)
<PublishUrl>IGNORED BY ClickOnce</PublishUrl>
<ProductName>IGNORED BY ClickOnce</ProductName>
...
<DefineConstants>Location="CITY2"</DefineConstants>
...
</PropertyGroup>
Legend:
1 - The AssemblyName works for the BUILD but not for the PUBLISH. Let me elaborate a little. If the Release-City1 configuration is selected, the Build works great and uses the AssemblyName and ApplicationIcon values from the Configuration settings that I added to the VBPROJ file. However, when you Publish the application, the Build works and then you get an error with the Publishing stating that it cannot find a folder. What appears to be happening is that the compiler uses the Configuration settings to build the application and stage its files, but when the Publish section starts, it ignores all of the values in the Configuration settings. Per the example above the Build creates a folder \bin\MyApp - City1.Publish and puts the necessary files in there then the Publish starts and is looking for a folder \bin\MyApp.Publish.
2 - The ApplicationIcon can be set in the appropriate PropertyGroup and it will work. (I forced this value into the VBPROJ file and it worked.)
3 - The PublishUrl value only works from the main PropertyGroup. It does not work from within the various configuration PropertyGroups.
4 - The ProductName value only works from the main PropertyGroup. It does not work from within the various configuration PropertyGroups. (This is the Product Name displayed on the ClickOnce Publish.htm page.)
5 - The PublisherName value only works from the main PropertyGroup. It does not work from within the various configuration PropertyGroups. (This is the name given to the folder in the Start -> All Programs menu)
In conclusion, from what I can garner about the process, it appears that the Build process will use the Configuration settings, but the Publish ignores them. This creates the error during the Publish.
Assumedly, the Publish portion of the Build process creates the Publish.htm and MyApp_ver_ver_ver_ver.application files, as those two files do not exist in the \bin\MyApp - City1.Publish folder.