首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用p4.net api连接到perforce服务器时出现异常

使用p4.net api连接到perforce服务器时出现异常
EN

Stack Overflow用户
提问于 2013-10-03 18:28:58
回答 1查看 1.2K关注 0票数 0

我正在尝试使用下面的代码连接到perforce服务器。我正在获取未设置为对象异常实例的对象引用。

代码语言:javascript
复制
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);行中,我得到的是对象引用,没有设置异常。这里没有我遗漏的任何东西。

EN

回答 1

Stack Overflow用户

发布于 2013-10-04 11:46:21

代码语言:javascript
复制
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);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19156793

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档