Sudden VS Form Design error: The designer could not be shown for this file ...

We encourage new members to introduce themselves here. Get to know one another and share your interests.
ic2
Posts: 1863
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Sudden VS Form Design error: The designer could not be shown for this file ...

Post 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
User avatar
robert
Posts: 4558
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Sudden VS Form Design error: The designer could not be shown for this file ...

Post by robert »

Dick,
I would love to blame Ms for this, but this was an error in our code...

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
ic2
Posts: 1863
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Sudden VS Form Design error: The designer could not be shown for this file ...

Post 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
User avatar
Chris
Posts: 4977
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Sudden VS Form Design error: The designer could not be shown for this file ...

Post 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.

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1863
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Re: Sudden VS Form Design error: The designer could not be shown for this file ...

Post 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
User avatar
Chris
Posts: 4977
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Sudden VS Form Design error: The designer could not be shown for this file ...

Post 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?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1863
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Re: Sudden VS Form Design error: The designer could not be shown for this file ...

Post 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
User avatar
Chris
Posts: 4977
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Sudden VS Form Design error: The designer could not be shown for this file ...

Post 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?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1863
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Re: Sudden VS Form Design error: The designer could not be shown for this file ...

Post 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
User avatar
Chris
Posts: 4977
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Sudden VS Form Design error: The designer could not be shown for this file ...

Post by Chris »

Hi Dick,

Yes, this one. What are the other contents of that file?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply