1
我正在使用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