![](/img/trans.png)
[英]Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug
[英]Dispose() causes dreaded Visual Studio "Unable to copy file from obj to bin' error?
在搜索了許多解決方案之后,我才發現控件的重寫Dispose方法導致了可怕的VS錯誤“無法將文件從obj /復制到bin / ...”(在我的情況下)
如果包含此Dispose方法,則每次更改代碼並嘗試重新生成時,VS都會引發錯誤。 如果注釋掉了覆蓋的處置方法,問題就會消失...
這里發生了什么? 我是在做錯什么,還是Visual Studio功能?
public class StyledLabel : Control
{
private ImageList imageList;
public ImageList ImageList
{
get { return imageList; }
set { imageList = value; }
}
public StyledLabel()
{
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
}
// This method causes dreaded VS Error ??
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (imageList != null)
{
imageList.Dispose();
}
}
base.Dispose(disposing);
}
}
編輯:不幸的是我現在無法重現該錯誤,所以我現在更加迷失了……vs錯誤消息消失了……
處置之前,請嘗試清除ImageList。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.