简体   繁体   English

调用过程以无效的凭据开始

[英]Calling Process.Start with invalid credentials

What happens if I call Process.Start with invalid credentials (ie, password)? 如果我使用无效的凭据(即密码)致电Process.Start会怎样? I'm getting a Win32Exception but that doesn't seem right to me. 我遇到了Win32Exception异常,但对我来说似乎不对。 However, the documentation suggests it's not designed to report credential errors. 但是,文档表明它并非旨在报告证书错误。 Is this a security feature? 这是一项安全功能吗?

No, Win32Exception is correct. 不, Win32Exception是正确的。 If you look a little bit more on the MSDN documentation : 如果您对MSDN文档了解更多:

An error occurred when opening the associated file. 打开关联文件时发生错误。

-or- -要么-

The sum of the length of the arguments and the length of the full path to the associated file exceeds 2080. The error message associated with this exception can be one of the following: "The data area passed to a system call is too small." 参数的长度和关联文件的完整路径的长度的总和超过2080。与此异常关联的错误消息可能是以下之一:“传递给系统调用的数据区域太小。” or "Access is denied." 或“访问被拒绝”。

Emphasis mine. 强调我的。

I would say, that it isn't extremely clear. 我会说,这还不是很清楚。 Looking at the code with reflector seems to agree with the documentation. 用反射器查看代码似乎与文档一致。

EDIT 编辑

Some plumbing details.. 一些管道的细节。

Process.Start will be throw a Win32Exception for a lot of reasons; 由于多种原因, Process.Start都将引发Win32Exception pretty much if anything goes wrong starting the process. 如果在启动过程中出现任何问题,则几乎可以解决。 Internally, .NET is called CreateProcessWithLogonW , and if that fails, it throws the Win32Exception and sets the NativeErrorCode property on it to whatever GetLastWin32Error returned. 在内部,.NET称为CreateProcessWithLogonW ,如果失败,它将抛出Win32Exception并将其上的NativeErrorCode属性设置为返回的GetLastWin32Error You can determined why it was thrown by looking at that code. 您可以通过查看该代码确定为什么抛出该错误。 There is a lookup of what each code means here . 有什么每个代码意味着查找这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM