小编And*_*man的帖子

从.NET服务作为其他用户启动.NET应用程序时的权限问题?

我正在尝试在.NET服务的不同用户下启动.NET应用程序.我们的想法是在Windows中创建一个沙盒托管应用程序.在服务中,我以编程方式在Windows中创建用户,为该用户创建文件夹,并将主机.exe从服务器下载到该文件夹​​中.然后我使用System.Diagnostics.Process运行主机.exe.这是该过程的StartInfo:

_process = new Process
{
    StartInfo =
    {
        Arguments = " -debug",
        FileName = instanceDirectory + "host.exe",
        WorkingDirectory = instanceDirectory,
        UseShellExecute = false,
        RedirectStandardError = true,
        RedirectStandardOutput = true,
        RedirectStandardInput = true,
        UserName = Helpers.GetUserNameForInstance(_hostid),
        Password = _hostpass,
        Domain = ""
    },
    EnableRaisingEvents = true
};
Run Code Online (Sandbox Code Playgroud)

当我将服务作为SERVICE运行时,进程立即崩溃,错误代码为-1073741502.但是,当我在Windows服务中指定的同一用户运行服务但在控制台中以交互方式运行时,一切正常.只有在将服务作为SERVICE运行而不是直接在控制台中运行时才会发生这种情况.

任何帮助将非常感激.这已经很长一段时间了,这是最后的手段:(

.net c# service

24
推荐指数
3
解决办法
2679
查看次数

标签 统计

.net ×1

c# ×1

service ×1