If your project requires someProgramThe Set exists in GAC, but those sets are generated when you compile another project, or are dynamically changed for other reasons, the best practice is to re-add these assembly to GAC when compiling the project.
If your GAC contains the assembly of your project because of deployment and other work, and you cannot add breakpoint debugging and so on, this kind of thing often happens, it is also a good solution to re-add these assembly to GAC when compiling the project.
The idea of automatically adding an assembly to GAC during compilation is very simple. It is to write a batch file and then call this batch file in the project generation event. The specific implementation is as follows:
1. Create a register.batfile under your project directory and use the Microsoft gacutil.exetool in batch processing. The location of the gacutil.exe tool varies depending on the operating system version. XP is v6.0a, While Vista and win7 are v7.0a. Assume that you have two projects: myproject1 and myproject2. myproject1 is an executable file, and myproject2 is a dynamic link library.
@ Echo off
Set Path = % PATH %; C: \ Program Files \ microsoft sdks \ windows \ v7.0a \ bin;
Set solutionpath = c: \ Users \ cyljxu \ Documents \ Visual Studio 2008 \ projects \ windowsformsapplication17 \
Gacutil/if "% solutionpath % myproject1 \ bin \ % ~ 1 \ myproject1.exe"
Gacutil/if "% solutionpath % myproject2 \ bin \ % ~ 1 \ myproject2.dll"
Exit 0
Note: \ bin \ % ~ 1 \ % ~ 1 indicates the compilation configuration, such as debug or release.
2. Open the properties page of the project and add a post-build event command line:
Call "$ (projectdir) Register. Bat" $ (configurationname )"
Note:
1. All the assembly to be added to GAC must be signed.
2. Because gacutil commands require administrator permissions, you must run ide as administrator in Vista and win7.