Forms in project either don't display any controls or the form does not show up at all any more

SIH007

New member
Joined
Sep 22, 2020
Messages
2
Programming Experience
10+
Hi,

I copied the entire project to my private pc to resume working on it from home (I copied the entire folder to a stick).
When starting work on the project on my pc I found that some of the forms are fine, others lost their controls and one (unfortunately the most important one) is not recognized as a windows form any more (instead of showing the forms icon in the project explorer it shows the c# icon, and it is not possible to switch to design view any more.
Does anyone of you know that problem and how to solve it? The code behind appears to be still complete.
 
I've seen similar symptoms before but there's no one specific cause that can be undone. Maybe you did something wrong and maybe you didn't. What EXACTLY did you copy? Was it the folder that contains the SLN file? If not, it should have been.

This is a fine example of why it's best to use cloud-based source control if possible. You just link each machine to the same provider and then any changes you make on any machine will be synced to all the others. There's no need for copying things around on flash drives or the like. Is that a possibility?

As for the fix, it would be easiest to take another copy if that's possible. If it's not, please post a screenshot of your Solution Explorer.
 
When you copied your project, did you exit Visual Studio first? Current Visual Studio defers updating the *.sln file until you lose the solution. Older versions of Visual Studio also deferred updating the project files (e.g. *.vcproj, *.vcxproj, etc.). If you copied the project while VS was live, you risk not copying everything. Furthermore the newer Visual Studio uses SQLite to keep some per developer/machine state that goes into the .vs directory.

And then after exiting Visual Studio, did you tree copy the entire solution directory and down, or did you just cherry pick some files? You should have done the former. And then after doing the former, if you had a newer version of Visual Studio, you should have stripped away the hidden .vs directory, and if you are using an older version of Visual Studio, you should have stripped away the .suo file and a few other hidden files. Visual Studio keeps per developer/machine state in these files which should not really be transported across machines.
 
As for "some controls not showing up in some forms", I assume you mean that the controls were not showing up in the Forms Designer. I would assume that is because you made some user controls and put those in the form. For them to be visible in the form, the controls need to be compiled. The WinForms designer is not as smart as the WPF designer which most of the time knows how to compile the user controls on demand.
 
Hi,

thanks for your reply.

I think default setting in VS is that you store your code in ...\source\repos\
I did not change that and when you create a project you can select to place project folder and project in the same folder (which I did). And when I copied my project I copied the entire folder ..\source\repos\MyProject, so I don't think I lost anything.
Of course I compiled the project before copying it.
 
Of course I compiled the project before copying it.
He meant compiling project on new computer before opening form designer. (this is if you have user controls)
 
Back
Top Bottom