Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perforce P4.NET API返回的Perforce密码(P4PASSWD)无效_.net_Api_Perforce_P4api.net - Fatal编程技术网

Perforce P4.NET API返回的Perforce密码(P4PASSWD)无效

Perforce P4.NET API返回的Perforce密码(P4PASSWD)无效,.net,api,perforce,p4api.net,.net,Api,Perforce,P4api.net,我正在编写一个VSC应用程序,使用p4api.net访问P4服务器。P4V应用程序使用给定的用户/密码访问存储库。使用p4api.net API,代码使用从表单传入的服务器/用户/密码字符串毫无例外地执行Connect()和Login()方法: rep.Connection.Connect(options); rep.Connection.Login(password, options); 以下是实际代码: String conStr = mServerConnection.Text;

我正在编写一个VSC应用程序,使用p4api.net访问P4服务器。P4V应用程序使用给定的用户/密码访问存储库。使用p4api.net API,代码使用从表单传入的服务器/用户/密码字符串毫无例外地执行Connect()和Login()方法:

  rep.Connection.Connect(options);
  rep.Connection.Login(password, options);
以下是实际代码:

String conStr = mServerConnection.Text;
String user = mUserText.Text;
String password = mPaswordTxt.Text;
try
{
   Server server = new Server(new ServerAddress(conStr));
   rep = new Repository(server);
   rep.Connection.UserName = user;
   Options options = new Options();
   Options["Password"] = password;
   rep.Connection.Client = new Client();
   rep.Connection.Connect(options);
   rep.Connection.Login(password, options);
}
catch (Exception ex)
{
   rep = null;
   MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
但是,在另一个访问P4”//depot“根目录的调用期间,API调用_repository.GetDepotDirs()将返回“Perforce Password(P4PASSWD)invalid or unset”异常。请参阅下面的代码:

public bool Expand()
{
  if (String.IsNullOrEmpty(depotPath))
     return false;
  // if we have the depot path, get a list of the subdirectories from the depot
  if (!String.IsNullOrEmpty(depotPath))
  {
     IList<string> subdirs = _repository.GetDepotDirs(null, String.Format("{0}/*", depotPath));

但这并没有解决问题。谢谢你的帮助。谢谢。

在安全级别为3时,直接输入密码进行连接不起作用。因此,我捕获随后的异常,然后调用Login。此时,您可以将登录返回的Credential.Ticket保存在选项中的“Ticket”字段下,以供将来连接


我不知道为什么后续的命令调用会失败,除非您的票证以某种方式过期,或者您实际上已经断开了与服务器的连接。在执行后续命令之前,始终可以再次调用Connect

谢谢你的帮助。我删除了“Options[“Password”]=Password;”这一行,我可以登录到P4存储库。
p4 set P4TICKETS=C:\Documents and Settings\my_user_name