Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 2nd, 2004, 08:34 PM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default Compile method (Compiler class)

Hi!

I am, trying to make my program compile in run time an external array of string (C# code).I read that I could use the compile method of the Compiler class Microsoft.CSharp namespace.So why isn't this working?

(comp.cs)

using System;
using Microsoft.CSharp;

class DeclareArraysSample
{
    public static void Main() {
    string[] codigo = new string[14];
    string[] nomes = new string[14];

    codigo[0] = "using System;";
    codigo[1] = "class DeclareArraysSample";
    codigo[2] = "{";
    codigo[3] = " public static void Main()";
    codigo[4] = " {";
    codigo[5] = " // Declarar Array-of-arrays (jagged array)";
    codigo[6] = " byte[][] Nos = new byte[11][];";
    codigo[7] = " for (int x = 0; x < Nos.Length; x++) ";
    codigo = " {";
    codigo[9] = " Nos[x] = new byte[1];";
    codigo[10] = " }";
    codigo[11] = " Console.WriteLine('Nos-length: {0}',Nos.Length);";
    codigo[12] = " };"
    codigo[13] = "};"

    nomes[0] = "Linha 0";
    nomes[1] = "Linha 1";
    nomes[2] = "Linha 2";
    nomes[3] = "Linha 3";
    nomes[4] = "Linha 4";
    nomes[5] = "Linha 5";
    nomes[6] = "Linha 6";
    nomes[7] = "Linha 7";
    nomes = "Linha 8";
    nomes[9] = "Linha 9";
    nomes[10] = "Linha 10";
    nomes[11] = "Linha 11";
    nomes[10] = "Linha 12";
    nomes[11] = "Linha 13";

    Compiler.Compile(codigo,nomes,"sdCOMPILADO.exe",nu ll,null);
    }
}

 
Old November 4th, 2004, 12:06 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hello,
these two links might help you,
http://www.codeproject.com/dotnet/Co...ithCodeDom.asp
http://www.codeproject.com/dotnet/CodeFromCode.asp

--------------------------------------------
Mehdi.:)
 
Old November 11th, 2004, 01:19 PM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

it helped!! THKS!! :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can’t add method to class in C#? arbab BOOK: Beginning C# 2005 Databases 0 September 29th, 2008 07:35 AM
unable to compile class file derricktancf JSP Basics 0 November 1st, 2006 04:42 AM
I am not able to compile my Action class vivekkumar_23 Struts 2 May 4th, 2006 09:09 AM
Method calls within same class w/Interface gmontanaro C# 0 April 6th, 2006 05:44 PM
URGENT - Unable to compile class for jsp Black Balloon Apache Tomcat 6 August 27th, 2004 06:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.