Lets use Carlib.dll from One file Assembly
1. Strong name
Properties – > Signing – > Sign the assembly -> New – > SomeName (for ex. myKeyPair.snk)
2. Install assembly to GAC (Global Assembly Cache)
go to
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Developer Command Prompt for VS2015
start Developer Command Prompt for VS2015 with Admin rights
write something like
C:\C#\MyC#StudyProjects\07_DifferentMains\CarLibrary\CarLibrary\bin\Debug>gacutil -i CarLibrary.dll
and receive
Сборка успешно добавлена в кэш
check if assembly in GAC
C:\C#\MyC#StudyProjects\07_DifferentMains\CarLibrary\CarLibrary\bin\Debug>gacutil -l CarLibrary
and receive
В глобальном кэше сборок содержатся следующие сборки:
CarLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6a9228aea5de13fa, processorArchitecture=MSIL
Число элементов = 1
3. Use assembly
In MS Visual Studio – Class View – right click add Reference – > Browse
add assembly to solution… go to…
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\CarLibrary\v4.0_1.0.0.0__6a9228aea5de13fa
and add CarLib.dll
4. Use it in project – now assembly not copied to location of program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CarLibrary; // << namespace SharedCarClient { class Program { static void Main(string[] args) { SportsCar c = new SportsCar(); c.TurboBoost(); Console.ReadLine(); } } } |