Wednesday 7 September 2022

Add DLL to SharePoint bin folder

Add DLL to SharePoint bin folder

 I have done this before for some sharepoint 2013 webparts projects and when googling I found this article, there it is explained how to sign third party assemblies with strong name. Basically you disassemble the dll first with ILDASM.exe and then you reassemble with ILASM.exe providing a *.snk file previously done with sn.exe. All this is explained in detail in the given article.

https://docs.microsoft.com/en-us/archive/blogs/miah/how-to-assign-a-strong-name-to-an-unsigned-3rd-party-assembly

How to sign a .NET Assembly DLL file with a Strong Name

 How to sign a .NET Assembly DLL file with a Strong Name 

.NET Assembly DLL file can be sign with strong name if it is no sign by using ILDASM and ILASM

Create strong name file.

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools

sn -k sgKey.snk


(Dis)assemble a dll using the Visual Studio command prompt


ildasm directory\myLibrary.dll output:directory\MyLibrary.il

Assemble a dll using the Visual Studio command prompt

ilasm c:\myLibrary.il /dll /key=C:\MessageIntegrity.snk /output:C:\myLibrary.dll


another example :
> ildasm /all /out=MYASSEMBLY.il MYASSEMBLY.dll
> ilasm /dll /key=key.snk MYASSEMBLY.il






Create a strong name key (snk) file

 

Create a strong name key (snk) file


Click Start, point to Programs, point to Microsoft Visual Studio 2019, point to Visual Studio Tools, and then click Visual Studio Command Prompt (2019).

  • At the command prompt, navigate to the location where you want to create the key file. For example, type cd C:\Sample, and then press ENTER.

  • At the command prompt, type sn -k <key file name>.snk, and then press ENTER.

  • At the command prompt, type exit, and then press ENTER.