473,385 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

CSharp Compiler / Interpretor

Hello,

I need to use Csharp compiler and an interpretor. In my application user
will use the application and application will write CSharp code on backend.
But now i don't need to reinvent the wheel, just need to know how i can give
user an option to build the project which will compile and make an
executable file.

thanks.
Nov 15 '05 #1
9 1704
Azeem M. Suleman wrote:
Hello,

I need to use Csharp compiler and an interpretor. In my application
user will use the application and application will write CSharp code
on backend. But now i don't need to reinvent the wheel, just need to
know how i can give user an option to build the project which will
compile and make an executable file.

thanks.


Check out the Microsoft.CSharp.Compiler class.

- Pete
Nov 15 '05 #2
Hi Azeem,

Check out Microsoft.CSharp.Compiler class.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
"Azeem M. Suleman" <as******@vercom.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...> Hello,

I need to use Csharp compiler and an interpretor. In my application user
will use the application and application will write CSharp code on backend. But now i don't need to reinvent the wheel, just need to know how i can give user an option to build the project which will compile and make an
executable file.

thanks.

Nov 15 '05 #3
Yeah i looked on msdn, is their any implementation sample for it. Like for
basic idea i found this article:

http://support.microsoft.com/default...NoWebContent=1

But it didn't compile windows form and other controls.

Thanks.
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:uQ****************@tk2msftngp13.phx.gbl...
Hi Azeem,

Check out Microsoft.CSharp.Compiler class.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
"Azeem M. Suleman" <as******@vercom.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...> Hello,

I need to use Csharp compiler and an interpretor. In my application user
will use the application and application will write CSharp code on

backend.
But now i don't need to reinvent the wheel, just need to know how i can

give
user an option to build the project which will compile and make an
executable file.

thanks.


Nov 15 '05 #4
Hi,

You'll have to specify parameters.ReferencedAssemblies to let compiler knows
which assemblies you reference in your code.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Azeem M. Suleman" <as******@vercom.com> wrote in message
news:em****************@TK2MSFTNGP09.phx.gbl...
Yeah i looked on msdn, is their any implementation sample for it. Like for
basic idea i found this article:

http://support.microsoft.com/default...NoWebContent=1
But it didn't compile windows form and other controls.

Thanks.
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:uQ****************@tk2msftngp13.phx.gbl...
Hi Azeem,

Check out Microsoft.CSharp.Compiler class.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
"Azeem M. Suleman" <as******@vercom.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...> Hello,

I need to use Csharp compiler and an interpretor. In my application user will use the application and application will write CSharp code on

backend.
But now i don't need to reinvent the wheel, just need to know how i
can give
user an option to build the project which will compile and make an
executable file.

thanks.



Nov 15 '05 #5
Azeem M. Suleman wrote:
Yeah i looked on msdn, is their any implementation sample for it.
Like for basic idea i found this article:

http://support.microsoft.com/default...NoWebContent=1
But it didn't compile windows form and other controls.
Did you reference System.Windows.Forms.dll?

[snip]
Nov 15 '05 #6
Where to reference that dll, as i'm just using this code. Any sample...Here
is the concept code that i saw from the url:

private void button1_Click(object sender, System.EventArgs e)
{
CSharpCodeProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler icc = codeProvider.CreateCompiler();
string Output = "Output.exe";
Button ButtonObject = (Button) sender;

textBox2.Text = "";
System.CodeDom.Compiler.CompilerParameters parameters = new
CompilerParameters();
//Make sure we generate an EXE, not a DLL
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;
CompilerResults results =
icc.CompileAssemblyFromSource(parameters,textBox1. Text);

if (results.Errors.Count > 0)
{
textBox2.ForeColor = Color.Red;
foreach(CompilerError CompErr in results.Errors)
{
textBox2.Text = textBox2.Text +
"Line number " + CompErr.Line +
", Error Number: " + CompErr.ErrorNumber +
", '" + CompErr.ErrorText + ";" +
Environment.NewLine + Environment.NewLine;
}
}
else
{
//Successful Compile
textBox2.ForeColor = Color.Blue;
textBox2.Text = "Success!";
//If we clicked run then launch our EXE
if (ButtonObject.Text == "Run") Process.Start(Output);
}

"AirPete" <x@x.x> wrote in message
news:4u******************@newsread1.news.pas.earth link.net...
Azeem M. Suleman wrote:
Yeah i looked on msdn, is their any implementation sample for it.
Like for basic idea i found this article:

http://support.microsoft.com/default...NoWebContent=1

But it didn't compile windows form and other controls.


Did you reference System.Windows.Forms.dll?

[snip]

Nov 15 '05 #7
I found the solution.

I just added:

parameters.ReferencedAssemblies.Add("System.dll");

parameters.ReferencedAssemblies.Add("System.Drawin g.dll");

parameters.ReferencedAssemblies.Add"System.Windows .Forms.dll");

It works fine. But it always loads from command prompt. How to handle that.
I just need to pass C# code to compiler and generate executable in such a
way that no process can be seen.

Thanks.

"AirPete" <x@x.x> wrote in message
news:ev******************@newsread2.news.pas.earth link.net...
Azeem M. Suleman wrote:
Hello,

I need to use Csharp compiler and an interpretor. In my application
user will use the application and application will write CSharp code
on backend. But now i don't need to reinvent the wheel, just need to
know how i can give user an option to build the project which will
compile and make an executable file.

thanks.


Check out the Microsoft.CSharp.Compiler class.

- Pete

Nov 15 '05 #8
Azeem M. Suleman wrote:
I found the solution.

I just added:

parameters.ReferencedAssemblies.Add("System.dll");

parameters.ReferencedAssemblies.Add("System.Drawin g.dll");

parameters.ReferencedAssemblies.Add"System.Windows .Forms.dll");

It works fine. But it always loads from command prompt. How to handle
that. I just need to pass C# code to compiler and generate executable
in such a way that no process can be seen.
parameters.CompilerOptions = "/target:winexe";

Not tested, but should work.

- Pete

Thanks.

[snip]
Nov 15 '05 #9
What to do for multiple files. Like if i have 3 class files at different
places and they all are using objects of each others....what will be the
parameter.....

Thanks.

"AirPete" <x@x.x> wrote in message
news:VH******************@newsread1.news.pas.earth link.net...
Azeem M. Suleman wrote:
I found the solution.

I just added:

parameters.ReferencedAssemblies.Add("System.dll");

parameters.ReferencedAssemblies.Add("System.Drawin g.dll");

parameters.ReferencedAssemblies.Add"System.Windows .Forms.dll");

It works fine. But it always loads from command prompt. How to handle
that. I just need to pass C# code to compiler and generate executable
in such a way that no process can be seen.


parameters.CompilerOptions = "/target:winexe";

Not tested, but should work.

- Pete

Thanks.

[snip]

Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Balaji | last post by:
Hello Everyone.... I have created a simple GUI using wx python. Its an simple editor... Now what I want to do is pass the contents of this editor and receive solution from python. Suppose...
4
by: Sam74 | last post by:
Hi, I've downloaded framework 1.1 .net SDK from the microsoft webpage and i've seen that in the pakage there is the csharp compiler (csc.exe) If I develop a program with notebook and I compile it...
1
by: Azeem M. Suleman | last post by:
Hello, I need to use Csharp compiler and an interpretor. In my application user will use the application and application will write CSharp code on backend. But now i don't need to reinvent the...
0
by: Lee Alexander | last post by:
This isn't a CSharp language issue as such but this seemed the best place to put this :-) When compiling a CSharp application via DevStudio I want the IDE to still be responsive like when...
3
by: Alex | last post by:
Hi, The following article describes how to compile CSharp code programmatically http://support.microsoft.com/default.aspx? scid=http://support.microsoft.com:80/support/kb/articles/Q3...
5
by: Andy Sutorius | last post by:
Hi, I am attempting to convert this vb function to csharp but I am getting stuck on the if statement dt.Rows(iLoop)("FAQCategoryID")). The compiler says "method name expected" and underlines...
19
by: auratius | last post by:
http://www.auratius.co.za/CSharpCodingStandards.html Complete CSharp Coding Standards 1. Naming Conventions and Styles 2. Coding Practices 3. Project Settings and Project Structure 4....
4
by: Ed | last post by:
Hi, dear all, Here are some questions when I was writing CLI code, which would be used by C# Project. 1. Reference Parameter If CLI method have % reference type parameter, which is ref class,...
1
by: sunil | last post by:
Hello, I am working on a problem where I will have a boolean expression with upto four variables: A,B,C,D and connected by basic operator &&,||and may be XOR and NOT in future AND has higher...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.