-
making a window
I want to make a window (not just selecting a windows form either) from code.
The peices of code I got so far are this:
my using statements
Code:
using System;
using System.Drawing;
using System.Windows.Forms;
starting code or somthing
Code:
namespace FormTest
{
public class FeaturedForm : Form
and ending code I belive
Code:
static void Main()
{
Application.Run(new FeaturedForm());
}
I also saw you can add STAThread before static void main()
so with that how do I make a window apear?
-
Ok I have made a window but now I got the black console window behind the window. How do I get rid of or make it so the console window doen't apear.
-
There should be a compiler switch for CONSOLE or WINDOWS subsystem. If you select windows, no console window will appear.
-
alright well than the problem is, I am using code DOM. I want the program be able to make a windows program and that is the hard part.
-
When you call the compiler in the CSharpCodeDomProvider (I think) you pass in a number of options - one is whether or not to create an exe, one is whether to create a console or Win32 program.
-
Code:
// Create an instance of the CSharpCodeProvider class.
Microsoft.CSharp.CSharpCodeProvider provider = new CSharpCodeProvider();
// Call the CodeDomProvider.CreateCompiler() method to obtain an ICodeCompiler from the provider.
System.CodeDom.Compiler.ICodeCompiler compiler = provider.CreateCompiler();
CompilerParameters cp = new CompilerParameters(referenceAssemblies,
exeFile, false);
// Generate an executable rather than a DLL file.
cp.GenerateExecutable = true;
cp.CompilerOptions += "/target=winexe";
// Invoke compilation.
CompilerResults cr = compiler.CompileAssemblyFromFile(cp, sourceFile);
I believe that is what is needed - /target=winexe is a parameter to the 'csc' C# compiler that says to make a Windows file.
-
You were close, it is
/t:winexe
Found that after I knew what I was looking for.
Thank you!
-
Ahh sorry my mistake, I used the .NET 2.0 CSC, where it's /target:winexe or /t:winexe. Glad to help :)