stdafx.h missing


I have started a job where I need to understand some C++/CLI code another person has written with Visual Studio in order to port the code to another language ( either C# or Java). I am a relative newbie in Visual Studio and C++/CLI stuff so if I am asking an "easy" question bare with me.

The problem is this, I have created a new project from existing code with Visual Studio 2008 Pro and when I try to build it I get notifications that a file called stdafx.h is missing. From what I understand this file is something Visual Studio creates automatically? Nowhere in the code files I have is there such a file in existence. If I comment this header file out from the various source files, I am left with a gazillion of error messages such as:
error C2039: 'Xml' : is not a member of 'System'
error C2871: 'Xml' : a namespace with this name does not exist
Is there an easy way to bypass the problem? Can I get the stdafx.h file from somewhere, ie. is it a standard file OR was it created dynamically when the person in charge of this code was writing his code. I am not sure whether I can get the coders original stdafx.h file if indeed the file is still around, since he is no longer with the company. Or did I perhaps do some mistake when creating the project from the existing code?

Best regards,


  • I managed to circumvent the problem, although I am not sure what exactly I did right. I created a new clr console program, then copied the source/header files one by one into it. This did the trick. The stdafx.h file was created automatically in the new project and it is empty. Everything works like a charm, so I guess I made a mistake when I created the project directly from the source files earlier.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion