本文整理汇总了C#中System.Diagnostics.Process.Attach方法的典型用法代码示例。如果您正苦于以下问题:C# Process.Attach方法的具体用法?C# Process.Attach怎么用?C# Process.Attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Process
的用法示例。
在下文中一共展示了Process.Attach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DebugGame
/// <summary>
///
/// </summary>
internal static void DebugGame()
{
if (SceneManager.ActiveScene == null)
{
MessageBox.Show("Ups!\n\nThere is no scene loaded", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
SceneManager.GameProject.SceneStartPath = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, SceneManager.ActiveScenePath);
SaveProject();
SaveScene(false);
if (File.Exists(SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe"))
{
if (File.Exists(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll"))
File.Delete(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll");
if (!Directory.Exists(SceneManager.GameProject.ProjectPath + "\\libs"))
Directory.CreateDirectory(SceneManager.GameProject.ProjectPath + "\\libs");
// Compile scripts:
// old (depracated): CompileScripts(false);
//if (SceneManager.ScriptsAssembly != null)
//{
string dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";
// The scripts .dll exists?
if (!File.Exists(dllpath))
{
// Compile scripts
CompilerWindow cf = new CompilerWindow();
cf.ShowDialog();
if (cf.DialogResult.Value) return;
// Update path
dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";
}
File.Copy(dllpath, SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll", true);
try
{
Process debug = new Process();
debug.StartInfo.WorkingDirectory = SceneManager.GameProject.ProjectPath;
debug.StartInfo.FileName = SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe";
debug.StartInfo.Arguments = "";
debug.StartInfo.CreateNoWindow = true;
debug.Start();
if (Properties.Settings.Default.AttachVisualStudio)
{
EnvDTE.DTE vsInstance;
// Try to restore the current project visual studio solution instance, returning it if successful
if (TryToRestoreSolution(out vsInstance))
{
// Tries to attach the retrieved instance to the game debug process
debug.Attach(vsInstance);
}
/*
if (VisualStudioInstancePID != 0 && Extensions.TryToRetrieveVSInstance(VisualStudioInstancePID, out vsInstance))
{
// restore window, in case the process is only running on background
vsInstance.MainWindow.Visible = true;
debug.Attach(vsInstance);
}
else // if PID attempt failed, try using the project solution name
{
// reset PID
VisualStudioInstancePID = 0;
// try to retrieve instance based on solution name
vsInstance = Extensions.GetInstance(UserPreferences.Instance.ProjectSlnFilePath);
if (vsInstance != null)
{
// restore window, in case the process is only running on background
vsInstance.MainWindow.Visible = true;
debug.Attach(vsInstance); // Attach visual studio dte
}
}*/
}
debug.WaitForExit();
debug.Close();
}
catch (Exception ex)
{
Console.WriteLine("ERROR: " + ex.Message);
}
}
//.........这里部分代码省略.........
示例2: DebugGame
/// <summary>
///
/// </summary>
internal static void DebugGame()
{
if (SceneManager.ActiveScene == null)
{
MessageBox.Show("Ups!\n\nThere is no scene loaded", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
SceneManager.GameProject.SceneStartPath = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, SceneManager.ActiveScenePath);
SaveProject();
SaveScene(false);
if (File.Exists(SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe"))
{
if (File.Exists(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll"))
File.Delete(SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll");
if (!Directory.Exists(SceneManager.GameProject.ProjectPath + "\\libs"))
Directory.CreateDirectory(SceneManager.GameProject.ProjectPath + "\\libs");
// Compile scripts:
// old (depracated): CompileScripts(false);
//if (SceneManager.ScriptsAssembly != null)
//{
string dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";
// The scripts .dll exists?
if (!File.Exists(dllpath))
{
// Compile scripts
CompilerWindow cf = new CompilerWindow();
cf.ShowDialog();
if (cf.DialogResult.Value) return;
// Update path
dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";
}
File.Copy(dllpath, SceneManager.GameProject.ProjectPath + "\\libs\\Scripts.dll", true);
try
{
Process debug = new Process();
debug.StartInfo.WorkingDirectory = SceneManager.GameProject.ProjectPath;
debug.StartInfo.FileName = SceneManager.GameProject.ProjectPath + "\\Gibbo.Engine.Windows.exe";
debug.StartInfo.Arguments = "";
debug.StartInfo.CreateNoWindow = true;
debug.Start();
if (Properties.Settings.Default.AttachVisualStudio)
{
EnvDTE.DTE instance = Extensions.GetInstance(UserPreferences.Instance.ProjectSlnFilePath);
if (instance != null)
{
debug.Attach(instance); // Attach visual studio dte
}
}
debug.WaitForExit();
debug.Close();
}
catch (Exception ex)
{
Console.WriteLine("ERROR: " + ex.Message);
}
}
else
{
MessageBox.Show("Ups!\n\nIt seems there is no engine set up for your game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}