[Mono-list] about guid

Robert Jordan robertj at gmx.net
Sun Aug 15 10:20:06 EDT 2010


On 15.08.2010 14:30, Feng Su wrote:
> I compile a file to a assembly. I find the Guids of all classes  is
> 00000000-0000-0000-0000-000000000000.
> How can generate the different Guids for these classes?

You can manually apply a GuidAttribute to these classes, something
like that:

using System;
using System.Runtime.InteropServices;

[Guid("7ADF8247-2749-447E-890C-47BC7B42999F")]
class Program
{
	static void Main ()
	{
		Console.WriteLine (typeof(Program).GUID);
	}
}


Automatic Type.GUIDs are not implemented in Mono, mostly
because the algorithms behind MS' implementation are not well
documented.

Robert



More information about the Mono-list mailing list