Kwang1imsa
23-03-2011 16:32:38
I'm creating an application that uses the .NET compiler to compiler an application that uses MOGRE.
The code itself compiles and runs fine in Visual Studio, but for some reason, the application breaks if it's compiled programmatically. This is the line that seems to be doing it, even though it is not throwing any exception:
Here is how I compile it:
and the code I compile:
And to run it:
I can see "Start." flash and that's about it. However, when I take the same code and compile it in VS2010, it works fine.
Please help.
EDIT:
Actually, when I build it through VS2010 it doesn't work. However, when I run it through Debug mode, it does. Odd?
Also:
App.config
ed.
The code itself compiles and runs fine in Visual Studio, but for some reason, the application breaks if it's compiled programmatically. This is the line that seems to be doing it, even though it is not throwing any exception:
mRoot = new Root();
Here is how I compile it:
CompilerParameters cp = new CompilerParameters();
cp.ReferencedAssemblies.Add("/reference/sfmlnet-window.dll");
cp.ReferencedAssemblies.Add("/reference/sfmlnet-graphics.dll");
cp.ReferencedAssemblies.Add("/reference/sfmlnet-audio.dll");
cp.ReferencedAssemblies.Add("/reference/Tao.Platform.Windows.dll");
cp.ReferencedAssemblies.Add("/reference/Tao.OpenGl.Glu.dll");
cp.ReferencedAssemblies.Add("/reference/Tao.OpenGl.ExtensionLoader.dll");
cp.ReferencedAssemblies.Add("/reference/Tao.OpenGl.dll");
cp.ReferencedAssemblies.Add("/reference/System.Data.dll");
cp.ReferencedAssemblies.Add("/reference/System.Core.dll");
cp.ReferencedAssemblies.Add("/reference/System.Data.Linq.dll");
cp.ReferencedAssemblies.Add("/reference/Mogre.dll");
//cp.ReferencedAssemblies.Add("/reference/MOIS.dll");
cp.ReferencedAssemblies.AddRange(MainGui.root.referenceList.ToArray());
//Debug
cp.ReferencedAssemblies.Add("/reference/System.Windows.Forms.dll");
cp.GenerateExecutable = true;
cp.OutputAssembly = exeName;
cp.GenerateInMemory = false;
cp.TreatWarningsAsErrors = false;
cp.CompilerOptions = "/platform:x86 /appconfig:App.config";
CompilerResults cr = provider.CompileAssemblyFromFile(cp,sourceName);
and the code I compile:
using System;
using System.Windows.Forms;
using SFML;
using SFML.Graphics;
using SFML.Window;
using Tao.OpenGl;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Mogre;
//using MOIS;
namespace gravitygame
{
class Game
{
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
public static extern bool FreeConsole();
public static Root mRoot;
public Game()
{
mRoot = new Root();
}
static void Main()
{
FreeConsole();
System.Windows.Forms.MessageBox.Show("Start.");
new Game();
System.Windows.Forms.MessageBox.Show("End.");
}
}
}
And to run it:
Process p = new Process();
p.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory() + @"\bin\build\";
p.StartInfo.FileName = Directory.GetCurrentDirectory() + @"\bin\build\" + "App.exe";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.Start();
p.ErrorDataReceived+=new DataReceivedEventHandler(p_ErrorDataReceived);
I can see "Start." flash and that's about it. However, when I take the same code and compile it in VS2010, it works fine.
Please help.
EDIT:
Actually, when I build it through VS2010 it doesn't work. However, when I run it through Debug mode, it does. Odd?
Also:
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
ed.