开发者

Getting exception system.AppDomainUnloadedexception: the application domain in which thread was running has been unloaded

开发者 https://www.devze.com 2023-04-04 08:48 出处:网络
I am working on c# vsto ( excel )and i have created the excel 2007 project installer . Project works fine in the Office 2007 but when open it in the Office 2010, it starts creating problem.

I am working on c# vsto ( excel )and i have created the excel 2007 project installer . Project works fine in the Office 2007 but when open it in the Office 2010, it starts creating problem.

System.AppDomainUn开发者_开发问答loadedexception: the application domain in which thread was running has been unloaded 

Anybody has any idea about it ?

UPDATE: I just checked my code again:

private void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
.
.
.
 this.Close(Type.Missing, Type.Missing, Type.Missing);
.
.

}

It is giving an exception for this.close


The simple answer is that you are using "this.Close" without telling the complier what "this" is. In this case, you are executing a method (void) but making a call to something that the compiler doesn't recognize.The reason it's a domain error? because you are trying to close the entire application instead of just the workbook you intended.

Solution would be to fully declare the workbook object that you are trying to close, then calling the close method on the fully declared object.


Closing the workbook shuts down the application domain. See http://blogs.msdn.com/b/mshneer/archive/2005/07/22/442866.aspx for an explanation.

0

精彩评论

暂无评论...
验证码 换一张
取 消