ChrisA
ChrisA

Reputation: 4193

WinForms Designer breaks after a recompile

We have a WinForms application, targeting .NET 3.5.

Loading it up into VS2010 works fine, editing form layouts using the forms designer is fine initially, then we compile and run.

However, after that, pretty much any change to the layout of a form (sometimes just a solution rebuild) will break the designer.

The error we get is:

Could not load file or assembly 'OurControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Restarting VS2010 and reloading the solution will cure it, but only for a couple of edits before it recurs.

The project referred to in the message contains a bunch of home-grown controls that we use in the application. It's as if a Rebuild Solution causes VS lose its ability to reference it - but as I say, it has no problem on initial load.

We never had this with VS2008, and the solution is a straight upgrade from then.

Any suggestions would be greatly appreciated.. it's not yet practical to migrate to .NET 4, unfortunately, or to WPF!

Edit:

The folder structure is as follows:

Solution Folder 
. Projects folder 
.. Project A 
.. Project B etc

The startup project, containing the forms, is in one of the folders A, B etc. The OurControls that it can't find, is one of the others at that level.

On initially opening the solution, all projects load correctly, and there are no errors or reference warnings.

On initial rebuild after opening the solution, all the project folders get their respective DLLs correctly.

A 'Clean Solution' does not solve the problem.

Upvotes: 3

Views: 1503

Answers (2)

Gert Arnold
Gert Arnold

Reputation: 109281

Not a fix, but in Visual Studio 2010 I've found out that the quickest way to get the form designer back on track is unload/reload the project where the form is in. Don't know if it always helps, but it is quicker than restarting visual studio.

Let's see if VS 2012 is better.

Upvotes: 1

alex
alex

Reputation: 11

It's a VS2010 bug, see https://connect.microsoft.com/VisualStudio/feedback/details/709080/after-working-for-a-while-vs-designer-stops-to-regnize-types-and-does-not-allow-designing-winforms#.

You could sending them a dump file when it happens , since it's easy for me to reproduce/send dump files to MS.

Upvotes: 1

Related Questions