EricG52

Under C++, we were able to add fields to the version structure and read them afterwards.
I currently have the following assenly data in my Assembly version.cs file.

[assembly: AssemblyTitle("Gage Interop Functions Library")]
[assembly: AssemblyDescription("Interop functions with Gage API")]
[assembly: AssemblyConfiguration("C# SDK")]
[assembly: AssemblyCompany("Gage Applied Technologies, Inc.")]
[assembly: AssemblyProduct("GageFunctions")]
[assembly: AssemblyCopyright("(c) Gage Applied Technologies 2003-2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Now, I would like to add a new field AssemblyMandatory.

How should I proceed in C# to add the field in the version block

Thanks

EricG


Re: Visual C# General How can I add fields to the assembly version??

Chris Eargle

The first thing you need to do is make your new attribute class.

Code Block

[AttributeUsage(AttributeTargets.Assembly)]

public class AssemblyUrlAttribute : Attribute

{

private string _url;

public string Url

{

get

{

return _url;

}

set

{

_url = value;

}

}

public AssemblyUrlAttribute(String url)

{

_url = url;

}

}

Then, add the namespace your class resides in to the using clause of AssemblyInfo.cs. Now you can declare your new attribute inside of AssemblyInfo.cs.

Code Block

[assembly: AssemblyUrl("www.kodefuguru.com")]

Now, you can do the same with AssemblyMandatory. Remember that if you name it AssemblyMandatoryAttribute, you can declare it as [assembly: AssemblyMandatory()]. The key to this is that you have derived from Attribute, and you add the attribute [AttributeUsage(AttributeTargets.Assembly)] to the class.