使用p4.net api连接到perforce服务器时获取异常

时间:2013-10-03 10:28:58

标签: c# api perforce p4.net

我正在尝试使用以下代码连接到perforce服务器。我没有将Object引用设置为对象异常的实例。

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)中;我得到的对象引用没有设置异常。我在这里失踪的任何东西。

1 个答案:

答案 0 :(得分:0)

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);