运行 vshost.exe 作为其他用户
Running vshost.exe as a different user
我可以使用不同于启动 VisualStudio 的用户名从调试文件夹启动 appname.vshost.exe
吗?
有 appname.vshost.exe.config
个,内容如下。是否有用户名的配置?我试过搜索它,但找不到任何东西。
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
如果您正在尝试 运行 您的 debugg 可执行文件
您可以尝试 shift 右键单击和 运行 作为不同的用户。
或者您想通过配置 运行 作为不同的用户?
我认为您不能在与您用来启动 Visual Studio 的用户不同的用户下启动 vshost.exe。所以现在我在另一个控制台应用程序的不同用户下启动主控制台应用程序并将调试器附加到它并且它可以工作。
如果对任何人有帮助,我已将我的代码复制到下面。
using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using EnvDTE80;
using Process = System.Diagnostics.Process;
namespace StartService
{
class Program
{
static void Main(string[] args)
{
var secure = new SecureString();
foreach (var c in "password-from-config")
{
secure.AppendChar(c);
}
Process process = null;
try
{
process = Process.Start(@"C:\Test Projects\WcfServiceTest\WcfServiceTest\bin\Debug\WcfServiceTest.exe",
"TestUser", secure, "DomainName");
Attach(GetCurrent());
Console.ReadKey();
}
finally
{
if (process != null && !process.HasExited)
{
process.CloseMainWindow();
process.Close();
}
}
}
public static void Attach(DTE2 dte)
{
var processes = dte.Debugger.LocalProcesses;
foreach (var proc in processes.Cast<EnvDTE.Process>().Where(proc => proc.Name.IndexOf("WcfServiceTest.exe") != -1))
proc.Attach();
}
internal static DTE2 GetCurrent()
{
var dte2 = (DTE2)Marshal.GetActiveObject("VisualStudio.DTE.12.0"); // Specific to VS2013
return dte2;
}
}
}
我可以使用不同于启动 VisualStudio 的用户名从调试文件夹启动 appname.vshost.exe
吗?
有 appname.vshost.exe.config
个,内容如下。是否有用户名的配置?我试过搜索它,但找不到任何东西。
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
如果您正在尝试 运行 您的 debugg 可执行文件 您可以尝试 shift 右键单击和 运行 作为不同的用户。
或者您想通过配置 运行 作为不同的用户?
我认为您不能在与您用来启动 Visual Studio 的用户不同的用户下启动 vshost.exe。所以现在我在另一个控制台应用程序的不同用户下启动主控制台应用程序并将调试器附加到它并且它可以工作。
如果对任何人有帮助,我已将我的代码复制到下面。
using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using EnvDTE80;
using Process = System.Diagnostics.Process;
namespace StartService
{
class Program
{
static void Main(string[] args)
{
var secure = new SecureString();
foreach (var c in "password-from-config")
{
secure.AppendChar(c);
}
Process process = null;
try
{
process = Process.Start(@"C:\Test Projects\WcfServiceTest\WcfServiceTest\bin\Debug\WcfServiceTest.exe",
"TestUser", secure, "DomainName");
Attach(GetCurrent());
Console.ReadKey();
}
finally
{
if (process != null && !process.HasExited)
{
process.CloseMainWindow();
process.Close();
}
}
}
public static void Attach(DTE2 dte)
{
var processes = dte.Debugger.LocalProcesses;
foreach (var proc in processes.Cast<EnvDTE.Process>().Where(proc => proc.Name.IndexOf("WcfServiceTest.exe") != -1))
proc.Attach();
}
internal static DTE2 GetCurrent()
{
var dte2 = (DTE2)Marshal.GetActiveObject("VisualStudio.DTE.12.0"); // Specific to VS2013
return dte2;
}
}
}