我正在尝试使用下面的代码连接到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);行中,我得到的是对象引用,没有设置异常。这里没有我遗漏的任何东西。
发布于 2013-10-04 11:46:21
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);https://stackoverflow.com/questions/19156793
复制相似问题