Page 2 of 3
Sudden VS Form Design error: The designer could not be shown for this file ...
Posted: Tue May 02, 2023 8:54 am
by ic2
Hello Robert,
robert post=26079 userid=253 wrote:
-next: started to remove variable declarations ... and BINGO, its the "PUBLIC CONST" declaration! So, I'm going to change my code and use the contemporary "rn" where needed. Note: remember, this compiled and executed just fine.
This is what I still don't understand. If this is the cause, how could it have worked previously and not anymore when restoring the complete backup?
If I had an issue like this and restoring a backup, it was invariably some VS problem. Otherwise restoring a backup solved it.
Dick
Sudden VS Form Design error: The designer could not be shown for this file ...
Posted: Tue May 02, 2023 9:10 am
by robert
Dick,
I would love to blame Ms for this, but this was an error in our code...
Robert
Sudden VS Form Design error: The designer could not be shown for this file ...
Posted: Tue May 02, 2023 9:28 pm
by ic2
Hello Robert,
This you wrote, but that still keeps me wondering how it was possible that the earlier version worked for him, and once he did restore this very same working version from the backup it didn't.
Dick
Sudden VS Form Design error: The designer could not be shown for this file ...
Posted: Tue May 02, 2023 10:12 pm
by Chris
Hi Dick,
I suspect that Roland had restored an earlier version of the form.designer.prg file, but kept the form.prg with the code that caused the problem.
.
Re: Sudden VS Form Design error: The designer could not be shown for this file ...
Posted: Tue Nov 28, 2023 9:27 pm
by ic2
I opened an X# solution on which I didn't work for a while. And got this same error (designer could not be shown for this file because none of the classes within it can be designed), on the main window. The MSDN help is useless (as usual) : "The class can be designed, but it is not the first class in the file. Visual Studio requires that designers use the first class in the file."
Of course it is the first (in fact only) class in the file. I've updated X# to 2.18 and, stupid enough, upgraded VS. It looks from the GitHub URL that this error should have been solved, at least from the X# side?
I have deleted the .vs directory, no change. .NET desktop development is checked as installed. For a few other Winforms windows in the solution the designer shows just right. But, also after a restart, this error remains.
There's no PUBLIC CONST in the xxxMainDesigner.prg, just a generated class with private controls of the main Winforms window of our program plus an also generated InitializeComponent and Dispose, which worked (unchanged) until the VS and X# update.
Is there anything else I can try?
Dick
Re: Sudden VS Form Design error: The designer could not be shown for this file ...
Posted: Wed Nov 29, 2023 7:54 am
by Chris
Hi Dick,
Because VS uses the source code itself for storing the window definition, there are a million reasons which could be causing this error message, and in most cases it's a small bug in the source parsing code component of X#. Can you please send us the project with this window, so we can find what's causing the problem?
Re: Sudden VS Form Design error: The designer could not be shown for this file ...
Posted: Wed Nov 29, 2023 8:48 pm
by ic2
Thanks Chris for the offer. Is there anything I can try myself? What I did already:
1 I copied the whole solution directory to another Pc with X# 2.12 still on it, and VS 2019 16.11.5 from October 2021 (instead of the latest 16.11.32). The first time I tried View Designer I got "The designer cannot be shown because the document for it was never loaded". This was solved after restarting VS, so the designer shows my Winform there without problems. I could for example update X# first, then Visual Studio, to see if any of these updates cause the error?
2 I renamed the designer.bak from 2022 to designer.prg, no change
3 I removed all code from the designer.prg except the namespace and class definitions, no change.
Dick
Re: Sudden VS Form Design error: The designer could not be shown for this file ...
Posted: Thu Nov 30, 2023 7:07 am
by Chris
Hi Dick,
If there's no code in form.designer.prg except for the namespace and class, then the problem probably lies in the form.prg file. Try removing code from that, too. Also what's the inherit clause of the form definition?
Re: Sudden VS Form Design error: The designer could not be shown for this file ...
Posted: Thu Nov 30, 2023 11:51 am
by ic2
Hello Chris,
Do you mean, with form.prg, the program which opens with "View source"? In my case iConnectMain.prg.
In the iConnectMain.Designer.prg the inheritance is
Code: Select all
Public Partial Class iConnectMain ;
Inherit System.Windows.Forms.Form
which is equal to the class of the code (in iConnectMain.prg)
Dick
Re: Sudden VS Form Design error: The designer could not be shown for this file ...
Posted: Thu Nov 30, 2023 4:52 pm
by Chris
Hi Dick,
Yes, this one. What are the other contents of that file?