Uninstall from GAC In C# code
How do I uninstall the GAC from my C# application.
I am not able to uninstall, the particular exe and DLL from GAC.
Is it the proper way to uninstall the GAC in C# ?
public void RemoveAssembly(string ShortAssemblyName, string PublicToken)
{
AssemblyCacheEnum AssembCache = new AssemblyCacheEnum(null); string FullAssembName = null; for (; ; )
{
string AssembNameLoc = AssembCache.GetNextAssembly();
if (AssembNameLoc == null)
break; string Pt;
string ShortName = GetAssemblyShortName(AssembNameLoc, out Pt); if (ShortAssemblyName == ShortName)
{ if (PublicToken != null)
{
PublicToken = PublicToken.Trim().ToLower();
if (Pt == null)
{
FullAssembName = AssembNameLoc;
break;
} Pt = Pt.ToLower().Trim(); if (PublicToken == Pt)
{
FullAssembName = AssembNameLoc;
break;
}
}
else
{
FullAssembName = AssembNameLoc;
break;
}
}
} string Stoken = "null";
if (PublicToken != null)
{
Stoken = PublicToken;
} if (FullAssembName == null)
throw new Exception("Assembly=" + ShortAssemblyName + ",PublicToken=" +
token + " not found in GAC"); AssemblyCacheUninstallDisposition UninstDisp; AssemblyCache.UninstallAssembly(FullAssembName, null, out UninstDisp);
} public static void UninstallAssembly(String assemblyName, InstallReference reference, out AssemblyCacheUninstallDisposition disp)
{
AssemblyCacheUninstallDisposition dispResult = AssemblyCacheUninstallDisposition.Uninstalled;
if (reference != null)
{
if (!InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme))
throw new ArgumentException("Invalid reference guid.", "guid");
} IAssemblyCache ac = null; int hr = Utils.CreateAssemblyCache(out ac, 0);
if (hr >= 0)
{
hr = ac.UninstallAssembly(0, assemblyName, reference, out dispResult);
} if (hr < 0)
{
Marshal.ThrowExceptionForHR(hr);
} disp = dispResult;
}
Uninstall from GAC In C# code的更多相关文章
- Android Security
Android Security¶ 确认签名¶ Debug签名: $ jarsigner -verify -certs -verbose bin/TemplateGem.apk sm 2525 Sun ...
- 如何使用OpenCart 2.x Event事件系统
如何使用OpenCart 2.x Event事件系统 OpenCart 2.x 包含很多新特性,其中之一就是专为开发者提供的事件系统,Event System.它允许你在不修改原有系统代码的基础上( ...
- 【转载】使用appium遇到的坑
问题 1. error: Failed to start an Appium session, err was: Error: Requested a new session but one was ...
- Intent.java分析
代码位于frameworks/base/core/java/anroid/Content/Intent.java Intent是对要进行操作的一种抽象描述.用action抽象操作,用data(andr ...
- Appium的一些问题的总结答案
问题 1. error: Failed to start an Appium session, err was: Error: Requested a new session but one ...
- SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7(问题补充)
SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7 需要注册GAC,修改注册表 IBM官方方案: http: ...
- using inno setup uninstall default icon
If you set SetupIconFile then the Uninstall Exe File (e.g. unins000.exe) will have exactly same icon ...
- Gumshoe - Microsoft Code Coverage Test Toolset
Gumshoe - Microsoft Code Coverage Test Toolset 2014-07-17 What is Gumshoe? How to instrument a binar ...
- 【转】adb uninstall卸载apk文件说明
昨天在使用adb卸载程序,结果死活卸载不了.我输入的命令和系统提示如下: [plain] view plaincopy arthur@arthur-laptop:~$ adb uninstall ...
随机推荐
- iOS 疑难杂症 — — 推送本地国际化 loc-key 本地化失败的问题
声明 欢迎转载,但请保留文章原始出处:) 博客园:http://www.cnblogs.com 农民伯伯: http://over140.cnblogs.com 正文 一.准备 推送本地国际化官方 ...
- 学习Coding-iOS开源项目日志(五)
继续,接着前面第四篇<学习Coding-iOS开源项目日志(四)>讲解Coding-iOS开源项目. 前 言:作为初级程序员,想要提高自己的水平,其中一个有效的学习方法就是学习别人好的项目 ...
- mac brew & gcc安装
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ...
- .Net中使用SendGrid Web Api发送邮件(附源码)
SendGrid是一个第三方的解决邮件发送服务的提供商,在国外使用的比较普遍.国内类似的服务是SendCloud.SendGrid提供的发送邮件方式主要是两种, 一种是SMTP API, 一种是Web ...
- [分享] 很多人手机掉了,却不知道怎么找回来。LZ亲身经历讲述手机找回过程,申请加精!
文章开头:(LZ文笔不好,以下全部是文字描述,懒得配图.因为有人说手机掉了,他们问我是怎么找回来的.所以想写这篇帖子.只不过前段时间忙,没时间.凑端午节给大家一些经验) 还是先谢谢被偷经历吧!5月22 ...
- 一个C语言问题
在这个题目中,你需要编写一个c++程序,要求输出以下内容:000000010010.....11101111(输出0到31的每个数的二进制表示,每行一个,前面的0也必须输出!) 1)部分代码已经为你完 ...
- JavaSe:Cookie 管理的API介绍
CookieManager 在使用HttpURLConnection中,并没有关于Cookie的管理.如果使用Java程序时,怎么管理cookie呢? Cookie案例 1. User Agent - ...
- 大数据系列(5)——Hadoop集群MYSQL的安装
前言 有一段时间没写文章了,最近事情挺多的,现在咱们回归正题,经过前面四篇文章的介绍,已经通过VMware安装了Hadoop的集群环境,相关的两款软件VSFTP和SecureCRT也已经正常安装了. ...
- MySQL优化概述
一. MySQL优化要点 MySQL优化是一门复杂的综合性技术,主要包括: 1 表的设计合理化(符合 3NF,必要时允许数据冗余) 2.1 SQL语句优化(以查询为主) 2.2 适当添加索引(主键索引 ...
- 【java开发】分支语句、循环语句学习
一.Java分支语句类型 if-else 语句 switch 关于if-esle语句可以拆分为三种 if语句 if(条件){语句块;} if-else语句if(条件语句){语句块;} if-else ...