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 ...
随机推荐
- 『SharePoint』Content Editor Webpart不能添加引用_layouts下面的文件
好久没写了,最近没怎么学到新东西,倒是犯了一个很常见的错误,那就是试图在content editor webpart中添加位于_layouts下面的一个txt文件,虽然这个txt中只是几行简单的htm ...
- View and Data API tips: 缓存Access Token
对于云API服务,常见的方式就是按照API调用次数收费,某些API调用也就有某些限制,比如在特定时间内只允许调用指定的次数以免造成滥用.虽然Autodesk的view and Data API目前还没 ...
- User Get 'Access Denied' with Excel Service WebPart
用户可以访问网站,并且具有相应的访问权限. 用户尝试了其他浏览器和IE的其他版本. 解决: 将用户添加到 ‘Excel Services Views’ 这个SharePoint组就OK了.
- IOS开发基础知识--碎片43
1:增加手势进行左划效果,针对视图并修改其中一个的坐标,菜单用隐藏跟显示 @property(strong,nonatomic)UISwipeGestureRecognizer *recognizer ...
- FastDFS+Nginx(单点部署)事例
FastDFS是由淘宝的余庆先生所开发,是一个轻量级.高性能的开源分布式文件系统,用纯C语言开发,包括文件存储.文件同步.文件访问(上传.下载).存取负载均衡.在线扩容.相同内容只存储一份等功能,适合 ...
- SQL Server Replication 中关于视图的点滴
在服务器A数据库TEST新建了一个本地发布(Local Publications)RPL_GES_MIS_TEST,在服务器B数据库RPL_TEST上创建了一个本地订阅(Local Subscript ...
- SQL Server自动化运维系列——监控性能指标脚本(Power Shell)
需求描述 一般在生产环境中,有时候需要自动的检测指标值状态,如果发生异常,需要提前预警的,比如发邮件告知,本篇就介绍如果通过Power shell实现状态值监控 监控值范围 根据经验,作为DBA一般需 ...
- MVC中的ActionLink生成的属性名称 中划线的解决办法
当使用ActionLink来生成链接属性时,由于中划线的变量名称不符合命名规则,那么直接写中划线的变量时无法编译,此时只要改为下划线即可.Razor 引擎会自动转为中划线. 即 data_icon ...
- 关于linx中man命令内容中第一行数字的含义
我们知道linux中man这玩意特别厉害,我们要查么个命令的使用方法.如man ls 出现如下内容 关于这写数字的含义如下表格
- jni调试3(线程调试env变量问题)
jni层调试线程死机原因 一,导致死机原因: jni层中 线程函数中 只要添加调用env 的函数 ,,就会死机 二,解决方法 第一我们应该理解: ①(独立性) JNIEnv 是一个与线 ...