John,
You have to do to things to accomplish this:
1) The field ("global string variable") you create must be in a class or
struct definition
2) The field must be constant - so you'll have to create a string declared
public const string versionInfoString = "1.1.1.1";
in some class or struct.
Not to say you shouldn't do this, but is there a reason you want to do it
this way? the version can't be changed at runtime and you can get the
current version number of the assembly as a string fairly simply:
System.Reflection.Assembly.GetExecutingAssembly(). GetName().Version.ToString
();
If you really, really want to, you can do it like this:
in the assemblyinfo.cs, change the [assembly: AssemblyVersion(... line to:
[assembly: AssemblyVersion(MyApp.Constants.VersionInfoString)]
Put this at the END of your assembly info
namespace MyApp
{
public struct Constants
{
public const string VersionInfoString = "1.1.1.1";
}
}
But as stated above, this really doesn't get you much. The one use I can
see for it would be to include the same
file with that struct in many different assemblies that you wanted the
version number synched on.
"John" <jo***********@hotmail.com> wrote in message
news:uX**************@TK2MSFTNGP10.phx.gbl...
Hello,
I would like to create a global string variable in my assemblyinfo.cs
file. This string will contain the value of my version info. Can anybody tell
me how to create a global string value in assemblyinfo.cs?
I have the following code after using System.Runtime.CompilerServices;:
string s;
I keep getting the following error:
A namespace does not directly contain members such as fields or methods.
Expected class, delegate, enum, interface, or struct.
I tried to create a class but was unsuccessful. Any ideas?
Thanks,
-- John