我正在使用p4api.net编写VS C#应用程序来访问P4服务器。 P4V应用程序通过给定的用户/密码访问存款处罚款。使用p4api.net API,代码执行的connect()&登录()使用从表单中传递的服务器/用户/密码字符串无一例外方法:Perforce P4 .NET API返回Perforce密码(P4PASSWD)无效
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)无效或未设置”异常。请看下面的代码:
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));
我读的地方,我需要让我这样做,在DOS提示符下设置环境变量P4TICKETS:
p4 set P4TICKETS=C:\Documents and Settings\my_user_name
但这并没有解决问题。我会很感激你的帮助。谢谢。
谢谢你的帮助。我删除了“选项[”密码“] =密码;”我可以登录到P4存储库。 – Kevin 2012-01-13 00:49:52