Context Menu Icons Disappear - Commands become Unavailable

Oct 26, 2011 at 10:21 PM

I'd like to start by thanking all parties responsible for this piece of software. Being able to have P4 tightly integrated into VS without having the overhead of the source control bindings embedded into the project files is a real dream come true. With that said, I do have one issue.

Sometimes, depending on what elements are in my projects, the plugin will continue to work when I modify a file (Auto Edit) or add a file (Auto Add), yet when I right click on an item in the Solution Explorer (Navigator) all of the VS2P4 elements are missing. I also have hotkeys bound to these commands and when I try to invoke them, I get a message stating that the command is no longer available. (Exact message: 'The key combination (Ctrl+P, Ctrl+G) is bound to command (P4 Refresh All Glyphs) which is not currently available.'). The interesting thing, is that if I restart VS, it'll reflect the correct P4 state (i.e. all glphys are correct). Then when I go to edit another file, the change isn't reflected until I restart VS again.

Sometimes it's easy to know when I'll have this issue. In particular, when working with web service references, the plugin fails. If I'm just working on a simple console application or class library I very rarely run into this issue.

I was wondering if you've experienced this behavior before. If not, are there any steps I should take to help you trouble shoot this issue?

Thanks again for your time and I look forward to hearing back from you.

 

Cheers,

Joe

Oct 28, 2011 at 8:48 PM

One more piece of information I found.

It seems like the plugin doesn't work well when dealing with projects that are in Solution Folders. The behavior is the same as described above, yet this is another example where this happens.

Hope this information is helpful.

Thanks again.

Oct 29, 2011 at 11:18 AM

Thanks for the kind words, Joe.

I would really like to nail this down. I'm puzzled how the commands could go missing. I wonder if you could email a tiny sample project (that fails) to brubaker.dale at gmail.com. 

And maybe also send the log showing a failure case:

  1. On the Options dialog, set Logging Level to Information 
  2. Start VS (devenv.exe) with /log tocause logging to go also to ActivityLog.xml, e.g. %AppData%\Microsoft\VisualStudio\10.0\ActivityLog.XML

Do I understand that all the files (e.g. the projects in Solution Folders) are still inside your P4 workspace?

And are you set to "Use P4Config instead" on the Options dialog?

Best regards,

Dale

Oct 31, 2011 at 2:53 PM

Dale,

No problem. I'll whip up a sample or two and e-mail them to the address provided. I'll try to have them to you by tonight.

I've already set logging to Info, but I'll run VS witht he command line option to hopefully provide more info.

You are correct. All of the files exist in my P4 workspace. I've tried using the default P4 config as well as manually entering in my P4 config credentials in the options dialog.

Thank you very much for getting back to me and I'll try to get those samples over to you as soon as I can.

Cheers,

Joe

Nov 9, 2011 at 10:54 PM

Joe,

I believe this is fixed now, in new version 1.51. Thanks for the sample code.

It turned out to be an IntPtr bug from the original Microsoft source control sample code. A tough one, and I'm glad it's squashed.

Thanks for your help!

Dale

Nov 10, 2011 at 3:18 PM

I was also experiencing the original issue, but now after updating to 1.51, vs crashes upon opening a solution file. Even solution files which did not have the original issue now crash vs.

I've had to disable the plug-in for now. 

Unfortunately, I won't be able to follow up for a couple of weeks, as I will be out of town/vacation.

Thanks,

Scott.

Nov 10, 2011 at 4:53 PM

Ouch. If anyone can send a small sample solution that crashes to me, I'll fix it immediately.

brubaker.dale at gmail.com

 

Thanks.

Nov 10, 2011 at 6:31 PM

Dale,

Thanks for fixing that bug. I'll try to create a sample project that fails after downloading the new bits sometime soon. I just can't do it today because I have too much work to do and I can't afford environment issues. But hopefully within the next couple of days I'll be able to send you something.

Thanks again for jumping on this so soon!

Nov 11, 2011 at 9:37 AM

I've added a new version 1.52 that might solve the problem, or it might not. I haven't been able to reproduce a crash, but I found and fixed a potential problem.

Nov 15, 2011 at 8:18 PM

Dale,

 

Thanks again for working on this. It kills me to say this, but I still have an issue:

I'm getting the following error in my VS2P4 output when trying to refresh all glyphs:

12:50.511: Error: P4Service.SendCommand() Exception: Error running Perforce command!
Usage: fstat [ -F filter -T fields -m max -r ] [ -c | -e changelist# ] [ -Ox -Rx -Sx ] file[rev]...
Missing/wrong number of arguments.

 

I notice that before the call to SendCommand, the call to P4Service.Connect() succeeds and correctly finds my workspace root.

Sorry to open up a can of worms here :(

Let me know if you'd like some more info. I seem to be getting this error on all of my projects, no matter how simple they are.

Nov 16, 2011 at 5:14 PM

Joe,

Try version 1.53, just released. It fixes this issue, on my machine at least.

Thanks,

Dale

Nov 16, 2011 at 7:31 PM
Edited Nov 16, 2011 at 7:32 PM

Dale,

It still doesn't work, but I think I've found the bug.

I was getting the following error message: 'File·{0}·is·not·under·Perforce·root·{1}'

After doing a little digging, I found a slight issue with the function IsFileUnderRoot in Map.cs. It seems like the Parent property on a DirectoryInfo object returns a DirectoryInfo who's full name doesn't contain the trailing '\'. I'm not really sure how to upload a patch, but below is a small fix I made to get it to work on my machine (I rebuilt the vsix with the fix and the context icons appeared as they should. I was able to edit files and refresh glyphs without issue). Feel free to put the fix in another way (i.e. maybe removing trailing space when we first set _root), but I'm pretty sure this is what was causing me issues.

 

private bool IsFileUnderRoot(string vsFileName) {
	if (string.IsNullOrEmpty(_root)) {
		// This happens when we fail to connect to Perforce for some reason.
		return false;
	}
	var diRoot = new DirectoryInfo(_root.ToLower());
	var diFile = new DirectoryInfo(vsFileName.ToLower());
	//-- Remove that last back slash (if exists) from our root.
	var fullRoot = diRoot.FullName.TrimEnd('\\');
	while (diFile.Parent != null) {
		//-- Here we can check against fulRoot instead of diRoot.FullName
		if (diFile.Parent.FullName == fullRoot) {
			return true;
		}

		diFile = diFile.Parent;
	}

	return false;
}

Nov 16, 2011 at 8:45 PM

I took your suggestion. It's in Version 1.54.

Thanks for your help!

Nov 16, 2011 at 9:47 PM

Dale,

Thanks. I've installed 1.54 and all is working. I've checked some other problematic solutions I had lying around and they're also working.

Thank you so much for addressing this issue. I really love this extension. I don't know how I lived without it before this!

Let me know if you need anything else or would like someone else to help out with the development of this project.