如何从C#应用程序中卸载GAC.
我无法从GAC卸载特定的exe和DLL.
这是在C#中卸载GAC的正确方法吗?
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
{ …Run Code Online (Sandbox Code Playgroud) 我是新的2 C#,我已经完成了一项任务......我必须编写一个C#代码,将发送的电子邮件附件和Outlook 2007中的电子邮件主题下载到本地驱动器或任何指定位置.我怎么做?我能够获取收件箱中的附件.任何人都可以帮我收看通过Outlook发送的邮件吗?
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.NewMail += new
Microsoft.Office.Interop.Outlook.
ApplicationEvents_11_NewMailEventHandler(ThisApplication_NewMail);
}
private void ThisApplication_NewMail()
{
Outlook.MAPIFolder SentMail = this.Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
Outlook.Items SentMailItems = SentMail.Items;
Outlook.MailItem newEmail = null;
//SentMailItems = SentMailItems.Restrict("[Unread] = true");
try
{
foreach (object collectionItem in SentMailItems)
{
newEmail = collectionItem as Outlook.MailItem;
if (newEmail != null)
{
if (newEmail.Attachments.Count > 0)
{
for (int i = 1; i <= newEmail.Attachments.Count; i++)
{
newEmail.Attachments[i].SaveAsFile(@"C:\TestFileSave\" + newEmail.Attachments[i].FileName);
}
}
}
}
}
catch (Exception …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
int i = 0, j = 0;
for(i=0,j=0;i<5,j<25;i++,j++);
cout<<i <<" "<<j;
Run Code Online (Sandbox Code Playgroud)
我不知道它为什么输出25 25.我真的不明白为什么它的价值25 i和j.任何人都可以解释一下为什么它从第二个条件达到25的价值?这是在一个for循环中检查两个条件的问题吗?
我正在编写一个Windows服务,检查特定服务并检查它.如果它停止它将启动它...
protected override void OnStart(string[] args)
{
Thread thread = new Thread(new ThreadStart(ServiceThreadFunction));
thread.Start();
}
public void ServiceThreadFunction()
{
try
{
ServiceController dc = new ServiceController("WebClient");
//ServiceController[] services = ServiceController.GetServices();
while (true)
{
if ((int)dc.Status == 1)
{
dc.Start();
WriteLog(dc.Status.ToString);
if ((int)dc.Status == 0)
{
//heartbeat
}
}
else
{
//service started
}
//Thread.Sleep(1000);
}
}
catch (Exception ex)
{
// log errors
}
}
Run Code Online (Sandbox Code Playgroud)
我希望服务检查另一项服务并开始... PLZ帮助我如何做到这一点