0

I have a project in Visual Studio which is misidentifying some of the files as 'user controls' as opposed to code-only classes. The project compiles and runs just fine, but it does leave a slightly annoying issue that when these files are double-clicked, the designer window is presented instead of the code editor.

Obviously, there are plenty of ways to get to the editor but, firstly it's annoying, and secondly, I don't know if this could lead to other issues later down the road so I'd like to resolve the problem sooner rather than later.

As you can see from the screenshot, there are 5 files, all of which are code-only classes, yet 4 of them are identified as custom-controls by the solutions explorer; only the final one is identified correctly.

Only SignalRManager.vb is correctly identified

No additional Designer Files

LairdPleng
  • 948
  • 3
  • 9
  • 28
  • Here's what I would do: a) Clean + Rebuild. b) Close + reopen VS. c) If a and b didn't work, I would try to open the solution on another PC (or in a different version of VS on the same PC) to make sure the problem is actually with Visual Studio, not the solution. Is it safe to assume you tried all that? – 41686d6564 stands w. Palestine Mar 29 '18 at 11:33
  • I'm also assuming here that you **are indeed sure that these are classes** *(they could be Components for example)*. Did you expand that arrow in front of each file and make sure that there is no designer code which inherits the Component class (or other derived classes)? Note: to be able to see the designer file, the `Show All Files` option needs to be enabled *which seems to be the case*. – 41686d6564 stands w. Palestine Mar 29 '18 at 11:45
  • @AhmedAbdelhameed I have tried cleaning, rebuilding and opening on other machines. I've added another screen grab with one of the files expanded. As you can see, there are no underlying designer files. – LairdPleng Mar 30 '18 at 03:50
  • Does it still look the same on the other machine? Do your classes inherits from any other classes? If so, what are they? – 41686d6564 stands w. Palestine Mar 30 '18 at 03:58
  • Ah yes; they all inherited from Sytem.ComponentModel.BackgroundWorker... Removing this inheritance and refactoring the code sorted the problem, thanks. – LairdPleng Mar 30 '18 at 04:30
  • 1
    Well, that explains everything since the `BackgroundWorker` class inherits from the `Component` class. Note: if you want to force any file to be displayed as a code-only file (e.g., if you still need to inherit from `BackgroundWorker`), you can always do that using the following attribute: ``. Check [this answer](https://stackoverflow.com/a/11897552/4934172) for more. – 41686d6564 stands w. Palestine Mar 30 '18 at 04:39

0 Answers0