簡體   English   中英

使用p4.net API連接到Perforce服務器時獲取異常

[英]Getting exception while connecting to perforce server using p4.net api

我正在嘗試使用以下代碼連接到perforce服務器。 我正在將對象引用未設置為對象異常的實例。

String conStr = "perforce2.ges.abc.com:1666";
String user = "John_Smith";
String password = "abc@1234";
String ws_client = @"E:\Perforce\Automation\Technical Books";

ServerAddress adr = new ServerAddress(conStr);
Server serv = new Server(adr);
P4Server ser = new P4Server(conStr, user, password, ws_client);
Connection con = new Connection(serv);
Options opconnect = new Options();
opconnect.Add("-p", "");
con.SetClient(ws_client);
con.Connect(null);
con.Login(password);

在con.Connect(null);中 我正在獲取對象引用未設置異常的行。 我在這里什么都沒有。

The issue got resolved. I have used below code

// define the server, repository and connection
                Server server = new Server(new ServerAddress(uri));
                Repository rep = new Repository(server);
                Connection con = rep.Connection;


                // use the connection varaibles for this connection
                con.UserName = user;
                con.Client = new Client();
                con.Client.Name = ws_client;

                Options opconnect = new Options();
                //opconnect.Add("-p", "");
                opconnect.Add("-p", password);


                // connect to the server
                con.Connect(opconnect);
                //con.Connect(null);
                con.Login(password);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM