.NET     Console.WriteLine( "All Things .NET" );
.NET Nerd Blog Home
3.23.2006

 
VersionInfo
Back in the C++ days, you get file version info from a Win32 API call which returned you a VERSIONINFO resource. This structure would have things like the copyright, internal product name, etc.

In .NET, the AssemblyInfo.cs source file contains attributes for each of these types of information. Here's how to get at the information at runtime.

Assembly asm = Assembly.GetExecutingAssembly();

// use this to get all custom attributes. have array and can walk through it
//object[] atts = asm.GetCustomAttributes( false );

// use this to get directly to a particular type of custom attribute
AssemblyCopyrightAttribute copy = AssemblyCopyrightAttribute.GetCustomAttribute( asm,
typeof( AssemblyCopyrightAttribute ) ) as AssemblyCopyrightAttribute;
Console.WriteLine( copy.Copyright );


3.09.2006

 
Fun With Nullable Types
We were playing with Nullable types this week - came across some interesting methods that are available to interrogate Nullable types.

To get at the underlying data type in the Nullable type:
System.Nullable.GetUnderlyingType(type)

And to find out more about a Type, whether it's a generic, whether it's a Nullable type, and what are the generic template arguments...


string s = "23";
object o = Convert.ChangeType( s, typeof( int ) );

Nullable ni = 3;
Type t = ni.GetType();

Type t2 = typeof( Nullable );

if ( t2.IsGenericType && t2.GetGenericTypeDefinition() == typeof(Nullable<>))
{
Type baseType = t2.GetGenericArguments()[0];
object o2 = Convert.ChangeType( s, baseType );
//return Activator.CreateInstance(ft, val);
}


Google groups post here


3.03.2006

 
WinFX February CTP
At the client I'm currently working with, we are waist deep in the WinFX pre-release cycle. Here is a quick list of download URLs for the tech stack that we're currently working with. Includes WCF & WF (and then those UI weenies are adding Atlas to the mix as well)

WinFX downloads -- February CTP





Powered by Blogger