Hi,
The following error occurred when i programmaticall y compile another project from my present project.
The Error:
error CS0234:The type or namespace name 'Windows' does not exist in the namespace 'System' <are you missing an assembly reference>
The Source Code:
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
using Microsoft.CShar p;
using System.CodeDom. Compiler;
using System.Reflecti on;
using System.Diagnost ics;
using System.IO;
using System.Globaliz ation;
namespace Compile2
{
class Class2
{
/// <summary>
/// The main entry point for the application.
/// </summary>
public bool CompileExecutab le(String sourceName)
{
FileInfo sourceFile = new FileInfo(source Name);
//CodeDomProvider provider = null;
CSharpCodeProvi der provider = new CSharpCodeProvi der();
ICodeCompiler compiler = provider.Create Compiler();
bool compileOk = false;
// provider = new Microsoft.CShar p.CSharpCodePro vider();
if (provider != null)
{
// Format the executable file name.
// Build the output assembly path using the current directory
// and <source>_cs.e xe or <source>_vb.exe .
String exeName = String.Format(@ "{0}\{1}.ex e",
System.Environm ent.CurrentDire ctory,
sourceFile.Name .Replace(".", "_"));
string[] Myref ={ "System.dll","S ystem.Drawing.d ll"};//,"System.Window s.Forms.dll","S ystem.Collectio ns.Generic.dll" ,"System.Compon entModel.dll"," System.Data.dll ","System.Drawi ng.dll","System .Text.dll" };
string MyAsm = "MyAsm.dll" ;
// CompilerParamet ers cp = new CompilerParamet ers(Myref, MyAsm);
CompilerParamet ers cp = new CompilerParamet ers();
// Generate an executable instead of
// a class library.
cp.GenerateExec utable = true;
// Specify the assembly file name to generate.
cp.OutputAssemb ly = exeName;
// Save the assembly as a physical file.
cp.GenerateInMe mory = false;
// Set whether to treat all warnings as errors.
cp.TreatWarning sAsErrors = false;
// Invoke compilation of the source file.
CompilerResults cr = compiler.Compil eAssemblyFromFi le(cp, sourceName);
//CompilerResults cr = new CompilerResults ();
if (cr.Errors.Coun t > 0)
{
// Display compilation errors.
Console.WriteLi ne("Errors building {0} into {1}",
sourceName, cr.PathToAssemb ly);
foreach (CompilerError ce in cr.Errors)
{
Console.WriteLi ne(" {0}", ce.ToString());
Console.WriteLi ne();
}
}
else
{
// Display a successful compilation message.
Console.WriteLi ne("Source {0} built into {1} successfully.",
sourceName, cr.PathToAssemb ly);
}
// Return the results of the compilation.
if (cr.Errors.Coun t > 0)
{
compileOk = false;
}
else
{
compileOk = true;
}
}
return compileOk;
}
}
class Program
{
static void Main(string[] args)
{
Class2 c2 = new Class2();
c2.CompileExecu table("C:\\temp 4\\temp4\\Progr am.cs");
Console.WriteLi ne("hai");
Console.Read();
}
}
}
Expecting quick Response.
Thanks,
Ramesh
0 1772 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ayende Rahien |
last post by:
reparing resources...
Updating references...
Performing main compilation...
error CS0583: Internal Compiler Error (0xc0000005 at address 53168B12):
likely culprit is 'BIND'.
An internal error has occurred in the compiler. To work around this problem,
|
by: Qiao Yun |
last post by:
I used vc++.net (visual studio .net ) to open a project which can work well
in vc++6.0. I succeeded in compiling the project in vc++.net in release
mode .
But when I tried to compile the project in debug mode, the following errors
happened:
d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xdebug(29):
error C2365: 'new' : redefinition; previous definition was a 'member
function'
d:\Program Files\Microsoft Visual Studio...
|
by: n3crius |
last post by:
hi,
i just got a web host with asp.net , seemed really cool. aspx with the
c# or vb IN the actual main page run fine, but when i use codebehind and
make another source file ( a .cs) to go with the aspx (as you would
realistically) I get this :
Details: To enable the details of this specific error message to be
viewable on remote machines, please create a <customErrors> tag within a
"web.config" configuration file located in the root...
|
by: JTrigger |
last post by:
When I compile my project using the IDE on a development machine it works
just fine. When I compile it on the server using csc.exe, I get the
following error when I try to bring it up in the web browser. What is the
issue?
Thanks,
Jim
Server Error in '/psnRequest' Application.
----------------------------------------------------------------------------
|
by: ST |
last post by:
Hi,
I keep getting the parser error, and I have no idea why. I've tried a
number of things including:
1)building/rebuilding about 100x
2)making sure all dll's are in the bin folder in the root of the web app
3)restarting IIS
4)recreating the virtual dir in IIS
5)playing with any and all settings I could find for the web app in IIS,
including changing permissions
6)recopying the machineconfig file from my asp v1.4... onto my local server
| |
by: Jim Heavey |
last post by:
Internal Compiler Error: stage 'BEGIN'
Hello, I had an application which was working just fine and I decided to
modify all database access within the application to utilizie a new Namespace
that I had developed which would handle all database access. After I
modified all of the code to point to the new namespace and created all of the
necessary references, I get an internal compile error when I attempt to
re-compile. I have create a new...
|
by: Jim Heavey |
last post by:
Hello, I had an application which was working just fine and I decided to
modify all database access within the application to utilizie a new Namespace
that I had developed which would handle all database access. After I
modified all of the code to point to the new namespace and created all of the
necessary references, I get an internal compile error when I attempt to
re-compile. I have create a new project and started fresh and I get the...
|
by: Ramesh2006 |
last post by:
Hi,
The following error occurred when i programmatically compile another project from my present project.
The Error:
error CS0234:The type or namespace name 'Windows' does not exist in the namespace 'System' <are you missing an assembly reference>
The Source Code:
|
by: deathtospam |
last post by:
A day or two ago, I wrote a quick ASPX page with a CS codebehind using
Visual Studio .NET 2005 -- it worked, I saved it and closed the
project. Today, I came back to the project, reopened the solution, and
was greeted with the following error:
========================================================================
It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |