hanumanth

Hi all,

I just want to compile a vc++ file byrunning a C# project.

and the code I written is

using System;

using System.Diagnostics;

using System.ComponentModel;

namespace process

{

class Myprocess

{

//

void ExecuteAppStartInfo()

{

ProcessStartInfo info=new ProcessStartInfo(@"C:\Program Files\Microsoft Visual Studio.NET\VC7\bin\cl.exe", @"D:\ws\samp.cpp");

Process.Start (info);

}

static int Main()

{

string Applicationpath;

// Console.WriteLine ( "Enter the path of your Application");

// Applicationpath=Console.ReadLine ();

Myprocess p=new Myprocess ();

p.ExecuteAppStartInfo();

Console.ReadLine ();

return 0;

}

}

}

here I am getting the error

An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in system.dll

Additional information: The system cannot find the file specified

The path I had given is valid.

plz reply how to fix this..




Re: Visual C# Express Edition runtime error

JGrove805

ProcessStartInfo info=new ProcessStartInfo(@"C:\Program Files\Microsoft Visual Studio.NET\VC7\bin\cl.exe", @"D:\ws\samp.cpp");

Are you passing @"D:\ws\samp.cpp" as a value to be passed

One parameter of Process.Start is the program to launch, the second parameter is sending command line arguments to whatever you are starting. If this is what you are in fact doing, there is no need to even uses ProcessStartInfo at all.

Try this.

Process.Start(@"C:\Program Files\Microsoft Visual Studio.NET\VC7\bin\cl.exe", @"D:\ws\samp.cpp");






Re: Visual C# Express Edition runtime error

Figo Fei - MSFT

Hi,

Regardless of other reference in the sourcecode, you can do like this:

Process p = new Process();
            ProcessStartInfo info = new ProcessStartInfo
                ("cmd.exe", @"%comspec% /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86_ia64");
            info.UseShellExecute = false;
            info.RedirectStandardOutput = true;
            info.RedirectStandardInput = true;
            p.StartInfo = info;
            p.Start();
            p.StandardInput.WriteLine("cl.exe d:\\vc.cpp");

Second line is used to execute the batch program to config environment variable (and if you have references in the source code you should add other settings to the info)

Last line is to do the compile work.

It works.

Thanks






Re: Visual C# Express Edition runtime error

hanumanth9

Hi,

Thanks for ur reply

I tried as u suggested.Then I am getting

this fatal error c1083:can not openinclude file 'assert.h' no such file or directory.

plz reply how to fix.

Here I have one more doubt.

suppose the VC++ project contains more cpp files then how to compile whole project at once

plz reply

thanks






Re: Visual C# Express Edition runtime error

hanumanth9

Hi,

As u suggested in previous mail,

I searched vcvarsall.batin my system mthere is no such file.I am using .NET 2002.can u tell me what is x86_ia64..

and in the last line u mentioned

p.StandardInput.WriteLine("cl.exe d:\\vc.cpp");

I think it will compile the specified vc.cpp file.

If I want to compile the whole project which contains 30 files..

can I do like this

p.StandardInput.WriteLine("cl.exe d:\\vc.vcproj");

If it is wrong plz tell me the correct solution.

Thanks






Re: Visual C# Express Edition runtime error

Figo Fei - MSFT

Hi,

I'm doing this in the VS2005 so far. vcvarsall.bat is a batch program (all about calling it is format issue) provided by VS 2005 to do the config.

Otherwise, you must add some evironment variables mannually.

Because when you compile a source code it may including other head file or reference, so you can not compile it successfully without reference infomation about evironment configration.

And as far as I know, *.vcproj is for VS editing, but not a source code, so, you can't compile it by cl.exe.

About how to compile VC++ project, It seems more related to this forum: Visual C++

Thanks