Monday, May 22, 2006

Retrieving an Assembly's PublicKeyToken

The short of it is, use the sn -T blah.dll command (see link). Here's the step-by-step for finding the PublicKeyToken of the System.Data.SqlServerCe.dll:

1. Open up the Visual Studio 2005 Command Prompt from the Start Menu. That should set the environment for using VS2005 commands.
2. C:\>cd "C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0\"
3. Type "sn -T System.Data.SqlServerCe.dll"

The sn utility will return something like: Public key token is 3be235df1c8d2ad3

Note: if you do not include a capital T (but instead a lowercase, -t), you will receive the following error: "Failed to convert key to token -- The public key for assembly '(null)' was invalid."

4 comments:

Attila Buturla said...

Thanks; I spent a good hour trying to figure this out.

Anonymous said...

thanks man.
it was 2 days and just a stupid mistake of capital letter...
thanks

Maxim said...

Thank you very much!

I spent three hours for searching the stupid mistake.

Anonymous said...

Thanks a ton!
I spent many hours to debug it as well.