open a mysession in perforce using p4api.net

978 Views Asked by At

i tried to open my session with p4 api .net but the command is not working.

ServerAddress adr = new ServerAddress(p.conStr);
Server serv = new Server(adr);
P4Server ser = new P4Server(p.conStr, p.user, p.password, p.ws_client);
Connection con = new Connection(serv);
string  password = "Password";
con.Login(password);

the object con.timeout countain the value :

"base {System.SystemException} = {"La référence d'objet n'est pas définie à une instance d'un objet."}" 

i think that the problem is that is not possible to do that because if we use the commandline w process by passing the command p4 -p xx.xxx.xxx.x:xxxx login and than we pass the password.

i tried also passing the command by using System.Diagnostics.Process by the following code:

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "p4.exe";
startInfo.Arguments = "p4 -p 10.215.100.7:1666 login";
process.StartInfo = startInfo;
process.Start();

help me please

1

There are 1 best solutions below

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