Get Public Token for DLL Assembly

Get Public Token for DLL Assembly

Spesso torna utile sapere il Public Token del proprio assembly per poter registrare, ad esempio, un HTTP Handler o un HTTP Module nel web.config.

Ci sono 2 strade. Potete utilizzare da riga di comando il tool sn.exe (strong name) che si trova in C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin nel modo seguente:

C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>sn -T MyAssembly.dll Microsoft (R) .NET Framework Strong Name Utility Version 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. Public key token is b4e93c26a31a21f0

Oppure è sufficiente cercare il proprio assembly nella GAC (se registrato) e leggere il Token. La GAC è raggiungibile da File System in C:\Windows\Assembly

Una volta ottenuto il token è possibile registrare il proprio HTTPHandler nel web.config nel modo seguente:

<add verb="GET,HEAD" path="MyHandledPath.axd" type="MyNamespace.MyHTTPHandlerClass, MyAssemply, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9381fe228ab06e20" validate="false" />

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *