Link to home
Start Free TrialLog in
Avatar of mojeaux
mojeauxFlag for United States of America

asked on

VISUAL STUDIO 2010 EXPRESS - DEBUG ISSUES WITH C PROGRAMS

Just throwing something out there because I'm at a loss.... No one seems to know or can fix my issue with Visual Studio 2010 express and professional trial:

I am creating C programs in the compiler.   I get a clean compile.  However when I  attempt to debug it, not so much.   It throws several errors and stops running my console.   It says that it is missing ntdll.dll, mscrv100d.dll, and another dll file whose name escapes me at the moment... or that it cant write to them.  I verified those files do exist.

I've tried setting my project up as an empty project, a win32 project, and a win32 console project.... and different setting variations... none of which worked.   I also tried running the app as an administrator (I am the admin on this machine but there are several profiles (3)).

Any ideas as to why VS is being such a pain in my rear?   Any suggestions would be gratefully appreciated.   Thanks! M
Avatar of Narendra Kumar S S
Narendra Kumar S S
Flag of India image

When you compile your code, it has just created an object file.
I think the problem that you are seeing is happening during linking.
After successfully linking the code to all the required libraries, an executable is created.
Then only you can run your code or debug it.

The reason for seeing the error "missing ntdll.dll, mscrv100d.dll" is,
the linker/debugger doesn't know where the dlls are located.
Or your system doesn't have these dlls.

So, search your system and see if these dlls are present.
If they are present, make sure that Visual Studio has this path in its default library path.
If they are not present, then try to download the dlls to C:\windows\system32,
and execute the command:
regsvr32.exe C:\windows\system32\ntdll.dll

After that, the Vistual Studio should not complain that the dlls are not found.
Avatar of mojeaux

ASKER

Thank you!   I will try this when I get home.   This is exciting!   I hope it works... I've beens struggling with this for two weeks and no one knew how to fix!    You are awesome!
Avatar of phoffric
phoffric

The problem could be an installation issue. When unusual things like this with standard downloadable products, rather than figure out how to make the installation right, I just uninstall the product first, and then reinstall. And then, in these cases, the product worked!

I notice that you mentioned both Express and the Professional Trial.

Although it is my understanding that various editions of MS Visual Studio can work together on the same computer, I have numerous problems with different combinations. I have several computers, and I no longer try to have different editions on the same computer.

I would uninstall all MS Visual Studio products. Then I would install just the Express version. Or, if you prefer, install the Professional Trial edition (although, possibly you may have a license issue since this is your 2nd installation on the same PC - but you can likely contact MS to explain the problem).

After you get the product installed, then write a simple Hello World program and run/debug it.

Good luck!
After uninstalling all MS Visual Studio products, you may consider the possibility that your OS is a little corrupt. Rolling back to a known working state is one approch. Here is one article from MS that suggests this:

http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_update/unable-to-find-rtlcopycontext-in-ntdlldll/afac51b2-9bb2-45c6-92e7-bad373264b7e

(Note: If rolling back a month or two, be sure to first uninstall any products that you installed between the rollback date and the present date.)

Good luck!
Avatar of mojeaux

ASKER

Hi All -
thank you for the helpful suggestions...
ssnkumar: I tried checking my default library in Visual Studio, but could not locate.  I followed the link that you provided and did the system scan.   Everything came back checked out ok, nothing corrupt or in need of repair.  I verified the DLL files do exist in the System32 direcotry.  I find that if I run a very simple program like hello world, it works.  However, if i add my own function to my program ... something other than printf or scanf... it does not work.

phoffric:  I'm currently not running both Express and Proffessional Trial... When Express did not work, I uninstalled it and then downloaded the Professional Trial version thinking there may be files in there that the Express did not load.   Not the case tho.   Still getting same results.   I'm hoping a restore would be a last resort as I have other programs, files, that would be lost from a roll back.

The errors below belong to a clean compiled program.  I'm attaching the debug screen shot for your review.  Thanks, Mojeaux

     User generated image User generated image
So, these errors are not telling that the concerned dlls are not found.
It gives error about "Access Violation".
And the error is coming for scanf_s() function.
Have you used this function in your code?
If you are having your code spread out in multiple files, are you linking all of them together?
Avatar of mojeaux

ASKER

Good morning,
It's had a problem with scanf or scan_s function.  When I use one, it recommends the other.

Not sure what you mean about multiple files.   Initially I was storing my project on a thumb drive so I could take it to the data center and work on it rather than continue to have issues at home.

I thought that it may have a problem with the location of the project (not being local), these last few projects i create on my C drive on the pc... but that did not have an impact on the outcome.

One note about the more recent error... the last project tht i created, I set up a litlle differently.   I chose the WIN32 Console option for C++, then chose 'empty project' to avoid getting all the header information (at the insistence of a coworker).  When I chose this option rather than Empty Project from the beginning... this is when I got the Access Violation.

Even when I run as Administrator, I still get the Access Violation.  

If you mean there are multiple files on my PC drive that need to be linked together... then no, I havent done that.   If you could be so kind as to share that information I would appreciate it.

Thanks for your help!  Mojeaux
When I say "Multiple Files", what I meant is, the source code that you have written.
Have you written all your functions (including main() function) in a single file
or
are you using more than one file - say main() function in file1, rest of the functions in file2.
If you are having multiple files, then you should include all of them in your project.
As far as the ntdll Window OS problem, sorry that I am unable to help further than what I wrote in your previous question.

>> It's had a problem with scanf or scan_s function.  When I use one, it recommends the other.
To disable MS fear warnings (which, btw, makes the code compile only using VS), just append
    ;_CRT_SECURE_NO_WARNINGS
to the project's Preprocessor Definitions property. The majority consensus here is that doing this is good. Now you can write standard C/C++ portable code.

In your picture, you are dereferencing pointer by setting *(char*)pointer to a value. Could you double check to verify that the pointed to region is a buffer that you defined and is not read-only.

In your previous question, you had similar difficulties in a simpler program. You got it to compile, but did you get that program to run correctly, and did the Debuger issues go away?
Avatar of mojeaux

ASKER

Good morning!

SSNKUMAR:  Everything is one one source code... I havent written other code which it calls in another location.  ... Maybe there are settings that tell it to look elsewhere?  Is this something I could change?

PHOFFRIC:  When I get home I will make these changes to night and let you know the outcome.   I have a question about the 'pointed to region'.   Not sure that I (knowingly) set anything up.   Where is the compiler thinking this buffer shoulld be?   Regarding the previous program.   with everyone's help I was able to compile, but the debug did not work on my machine.  

Thank you!!
ASKER CERTIFIED SOLUTION
Avatar of phoffric
phoffric

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mojeaux

ASKER

Thank you for your time and effort.   Sorry for the delay in my acceptance.   I took a few days away from it to gain a fresh perspective.   Will try your solution tonight.   If i get something weird, I will start a new thread.

Again, I really appreciate everyone's assistance!  Mojeaux
No apologies needed for delay in accepting. In fact, it is even better to test first (take your time) and verify that the suggestions actually bear fruit.