Visual Studio keeps temporary intermediate files which it doesn't handle very well sometimes.
And every now and then if you have a Solution with multiple projects - as is recommended by good practices - VS ends up with two copies of intermediate files for the same project - and it ends
up complaining about designer generated code like this:
protected MyWalletBL.Branch Branch;
Saying that the class is different on the two sides of the equals sign - which is blatantly untrue!
What has happened is that somehow, VS has got confused and is using two different intermediate files with slightly different class signatures (even if you haven't changed the class)
and doesn't know what to do.
So when you try to open the form, it throws up it's electronic hands, and collapses.
Stop right where you are. Do not do anything else: VS is in a fragile state right now, and could easily start to corrupt stuff.
It's actually pretty simple to fix:
- Remove all inter-project references.
- Clean solution. (I don't think this does anything useful here, but it can't hurt) This does not get rid of the intermediate files.
- Close VS. Wait until it is completely gone, the disk has stopped rattling, etc.
- Delete the intermediate files. Where are they? Here on my PC:
Which means they will be under your user name - but be aware than AppData is a hidden folder, so you will probably be best creating a shortcut to this location using your username. I find that once this problem crops up, it will be back, and back, and back...
Delete everything in that folder. All the files (shouldn't be any). All the folders. If you can't delete a folder, then VS is still running. Find it. Kill it. Try again.
- Restart VS
- Re-instate the references, and rebuild the solution.
Points of Interest
There are times when I hate VS...