Solution Keeps Corrupting - Please Help

  • Thread starter Thread starter Paul [Paradise Solutions]
  • Start date Start date
P

Paul [Paradise Solutions]

Just recently, the solution file will corrupt on my system and make all
procedure names disappear from the dropdowns (VB.Net against the CF),
project references break and and "Unspecified errors" appear in the
tasklist (Have since learnt that these errors relate to the form designer):

Main solution located in ...\My Documents\Projects\ProductA\MainApp

Add a reference to a project containing only forms located at \My
Documents\Projects\ProductA\ClassLibrary

Save project, close solution. Re-open solution - all OK so far. Now
add another reference to a class library of common functions located in
\My Documents\Projects\Tools\CommonFunctions

Still all OK. Now save and close. At this point when the project is
reopened, the above faults occurr.

Can anyone shed any light on this as my solution corrupts every time I
open it.


Paul
 
Hi Paul,

This happened to me once. I'm not sure it's the same thing, but here
is what happened :

I created a form (or class, can't remember) called SomeClass. Worked
on it for a while, then decided to start over from scratch. I created
a folder named "old stuff", dropped the class inside that folder and
forgot about it.

A few hours later, I created a new form/class in the main folder, with
the same name. Everything went fine, I saved the solution, loaded it
back, and had all sorts of problems : controls disappearing, methods
going nuts... It appears that in some weird combinations of class
names and subfolders, VS is unable to warn you that two forms/classes
have the same name, and gets the two mixed up.

Sorry I can't post an exact repro of the combination involved, but you
could try looking into that direction. Maybe some duplicate names with
your CommonFunctions lib?

HTH,

Michel
 
Thanks for the response - although I did have duplicate file/class
names, they have now been dealt with (as far as I can see) but the
problem still remains. If VS can't determin difference between 2 files
and thier repective projects, that would imply a severe scoping issue,
would it not?

Paul
 
Hi Paul,

I don't believe it's a scoping issue but the effect of the natural
programmer's laziness. We tend to avoid fully qualifying names when we
write code, because it is so much easier, and sometimes we end up with
confusing situations.

The power given to us programmers - remember that, seen from the IDE,
we are only the ever-stupid users - means that we DO have the
possibility to utterly confuse VS. We can declare a class with some
name, then a label with the same name, then move this class to another
project, then create a new class with the same name, and a Dataset
with yet again the same name, move them to another folder, perform a
global "Search and Replace", move the files around a bit more... After
a while, if you're not over-cautious with your naming habits, you CAN
- and probably WILL - end up with confusing situations (for instance,
it is very logical to call a Dataset "people" when that Dataset deals
with people, but then you'll be tempted to name it's helper class
"people" as well, because that class also deals with people. I know
it's annoying, but I stick with "dsPeople", "clsPeople", "xmlPeople",
and so on).

In your case, my guess is that you still have duplicate names,
somehow. When loading a project, the IDE cannot warn you nicely like
it does when you compile/deploy a project : if it sees
duplicate/ambiguous names, it has to handle them in any way it sees
fit, and that often means removing one of the references. Remember
that it can remove object/methods from your code, because as much as
it can generate code, it can also remove it (that is what it does when
you remove a control from the designer : it removes the corresponding
lines of code from the code-behind).

Try the old dichotomy stuff : remove half your files from the project
(set them aside in another folder), try opening your solution. Simply
ignore the error messages about missing references, and check whether
methods/objects keep disappearing. If they do, then remove half of
what's left, until everyting seems fine. Then the problem lies in the
last files you moved away. Oh, and BACKUP FIRST. NOW. I'M NOT KIDDING.
Again, VS has a licence to change your code any way it sees fit, and
it WILL do it in what it thinks is your best interest.

Alternately, open your files one by one in the IDE, then two by two,
four by four... until the problem arises.

I know how frustrating this must be, I do hope you find a solution. Is
your project very large? If it's not, maybe you could try sending it
as an attachment so that we can look at it. Often, the simple process
of removing the passwords/bits you don't want other people to peek
around, in other to post a clean repro, will help you pinpoint the
problem.

HTH,

Michel
 
Oh, I found another possible explanation (the hard way).

Here is what happened. I have a solution with two projects : one for
Pocket PC (the "pocket app"), and one for the full framework (the
"desktop app").

The desktop app allows me to create/edit XMLs that are in turn
consumed by the pocket app (after deployment). I had written the
desktop app three days ago ; it ran fine, so I unchecked the
"Generate" option in the Generation Options dialog and promptly forgot
about it.

Then, this afternoon, I stumbled upon the XML/default empty string
bu... I mean issue, and had to go back to the desktop app to write
some code around it. I typed Ctrl-F5, and had a
"NullReferenceException" thrown at me. I checked, and the dataset I
had added visually in the designer was gone. Some of the lines of code
had gone as well (that's where it looks a bit like your problem). I
tried to add it back, and the IDE warned me it couldn't add it because
there already was an object with that name (there wasn't). I decided
to trace the code, hit F5... Everything went well for the few lines of
code, then suddendly, the trace skipped like 8 lines and went straight
to the end of the method. I traced a bit more, and the trace pointer
was going awry, skipping lines, going backwards...

I took me a while (read : 4 hours) to figure it out : everytime I hit
F5, the project wasn't generated, as I had specifically unchecked the
auto-generation.

It caused all sorts of very weird symptoms, the dataset not being
initialized, variables not showing up, code being overwritten or
deleted, depending on whether I opened the code form the designer (F7)
or the designer from the code (Shift-F7).

I then remembered the Generate option, checked it, and everything went
fine after that.

That might be another lead for you...

HTH,

Michel
 
Hi

"Be vewy, vewy quiet.... it's NamingConvention season.. eheheheh..."

Took your advice and worked through my solution again (6 projects, many
files..). After four hours I finally have a stable solution file again...
Can't say how in debt to you I am for the pointer (a-la "This button
Stupid!!!" from Roger Rabbit). I'm still not 100% sure of the cause,
but going through ensuring unique class names across different projects
did it.
There was still a certain amount or 'reminent screwyness' but that
cleared after compiled, delpoyed and ran.

Again, many thanks.


Paul
 
Back
Top