Establish your own .NET class library

zhaozj2021-02-17  55

Establish your own .NET class library

First, open your vs.net, find a Class Library project, here we are named: MyDLL.

Second, add a strong name to your own DLL project, steps below:

1, click Start -> Program -> Micro Visual Studio.net -> Micro Visual Studio.net Tools-> Visual Studio .NET Command Prompt

2, enter SN -K C: /MYDLKEY.SNK

3, return to the vs.net editing the environment, open the assembly.cs (or vb) file, change [askMBLY: askEMBLYKEYFILE (")]: [Assembly: askEMBLYKEYFILE (@" c: /mydllkey.snk ")]

Third, compile the MYDLL project, generate mydll.dll, here we assume that mydll.dll files in c: / myproj / mydll / bin / release / directory

Fourth, return to the Visual Studio .NET Command Prompt command prompt, enter Gacutil -i c: /myproj/mydll/bin/release/mydll.dll

5. Open the registry, in the hkey_current_machine / software / microsoft / .NetFramework / assemblyfolders key, create a new key value "mydll", change its default value to: c: / myproj / mydll / bin / release /

6. Restart VS.NET, create any project, then right click on References, select Add Reference, you can see your MyDLL under .NET TAB.

Summary: We can register some of your components you usually use into a GAC, and in .NET, you can use it for a lot of convenience for yourself.

转载请注明原文地址:https://www.9cbs.com/read-30624.html

New Post(0)