获取异常 system.AppDomainUnloadedException:运行线程的应用程序域已被卸载
我正在研究 c# vsto ( excel ),并且我已经创建了 excel 2007 项目安装程序。项目在 Office 2007 中运行良好,但在 Office 2010 中打开它时,它开始产生问题。
System.AppDomainUnloadedexception: the application domain in which thread was running has been unloaded
有人对此有任何想法吗?
更新: 我刚刚再次检查了我的代码:
private void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
.
.
.
this.Close(Type.Missing, Type.Missing, Type.Missing);
.
.
}
它给出了 this.close
的异常
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.AppDomainUnloadedexception: 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简单的答案是您正在使用“this.Close”而没有告诉编译器“this”是什么。在这种情况下,您正在执行一个方法(void),但调用了编译器无法识别的内容。这是域错误的原因是什么?因为您正在尝试关闭整个应用程序,而不仅仅是您想要的工作簿。
解决方案是完全声明您尝试关闭的工作簿对象,然后对完全声明的对象调用 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.
关闭工作簿将关闭应用程序域。
请参阅 http://blogs.msdn.com/b/ mshneer/archive/2005/07/22/442866.aspx 进行解释。
Closing the workbook shuts down the application domain.
See http://blogs.msdn.com/b/mshneer/archive/2005/07/22/442866.aspx for an explanation.