Getting a copy of a DLL in the GAC
2007-08-21 12:22
309 查看
GettingacopyofaDLLintheGAC
Afewweeksago,Thisapplicationtakesatleasttwoarguments.ThefirstargumentisthephysicalpathtotheGAConthesystem.ThesecondisthepathwheretheDLLneedstobecopied.ThefollowingexamplecopiesallCrystalcomponentsintheGACtoabackupfolder:
GetGACAssembliesC:\Windows\AssemblyC:\Projects\GACBackupCrystal*.dll
IfyoujustneedabackupofallGACassemblies,simplydosomethinglikethis:
GetGACAssembliesC:\Windows\AssemblyC:\Projects\GACBackup
Tobuildtheapplication,Iusedthe
usingSystem;
usingSystem.IO;
namespaceGetGACAssemblies
{
classProgram
{
privatestaticstring_targetPath;
staticvoidMain(string[]args)
{
//Youneedatleasttwoarguments
if(args.Length>=2)
{
//Getthetargetpathandmakesureitexists
_targetPath=args[1];
if(!_targetPath.EndsWith(@"\"))
{
_targetPath+=@"\";
}
if(!Directory.Exists(_targetPath))
{
Directory.CreateDirectory(_targetPath);
}
//Setupthedirectoryscannerobject
ScanDirectoryscanner=newScanDirectory();
scanner.FileEvent+=newScanDirectory.FileEventHandler(scanner_FileEvent);
if(args.Length==2)
{
scanner.SearchPattern="*.dll";
}
else
{
scanner.SearchPattern=args[2];
}
//Startthescan
scanner.WalkDirectory(args[0]);
}
}
staticvoidscanner_FileEvent(objectsender,FileEventArgse)
{
stringnewFile=_targetPath+e.Info.Name;
if(File.Exists(newFile))
{
File.Delete(newFile);
}
File.Copy(e.Info.FullName,newFile);
}
}
}
Youcan
GettingacopyofaDLLthat'sonlyintheGAC
Okprobablythereisasimpelerwayofdoingthisbutigoogledforitandcouldn'tfindit.Sohereisthestory.IneededaspecificDLLthatwasplacedintheGACbytheinstallofBizTalk.IneededtheDLLcauseIneededtoadareferenceinmyC#project.IfanybodyknowshowtoaddaReferencetoaDLLtha'sintheGACI'llbeinterestedaswell.
ButIcouldn'tfindawaytodoitsoIneededacopyofthatdll.
SoyouuseexplorerandBrowsetotheGAC.
Butyoucan'tmakeacopyofit,Youcanseeallthedetailsandstuffbutyoucannotcopyit.ButifyouopenaCommandpromptandgotothesamedirectorystufflooksdifferent....
AndforsurewhenyougotothecorrectdirectoryyoucangettheunderlyingDLL.
ThereareprobablyeasierwaysofdoingthisbutIthoughtIsharethismethodofdoingit.
相关文章推荐
- 评论数据库Win A Free Copy of Packt’s Managing Multimedia and Unstructured Data in the Oracle Database e-book
- Getting over the dangers of rm command in Linux---reference
- How do you copy the contents of an array to a std::vector in C++ without looping? (From stack over flow)
- [TroubleShooting] The remote copy of database xx has not been rolled forward to a point in time
- You cannot run the non-logged version of bulk copy in this database. Please check with the DBO. 问题的解决方法
- ExtJS中表格控件的使用,属性设置和数据的获取(copyfrom:http://www.itzhai.com/extjs-form-controls-in-the-use-of-property-)
- You cannot run the non-logged version of bulk copy in this database问题的解决方法
- Getting the indexes of duplicate elements in arrays (Ruby)
- How to Defeat Windows 8 ASLR in Getting the Address of KPCR
- Teddy's Aspect Weaver Version 0.3 with Great Updating and Fixing, Especially the Implementing of Getting Runtime Method Context Info and Method Arguments in MSIL Level
- 获取peergroup的所有peers(Getting a list of the peers in a PeerGroup)
- References & the Copy-Constructor(Chapter 11 of Thinking in C++)
- Win A Free Copy of Packt’s Managing Multimedia and Unstructured Data in the Oracle Database e-book
- Question 8: In which of the following scenarios is a Copy Constructor called or invoked?
- [TroubleShooting] The remote copy of database xx has not been rolled forward to a point in time
- Getting a statistics education: Review of the MSc in Statistics (Sheffield)
- An instance of getting the maximum and minimum values in an array
- Getting over the dangers of rm command in Linux---reference
- How to choose the number of topics/partitions in a Kafka cluster?
- 使用slidingmeu_actionbarsherlock_lib的问题和The hierarchy of the type MainActivity is inconsistent