我有一段 C# 代码,用于在 C# 中远程注册 *.tlb 文件。我正在使用 PsExec (Powershell) 使用以下命令部署它:
.\PsExec.exe \\* -u "username" -p "password" -h -c "MyExe.exe"
它在 x86 机器上运行良好,但在 x64 机器上失败并出现以下错误:-2146232576
.
如果我在 64 位机器上本地运行 *.exe,它工作正常。代码如下:
static void Main(string[] args)
{
try
{
Directory.CreateDirectory(@"C:\Directory");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
try
{
File.Copy(@"\\x.x.x.x\MyDll.dll", @"C:\Directory\MyDll.dll");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
try
{
var p = new Process
{
StartInfo =
{
FileName = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe",
Arguments = @"C:\Directory\MyDll.dll",
UseShellExecute = false
}
};
var q = new Process
{
StartInfo =
{
FileName = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe",
Arguments = @"C:\Directory\MyDll.dll /tlb",
UseShellExecute = false
}
};
var r = new Process
{
StartInfo =
{
FileName = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe",
Arguments = @"C:\Directory\MyDll.dll /codebase",
UseShellExecute = false
}
};
p.Start();
q.Start();
r.Start();
}
catch(Exception z)
{
Console.WriteLine(z.Message);
}
}
Console.WriteLine("Done and Done");
}
}