Jump to content

.NET API - P4CommandResult returns empty string, instead posts content to debug window

  • Please log in to reply
2 replies to this topic

#1 falcon



  • Members
  • Pip
  • 3 posts

Posted 30 April 2020 - 09:29 PM

I tried several versions of the api and get the same result. I assume I am doing something wrong. I am using visual studio 15 and the .net api. I am just trying to get the contents of a client spec. The Results look like the command succeeded but the InfoOuput is an empty string. The contents do however appear in the debug window in Visual Studio. Here is the code I am using:

		 P4Server server = new P4Server(uri, user, null, "temp") { RunCmdTimeout = new System.TimeSpan(1, 0, 0) };
		 P4Command command = new P4Command(server, "client", false, "-o", selectedWorkspace);
		 P4CommandResult results = command.Run();

		 List<string> workspaceLines = new List<string>();

		 if (results.Success && results.ErrorList == null)
			 foreach (P4ClientInfoMessage msg in results.InfoOutput)

Thanks for any tips.

#2 falcon



  • Members
  • Pip
  • 3 posts

Posted 06 May 2020 - 10:43 PM

Follow up: It would be nice to know why my initial approach didn't work, but I found another way to get the data. I used the Repository.GetClient() method and its ViewMap variable.

#3 Sambwise


    Advanced Member

  • Members
  • PipPipPip
  • 1065 posts

Posted 06 May 2020 - 11:04 PM

The client -o command doesn't write its output to the `info` channel; it arrives via "OutputData" instead of "OutputInfo" (I'm not sure how you get at that through the .NET API but I assume there's a way).  Running the command through the command line with -vrpc=3 shows the protocol messages:

C:\Perforce\test>p4 -vrpc=3 client -o
RpcSendBuffer cmpfile =
RpcSendBuffer client = 81
RpcSendBuffer api = 99999
RpcSendBuffer enableStreams =
RpcSendBuffer enableGraph =
RpcSendBuffer expandAndmaps =
RpcSendBuffer version = 2016.2/NTX86/1568552
RpcSendBuffer  = -o
RpcSendBuffer autoLogin =
RpcSendBuffer prog = p4
RpcSendBuffer client = Samwise-dvcs-1509687817
RpcSendBuffer cwd = c:\Perforce\test
RpcSendBuffer initroot = c:\Perforce\test
RpcSendBuffer os = NT
RpcSendBuffer user = Samwise
RpcSendBuffer charset = 7
RpcSendBuffer clientCase = 1
RpcSendBuffer port = rsh:p4d.exe -i -J off -r "c:\Perforce\test\.p4root"
RpcSendBuffer sndbuf = 2048
RpcSendBuffer rcvbuf = 2048
RpcSendBuffer func = protocol
Rpc invoking protocol
RpcSendBuffer func = user-client
Rpc invoking user-client
RpcRecvBuffer xfiles = 7
RpcRecvBuffer server = 3
RpcRecvBuffer server2 = 42
RpcRecvBuffer serverID = Samwise-dvcs-1509687817
RpcRecvBuffer revver = 9
RpcRecvBuffer tzoffset = -28800
RpcRecvBuffer sndbuf = 2048
RpcRecvBuffer rcvbuf = 2048
RpcRecvBuffer func = protocol
Rpc dispatch protocol
RpcRecvBuffer serverAddress = unknown
RpcRecvBuffer token = unknown.1588806097
RpcRecvBuffer confirm = crypto
RpcRecvBuffer user = Samwise
RpcRecvBuffer func = client-Crypto
Rpc dispatch client-Crypto
RpcSendBuffer daddr = unknown
RpcSendBuffer token = 129047C606B957AA37E126A7596734FC
RpcSendBuffer func = crypto
Rpc invoking crypto
RpcRecvBuffer himark = 0
RpcRecvBuffer fseq = 180
RpcRecvBuffer func = flush1
Rpc dispatch flush1
RpcSendBuffer himark = 0
RpcSendBuffer fseq = 180
RpcSendBuffer func = flush2
Rpc invoking flush2
RpcRecvBuffer data = <big>
RpcRecvBuffer func = client-OutputData
Rpc dispatch client-OutputData
# A Perforce Client Specification.
#  Client:	  The client name.
#  Update:	  The date this specification was last modified.
#  Access:	  The date this client was last used in any way.
#  Owner:	   The Perforce user name of the user who owns the client
#			   workspace. The default is the user who created the
#			   client workspace.
#  Host:		If set, restricts access to the named host.
#  Description: A short description of the client (optional).
#  Root:		The base directory of the client workspace.
#  AltRoots:	Up to two alternate client workspace roots.
#  Options:	 Client options:
#					  [no]allwrite [no]clobber [no]compress
#					  [un]locked [no]modtime [no]rmdir
#  SubmitOptions:
#					  submitunchanged/submitunchanged+reopen
#					  revertunchanged/revertunchanged+reopen
#					  leaveunchanged/leaveunchanged+reopen
#  LineEnd:	 Text file line endings on client: local/unix/mac/win/share.
#  Type:		Type of client: writeable/readonly/partitioned.
#  Backup:	  Client's participation in backup enable/disable. If not
#			   specified backup of a writable client defaults to enabled.
#  ServerID:	If set, restricts access to the named server.
#  View:		Lines to map depot files into the client workspace.
#  ChangeView:  Lines to restrict depot files to specific changelists.
#  Stream:	  The stream to which this client's view will be dedicated.
#			   (Files in stream paths can be submitted only by dedicated
#			   stream clients.) When this optional field is set, the
#			   View field will be automatically replaced by a stream
#			   view as the client spec is saved.
#  StreamAtChange:  A changelist number that sets a back-in-time view of a
#				   stream ( Stream field is required ).
#				   Changes cannot be submitted when this field is set.
# Use 'p4 help client' to see more about client views and options.

Client: Samwise-dvcs-1509687817

Update: 2020/01/19 09:21:31

Access: 2020/05/02 08:13:42

Owner:  Samwise

		Created by Samwise.

Root:   c:\Perforce\test

Options:		allwrite noclobber nocompress unlocked nomodtime rmdir

SubmitOptions:  revertunchanged

LineEnd:		local

Stream: //stream/main

		//stream/main/... //Samwise-dvcs-1509687817/...
		-//stream/main/bin/... //Samwise-dvcs-1509687817/bin/...
		//stream/main/bin/Game.dll //Samwise-dvcs-1509687817/bin/Game.dll

RpcRecvBuffer func = release
Rpc dispatch release
RpcSendBuffer func = release2
Rpc invoking release2

The important part is the Rpc dispatch client-OutputData, after which you see the entire client spec get dumped as a big text blob, rather than as a series of message ("info") calls.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users