Why would building a program fail sometimes but not others, without any changes to the source or settings? Possibly defective hardware? - hardware

I recently built a large-ish open source program in Visual Studio 2013. Initially the build failed due to a couple errors (a C1900 and a LNK2019). These errors were quite puzzling since I was following clear, simple instructions for building the program. The main developer couldn't think of any good reasons why they would occur.
I turned off my laptop overnight and the next morning I reattempted the build with the intention of reproducing the errors. But to my great surprise, no errors. I did not change any of the source or any compiler settings, etc.
Later that day I decided to do another build, and I got the same errors as before. I shut down my laptop for a minute or so, turned it back on, tried building again and it worked.
Clearly this is really strange. I have reason to suspect that there is some faulty hardware in my laptop. Could that cause these mysterious disappearing errors?

Try this on another machine and see if you get the same results. If you do, you'll know it's not a hardware issue.
It's more probable that you don't have complete build steps provided by the other developer. If he only built/tested it on his computer, then he may have added/installed (and not documented) some other tools/scripts/libraries necessary for a successful build - that he doesn't even remember about. There could also be circular dependencies between the projects which prevent you from building in one step.
You should try and identify the relationships between the projects and then build them separately, until you find where the problem is. You start with those projects not having references on any other ones, and so on. Eventually, you'll find the 'problem' project, and it'll be easier to fix.

Related

visual studio 2013 local variables not showing in debugger

I have a solution written in VB with some C# components. The solution uses some libraries from 2 outside sources. I have been working on this project for several months without issue. I cannot identify anything specific that I did to change my system or configuration. I was just working through the code, transitioning from an old set of library calls to the new library calls. The new library calls require complete rewrite so I change sections of the code and test to that point. Visual Studio 2013 debugger as of Friday morning will no longer recognize or show my local variables in this solution. The only things that appear in the Locals window are under Me. The code does work and I have it writing out to a text log file to confirm the values of variables at certain points, but the debugger has gone blind. When I add any of these local variables to Watch the response is " is not declared. It may be inaccessible due to its protection level."
Steps I've taken so far with no permanent success:
looked online and tried the few matches I found with no success
deleted the bin and obj folders and had the solution rebuild with no
success
recreated solution from scratch, copied over base files and rebuilt
solution and project (which worked for a few hours), until I did a
rebuild project and problem appeared again
updated to pack 5 and no success
I have opened my older projects and checked them. The debugger runs just fine and shows the variables. It is obviously something that happens during the rebuild process.
Any assistance would be greatly appreciated.
Thanks
Update:
Let me try to explain a little more clearly the situation.
I have an application I have built and am selling to some customers. Version 1 is installed and running at several locations. It is written in VB and uses some older COM libraries for a particular integration process.
The vendor is retiring the COM libraries. Their new libraries are in C#.
I created a new copy of my entire application (solution) and imported the new C# libraries. I have been going through and replacing the old code with the code for the new calls.I recompiled the solution and everything ran fine in debug.
The objects used with the new calls are completely different and there is limited documentation so I update a section of code and test to that point. Each time I "Save all Files", rebuild the project and test the changes. Everything worked fine for a few days. On Friday morning I started working on more changes and got an odd error. The system was not getting a proper value for a certain variable. When I went to check it in the WATCH window, debugger said it could not evaluate it. I figured something was hung up so I shut everything down and rebooted my machine. When I tried it again later, the same problem.
After several hours of no success I exited VS, renamed the folder to "OLD" and recreated the solution from the older version. Immediately everything was looking fine. I started making the changes and testing. Each time I did a rebuild, everything looked fine until the last change. Here I am again.
The code works fine up to the point I have updated. The only issue is that the debugger windows are not working correctly. If a variable is declared at the Class level outside the Sub, they can be seen. The only variables the debugger is blind to are the local variables within the running Sub.
I looked for anyone else with this issue and only found a few items. I tried the suggestions but no joy. I am left with having to temporarily define the variables outside the sub so I can see them while debugging.
I am on VS 2013 Update 5.
Do I need to move to VS 2015 to get around this?
Thanks again for your time and assistance.
I am assuming that you haven't changed versions of visual studio since the last time a rebuild worked for you.
recreated solution from scratch, copied over base files and rebuilt solution and project (which worked for a few hours), until I did a rebuild project and problem appeared again
Based on this, you create it from scratch and everything works until you do the rebuild right? But you are copying the base files still and you have new library calls since the last time a rebuild didn't mess up the locals window. So one of those is almost assuredly the culprit.
Since the library calls seem to be the thing that changed based on your post start there. If you go back to the old code and do a rebuild does it fix it? Assuming so, put the library calls back one at a time until it breaks.
If going back to the old code doesn't fix it, create from scratch with the old code and copy over the base files and rebuild. If that fixes it, add new library calls one at a time and rebuild after each until it breaks.
If that doesn't fix it either, then you will need to dig deeper on what else might have changed.
You are copying base files so eliminate those as the problem if you can:
Are you able to use placeholders instead of the base files or something that won't necessarily work as a finished product but that will allow you to debug, rebuild, debug again to see if the problem is related to one of them? Check the dates on the base files and ensure that they haven't changed since the last time a rebuild worked.
Something you could do concurrently could be to have have a colleague do a rebuild on their machine and see if the same issue comes up for them. It would (almost) completely eliminate the possibility that it is a configuration / program corruption issue on yours. Alternately, there are some free vb.net compilers online that you can upload files and code to. I'm not sure if that would be practical for you (due to the components of your program and/or sensitivity of the data) or not and haven't ever tried any where there is C# code in there but I wouldn't think that would be an issue.

Visual Studio keeps looking for .resx files in the wrong place

I am working with visual studio 2012, and my problem occurs in a large, old winforms application solution when I try to compile the whole application (dozens of projects).
When I get the latest code from source control (Team Foundation Server) for the first time, and build the solution, it builds just fine the first time. Then, if I make any changes, a later Build/Rebuild, will sometimes (not always) result in lots of projects in the solution throwing the following error for some of its resx files.
Unable to create a manifest resource name for "Contracts\Templates\ContractTemplateDb.resx". Could not find a part of the path 'C:\Windows\system32\Contracts\Templates\ContractTemplateDb.vb'
OR
Invalid Resx file. Could not find a part of the path 'C:\Windows\system32\NeptuneForms\HelpForm.resx'.
The problem is that there is no reason it should be looking in C:\Windows\system32 for these files, as they exist fine (and did during the last build) in the local directory of the project! The random directory is not always C:\Windows\system32, sometimes it is a random directory of another project, or even in another branch.
This happens sporadically to some of our developers, frequently to others, and almost always to me, and it seems unrelated to the code we are writing, because when it happened, I rolled back all the changes we had made since it started happening, and it still happened.
There are two things I've tried, that had no success.
Recreate the entire solution, and remove and readd all resource files as though they never existed before.
Install all windows updates and get the latest updates to Visual Studio 2012
Nothing has helped, and I am at a loss. My next step is to upgrade to 2013 and hope for the best, but I'm afraid thats not going to help either.
Does anyone have any similar experience, or any ideas of other things to try? I'm pulling my hair out over this one...

Always Cleaning / Building Project on Debug

I have a rather large solution of about 20 projects, that I have worked with for about three years now. In recent weeks, I seemed to have lost the ability to just press "Run and Debug" on my toolbar. If I do this, I lose all ability to debug and use breakpoints. My breakpoints all get a little yellow exclamation point on them and never run. Below is an example.
To fix this so I can get debugging again I have to fully clean the project. If I try to run after cleaning, i get an error saying the file does not exist. So I have to then fully re-build the project before I can run. It works just once, and then I lose my ability to debug again. Below is the error if I don't manually build first:
This seems to be effecting several (maybe all) projects in my solution and is causing extremely large problems for me. Some of my projects I need to breakpoints to verify data before it runs, and if I forget to do this, it runs before verifying.
Any help in fixing this would be amazing. Under solution settings, my start up project i set to "Current Selection" if that helps.
UPDATE:
So far under solution settings -> configuration a bunch of my items had "Build" not selected for Debug. Not sure how that happened, but updating that for now seems to have solved it. If it goes to not building each time again I will re-update, but for now I think that solved the issue.

VS2008 "must implement" fake errors?

I have a VS 2008 VB.NET Solution, which is quite large. Every once in a while, if I take latest code from source control, I get hundreds of errors. These aren't real errors. They are all about classes not implementing functions/events from interfaces (which they DO implement).
"Class [class name] must implement [event or function name] for interface [interface name]"
I usually end up spending couple of hours doing a combination of: building/rebuilding the solution project by project, cleaning the solution, deleting everything locally, taking latest... etc. At some point, everything just magically builds. Does anyone have any idea what is causing this? Other people on my team experience this as well. I do not see any circular references.
Yes, I've been there.
The root of the problem is that some projects are trying to build and they are dependent on the dll's that other projects generate.
You can solve this by modifying the build order of your projects.
Once you do this, everything should work fine on the first build attempt after check out.
I've seen it as well.
I think it's related to some of the metadata/files Visual studio keeps around..my running theory is that VS isn't refreshing it's internal stuff when you do the latest pull from source control. Thus it tries to do a build, it thinks some files haven't been "updated" (thus it has an old intermediate object file lying around it uses instead) gets confused, and fails.
Generally doing a combination of Build->Clean Solution, Build->Build Solution solves it most of the time. I have, twice, had to blow away the entire build directory and pull a fresh copy from source control (Clearcase) and do a fresh build.
Edit: I have Clearcase integrated with VS2008, and do my checkouts/checkins/version history from within VS2008. Not sure if using the standalone windows tool would solve this issue, and haven't the time to test (not to mention being unable to reproduce the error consistantly)
Edit2: When i say twice, i mean twice in the last 12 months or so.

What causes difference in VB6 app testing result when running from Dev machine vs installed?

I'm new to VB6 but i'm currently in charge of maintaining a horror of editor like tool with plenty of forms, classes, modules and 3rd party tools all chunk together like the skin faces on that guy in the texas chainsaw massacre...
What i don't understand is why i get different results when i run the app in debugging mode, vs when i compiled it and run it on my devevelopment pc vs when i installed it on a different pc.
Yes i know i'm dumb, so please direct me to where i can find out more about this. I'm hoping to find out something like different linking, registry related etc connection that i'm simply not getting right now, i.e. something like wax on, wax off :P
The main pain in the neck is when i'm trying to debug some errors from my QA and i need to find a spare pc to test this on plus i can't directly debug because i don't know where the code is if i do it that manner.
Thanks.
i run the app in debugging mode vs when i compiled it and run it on my
devevelopment pc
When you compile you have the option of compiling to native code or pcode. The debugger runs using pcode only. Under rare circumstances when you compile to native code there will be a change in behavior. This particular is really rare. I used VB6 since it's release and I may get it once or twice a year. My application is a complex CAD/CAM creating shapes and running metal cutting machine and has two dozen DLLs. Not a typical situation. At home with my hobby software I never ran into this problem.
There are another class of errors that result from event sequencing problems. While VB6 isn't truly multi-tasking it has the ability to jump out of the current code block to process a event. If it re-enters the same block for the new event interesting things (to say the least) can result. I think this is the likely source of your problems as you software is an editor which is a highly interactive type of software.
In general the problem is fixed by reordering the effected areas. You find the effected area by inserting MsgBox or write to a text file to log where you are. I recommend logging to a text file as MsgBox tend to alter behavior that are timing or multi-tasking related.
Remember if a event fire while VB6 in the middle of a code block and there a DoEvents floating around then it will leave the code block process the event and return to the original code block. If it re-enters the same code block and you didn't mean for this to happen then you will have problems. And you will have different problems on different computers as the timing will be different for each.
The easiest way to deal with this type of issues is create some flag variables. In multi-tasking parlance they are known as semaphores or mutexes. WHen you enter a critical section of code, you set it true. When you leave the routine you set it to false. If it is already true when you enter that section of code you don't execute it.
when i installed it on a different pc.
These are usually the result of the wrong DLL installed. Most likely you have an older version while the target has a newer version. I would download the free Virtual PC and create a clean Window XP install to double check this.
If your problem is event timing this too can be different on different computers. This is found by logging (not MsgBox) suspect regions.
If you can display a screen shot or the text of your specific errors then I can help better.
The first thing to check would be the versions of all the dlls that your app depends on - including the service pack version of the VB6 dll.
Have you any more specific details about what's behaving differently?