views:

81

answers:

2

I researched quite a lot on this but finally seemed to pin down on this issue. Visual Studio some times randomly locks the build dll/exe file if you have custom controls in your project. Steps to replicate:

  1. Create a winforms app/dll project
  2. Add a new class, say CustomButton that inherits from Button
  3. Build
  4. Create a form. Look in the toolbox, and the custombutton appears allowing you drag it on your form
  5. [This now becomes random] the next build of your project will either proceed or fail requiring you to restart visual studio.

Any ideas?

A: 

Download process explorer and do a search on your DLL name to make sure VS is the only thing that has this DLL. It might be something silly like Microsoft Indexing Service that is locking the DLL.

Conrad Frix
Yes, it does actually have a handle on it. Closing the handle did not resolve it.
Crypton
I also tried moving the controls to a referenced library project and now that project build is locked, so it's definately the user controls cause it.
Crypton
+1  A: 

Seems to have found a [temporary] solution. It seems M$ "fixed" this in later versions, but it still does not work. Anyways, here is solution: remove automatic version incrementing in the assembly version attribute. This seems to resolve the issue however it's somewhat inconvenient.

https://connect.microsoft.com/VisualStudio/feedback/details/533411

Temporary workaround would be disable assembly version update after the rebuild. In AssemblyInfo.cs file, remove the wild card from the AssemblyVersion attribute, for example: replace this: [assembly: AssemblyVersion("1.4.*")] [assembly: AssemblyFileVersion("1.4")] with this: [assembly: AssemblyVersion("1.4.0.0")] [assembly: AssemblyFileVersion("1.4.0.0")]

UPD Again :( The above did not solve the problem. I am still going to leave it in case somebody else encounters something like this, but the question remains open.

Crypton