solving program corruption in c#, VS2008

I have written a c# com-enabled dll using VS2008.  The dll works fine.

However, in recent attempts to add to the dll, I am getting strange things that I believe are caused by some sort of corruption.

In essence, when I add variables to a method, they will not instanstiate, though the original variables are fine.  For example, in this code snippet,

        [ComVisible(true)]
        public int CreateXML(ref string ErrMess)
        {
            string phase = "";
            string whatever = "";

            try
            {
                whatever = "1";
                MessageBox.Show("Remove this readxml which is for testing changes only");
                this.ReadXML();

if you hover over "phase" or look at it in the immediate window it is instantiated and holds the value of an empty string.

If you hover or "whatever" you get nothing, and the immediate window returns "The name 'whatever' does not exist in the current contextt".

This probelm occurs on at least two different methods within the dll.

I have tried a Clean then Build without any luck.  I have compeletely deleted the bin folders and then done a Build, no luck.  I have tried writing a new method, no luck.  I have done the same for the app that calls the dll, no luck.

Any thoughts?

Thank you
LVL 4
g_johnsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

andrewjbCommented:
Are you trying to debug a debug build or a release build? How are you doing the debuggin... what project(s) are open in your IDE... the calling app, and/or the target dll?
0
g_johnsonAuthor Commented:
I am debugging a debug build.  Both the calling app and the dll are open in the IDE -- the only two projects in the solution.  

I'm not sure what you mean by "how are you doing the debugging?" but I set a breakpoint in the code, for example, at "whatever = 1" then check the immediate value of the variables.  If I hover over "phase" in the above, or check it in the immediate window, it's fine (that's an original variabble).  For "whatever", it does not exist.

Thanks.
0
andrewjbCommented:
It sounds very much like you're referencing an old version of the dll, thus the source code isn't matching the target dll.

Check the references in the main app, where it references the dll... make sure it's pointing to the correct location of the (debug build) dll output. Perhaps even remove the reference then add again, making sure you add it from the 'projects' tab in references.

When running, if you open up the Modules debug window that also shows you the path names of the dlls that have been loaded... Try checking that to see you're looking at the right binary.

If you add some debug e.g. Console.WriteLine(..) or something in your app, does that get run? Shove a messageBox.Show(..) in the middle of the function to make sure a 'build' really does recompile the source code.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
andrewjbCommented:
Oohh.. Try a 'clean' then check that the .pdb files have also been removed (and delete if not) in case they're corrupted somehow. Then rebuild..
0
g_johnsonAuthor Commented:
Excellent.  Thank you very, very much!  I deleted the reference and then added it back in and the problem was solved.  It was very strange, because some things were working (such as adding in a message box, certain other variables), but most weren't.  Thanks again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.