VStudio 2008: How to create simple console tool?

A

Axel Dahmen

Hi,

I've created a few simple console tools. No .NET used at all, just STL.

Now I want to just XCOPY them to another machine. But running them there yields a couple of errors in the application log telling me that some ..NET DLL could not be found:


"The application has failed to start because its side-by-side configuration is incorrect.
Please see the application event log for more details."

The application log says:

"Activation context generation failed for "D:\Documents\MyTools\SomeTool.exe". Dependent Assembly Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis."


I learned that this error occurs because of missing .NET runtime files on the target machine. But I DON'T want to install .NET on the target machine. I'm *intentionally* just using common API and STL functions.

Can someone please enlighten me on how to set up a VC++ project to don't use .NET at all?

I just want to create some simple DOS tools that I can put on my USB stick to help me with my daily work.

TIA,
Axel Dahmen
 
G

Giovanni Dicanio

Try static linking CRT.

Giovanni

"Axel Dahmen" <[email protected]> ha scritto nel messaggio
Hi,

I've created a few simple console tools. No .NET used at all, just STL.

Now I want to just XCOPY them to another machine. But running them there
yields a couple of errors in the application log telling me that some .NET
DLL could not be found:


"The application has failed to start because its side-by-side configuration
is incorrect.
Please see the application event log for more details."

The application log says:

"Activation context generation failed for
"D:\Documents\MyTools\SomeTool.exe". Dependent Assembly
Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
could not be found. Please use sxstrace.exe for detailed diagnosis."


I learned that this error occurs because of missing .NET runtime files on
the target machine. But I DON'T want to install .NET on the target machine.
I'm *intentionally* just using common API and STL functions.

Can someone please enlighten me on how to set up a VC++ project to don't use
..NET at all?

I just want to create some simple DOS tools that I can put on my USB stick
to help me with my daily work.

TIA,
Axel Dahmen
 
G

Giovanni Dicanio

Giovanni Dicanio said:
Try static linking CRT.

i.e. :

Select project properties, then navigate here:

Configuration Properties | C/C++ | Code Generation

and select:

Runtime library = Multi-threaded (/MT)

(or use /MT option from command line).

In this way, you will have just a simple .exe that you can distribute.

Giovanni
 
S

SvenC

Hi Axel,
I've created a few simple console tools. No .NET used at all, just
STL.
Now I want to just XCOPY them to another machine. But running them
there yields a couple of errors in the application log telling me
that some .NET DLL could not be found: ....
"Activation context generation failed for
"D:\Documents\MyTools\SomeTool.exe". Dependent Assembly
Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
could not be found. Please use sxstrace.exe for detailed diagnosis."

Where does the error talk about .Net?
I learned that this error occurs because of missing .NET runtime
files on the target machine.

Where did you learn that? You have been taught wrong!
The above microsoft.vc90.crt is the C++ runtime, a native dll which
is needed when you link to the CRT dll instead of static linkage
Please learn the differences of native and managed VC++ more
carefully and you will have much less trouble ;-)
But I DON'T want to install .NET on the
target machine. I'm *intentionally* just using common API and STL
functions.
Can someone please enlighten me on how to set up a VC++ project to
don't use .NET at all?

Change your VC++ project settings to use static linkage:

General settings:
- Use of MFC "Standard Windows" or "Static Library"
- Use of ATL "Not using ATL" or "Static Link"
- Common Language Runtime (this is .Net!) "No Common Language Runtime"

C/C++/Code Generation:
- Runtime Library (this causes your above error!) "Multi-threaded" or
"Multi-threaded Debug" depending on the Build Configuration you are
configuring "Release" or "Debug"
 
A

Axel Dahmen

Thanks, Giovanni and Sven, a lot for enlightening me and helping me out with the appropriate settings!!

Sven,
yes you're perfectly right. My mistake. I apologize for having been ignorant on the details of SxS... I must have got something wrong when reading about "assemblies" and the syntax of how the CRT file is referenced in the event log.

I've now found a very helpful blog on SxS on MSDN which I'm just reading into:

http://blogs.msdn.com/dsvc/archive/2008/08/07/part-1-troubleshooting-vc-side-by-side-problems.aspx

Thanks again to both of you for being a valuable help on my problem.

Best regards,
Axel Dahmen



PS: I've posted this reply once before, but there seems to be a problem with Windows Mail on Vista. It sometimes doesn't download my own replies from the newsgroup. So it's impossible for me to see if my reply actually reached the newsgroup at all. That's why I'm re-posting now...






-----------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top