# Asign PublicKeyToken for nuget package ###### tags: `C#` ### How to check nuget package infomation use powerShell ``` ([system.reflection.assembly]::loadfile("C:package\aaa.dll")).FullName ``` ![command result](https://i.imgur.com/3Sr5HJi.png) ### Nuget package want use assembly need have PublicKeyToken If one project different package all use one comment package(like Newtonsoft.Json) but with different version, then need use assembly at web.config to decied this shared package in project will use which version. In poject runtime package can't use different version. In ASP.NET Core no need to assign assembly at web.config, framework will do it automic. ![assembly command](https://i.imgur.com/1U7ALqE.png) If nuget package was packaged by yourself or 3rd party, and not assign **strong name**, then PublicKeyToken will be null. Framework assembly bindings will ignor for publickeytoken null package, can see in [official document](https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions?redirectedfrom=MSDN) or other discous in stackoverflow [article1](https://stackoverflow.com/questions/10324972/are-assembly-bindings-ignored-for-publickeytoken-null)、[article2](https://stackoverflow.com/questions/2191296/net-assembly-binding-redirect-with-differing-public-key-tokens). So for this aituation only can do let all package use same version of shared package or assigned strong name for shared package. Need be noted if package version which is used have PublicKeyToken null, then assembly will not work, need let all of version of package have PublicKeyToken. ### How to assign strong name [How to: Sign an assembly with a strong name office document](https://docs.microsoft.com/en-us/dotnet/standard/assembly/sign-strong-name) [Create and use strong-named assemblies official document](https://docs.microsoft.com/en-us/dotnet/standard/assembly/create-use-strong-named?redirectedfrom=MSDN) [what exactly are delay signing and strong names in net](https://stackoverflow.com/questions/8394357/what-exactly-are-delay-signing-and-strong-names-in-net) #### Use Visual Studio 1. In Solution Explorer, open the shortcut menu for the project, and then choose Properties 2. Under the Singing tab and Select the Sign the assembly checkbox, which expands the options 3. Select the Browse button to choose a Strong name key file path ps: If already have key need keep use it. If not choose New Visual Studio will generate new key file ![assign strong name in visual studio](https://i.imgur.com/Vt0zeGW.png) #### Modify SDK Html by self use Visual Studio UI assign stong name, it will automatic modify SDK file, so we also can change by self ![modify sdk file](https://i.imgur.com/90yhzRv.png)