3

Quick bit of background to the project in question: it's C# .Net 4, WinForms with smart client factory and unfortunately a lot of visual inheritance.

Here's a brief outline of the problem the team I'm working on are experiencing which seems to be fairly intermittent:

Someone will open up one of the client module projects to begin work on one of the views, double click on the view to open up the designer and Visual Studio will give them a design time error such as:

There's no way back from this; if you rebuild from here without doing the following work around then the error will still persist. The only work around we've found is to clean the client solution, close Visual Studio (you have to do that), reopen Visual Studio and rebuild the solution. Next time you try to open the view it will work. But the error will come back again - it seems to be after X amount of rebuilds (possibly only while the view is open in the designer whilst you're building the solution?)

No one has taken the time out to really dig into this problem and at the moment no one has the time! So I was wondering (bit of a long shot) if anyone might have an idea about what could be going on? Or perhaps an inkling of where to start digging once we get a bit of time to look into this?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
james lewis
  • 2,486
  • 3
  • 24
  • 30
  • We've got the same problem, but no solution either. We've got a lot of inherited views and I always suspected that a change to the base class is the cause, not always, but sometimes. Another possible cause could be the change to a control that you include in your view. – Andreas Oct 18 '11 at 12:01
  • possible duplicate of [C# Visual Studio 2010 suddenly can't see namespace?](http://stackoverflow.com/questions/4880685/c-sharp-visual-studio-2010-suddenly-cant-see-namespace) – Hans Passant Oct 18 '11 at 12:02
  • @HansPassant thanks for the comment but I don't think this is a duplicate of that question. – james lewis Oct 18 '11 at 12:09
  • @DonAndre yeah it's definitely a weird one - 9 times out of 10 I can't even open the base view before doing the work around (not that we actually ever do much to the base views anymore). Very annoying issue that's costing our team a lot of time during our sprints. I thought it could have something to do with how these visual hierarchies are built and then rebuilt (something missing second time around?) but I don't have anywhere near the amount of VS knowledge to guess. Thanks for the input though. – james lewis Oct 18 '11 at 12:13
  • @HansPassant that's not a duplicate and the answer wouldn't work, otherwise we wouldn't even have a problem :-) – Andreas Oct 18 '11 at 13:13
  • Not sure what kind of answers you guys are hoping for if you do nothing to narrow down the possible causes in the question and comments. Call Microsoft Support, have a repro project ready for them to look at. – Hans Passant Oct 18 '11 at 13:17

1 Answers1

0

If you use visual inheritance, these problems are a fact of life and they're not likely to ever go away.

I make extensive use of UserControl inheritance in my current project. I used to get the problem you're describing very frequently. Over time I've refined the design down to the point where it only happens occasionally now, and I rarely have to do the clean-restart-rebuild dance anymore.

You mileage will probably vary, but I think the main thing I did to reduce this problem was to get rid of design-time inter-assembly data bindings.

An example of this is when you drop BindingSource on your form and set its datasource to a type from another assembly.

(Well, it's always from another assembly because I never define types in the same assembly as my UI. So for all I know, the inter-assembly thing may not even be a factor.)

Anyway I ended up getting rid of most or all of these design-time bindings and setting up all my bindings at runtime. The problem has 99% gone away. It still happens occasionally but I don't bother to try to troubleshoot it.

And whatever you do, don't inherit a form/control from a generic base class. That breaks it 100% of the time. If you need to do this, there's a workaround which you can find with quick search.

Microsoft will almost certainly never fix these problems, so get used to them.

Igby Largeman
  • 16,495
  • 3
  • 60
  • 86