So, I'm profiling my application, and I'm getting 30% exclusive samples on System.Windows.Forms.Application.Run, of which almost the entirety is on "Function Body". However, I can't see what is exactly happening there, as Visual Studio tells me "Matching symbols could not be found".
I've tried adding manually the System.Windows.Forms.pdb file, which's pathI got from Debug->Windows->Modules, to Options->Debug->Symbols, to no avail.
I also generated the respective pdb file and added it similarly, with no luck.
I've also tried setting Debugging->General->Enable .Net FrameWork Source stepping to true, and disabled Just My Code, in the same menu. No luck at all
Is there any way this can be done? I really want to know what the hell is happening in that function body that's taking a third of CPU time.
Related
I often get blue question marks on files in my VS2012 Solution Explorer when opening a solution bound to Perforce through P4VS.
Looks like something is having trouble to "synchronize" with the depot/workspace/whatnot. Hitting "Refresh View" always solves the issue but I'm growing tired on doing this everyday:
This is my VS version:
Microsoft Visual Studio Professional 2012
Version 11.0.61030.00 Update 4
And P4VS:
2014.1.85.4506
This is persistent across P4VS versions for a few months now, and seems to be affecting sometimes individual files, sometimes entire projects, with no apparent pattern.
How can I diagnose what's going wrong, be it a server issue, a VS issue, a workspace issue?... The Perforce Source Control output shows nothing special.
Actually it's not entire folders, it's entire projects. It appears that even if refreshing a project "fixes" the issue for one run, re-opening the solution brings it back. Whereas I think that for individual files, refreshing them solves the issue once and for all. I'll play with it a bit more to confirm that.
To help diagnose what is going wrong you should probably turn on logging, and check the preferences that will show everything in the output window. For the P4VS log, go to:
Tools- > Options -> Source Control -> Perforce - Logging
(This is not the same thing as the Visual Studio Activity log.)
There could be a possibility that you are getting disconnected and refresh reconnects you. I am not sure if you have your connection set to use solution-specific settings, since you did not mention the connection dialog coming up.
This "solved" the issue for me, at least for the entire projects that went blue-question-marked:
1) Tools > Options
2) Source Control
3) Perforce - General
4) Tick the option "Treat Solution/Project as directory when
selected"
Not sure why but that's one less annoyance for me every day. Thanks to Perforce support for suggesting that.
The file is probably not marked for version control. I noticed this icon in one file and opened Perforce to check. For whatever reason, this file was not marked for add in Perforce. After marking the file for add and submitting, the blue question mark went away.
I'm using VS2012 and .net 4.5. Whenever I edit C# expression in properties window I get message as shown in below image
Update:
I did not open this file. Neither in VS nor in other program. I think VS loads this file for some reason.
If I open C# expression dialog I get similar behavior to the one described here
I also often get error saying that VS cannot access this 'TemporaryGeneraterdFile_' cos it's being used by another process.
This post describes that error.
Did anyone experienced similar behavior?
It's realy anoing as it happens very often.
I have the following code in a view model:
public Point Location
{
get
{
var rangePixels = Range * PixelsPerMile;
var xCoordinate = OwnLocation.X * MapScale + rangePixels * Math.Cos(Theta);
var yCoordinate = OwnLocation.Y * MapScale - rangePixels * Math.Sin(Theta);
return new Point(xCoordinate, yCoordinate);
}
}
One of the usings at the top of the code file is System, which contains Math.
If I view Math.Sin(Theta) in the Watch window (by selecting the code, right clicking, and choosing "Add Watch"), I get the following error:
The name 'Math' does not exist in the current context
What I want to know is:
Is this expected/default behavior for Visual Studio 2010? I could swear this never used to be a problem, but maybe it's always worked that way and I somehow never noticed.
If it's not normal to get this error, any thoughts on what the problem could be? There are a million settings in Visual Studio, and I wouldn't know where to begin.
I should note this question is vaguely similar to this, but I'm not having any issues mousing over my local variables, and I'm not using PostSharp.
Edit
I just tried resetting all my Visual Studio settings backs to default, and I'm still getting the same error. If someone wants to try a simple test in Visual Studio, I just want to know if you get an error if you add a watch for Math.Sin(1).
Edit 2
Here are a couple screen captures to show what I'm experiencing:
Edit 3
Interestingly, intellisense works if I type Math. into the Watch window, but if I complete the expression, I still get the error:
Edit 4
To address BACON's questions:
I get the same behavior with QuickWatch and Immediate.
Closing and reopening all the windows does not solve the problem.
I'm using Visual Studio 2010 Professional (version 10.0.40219.1 SP1Rel)
I tried targeting .NET 4.0 Client Profile and full .NET 4.0. Made no difference. I created a Console App (rather than a WPF app) targeting .NET 4.0 Client Profile, and finally, the error did not occur. So, WPF may be an issue (or WPF with some third-party libraries). (Will check on that next.)
It appears that the culprit is a third-party library that performs IL weaving (Fody.PropertyChanged).
If I create a new WPF project without this library, I'm able to use Math.Sin() in the Watch window. Once I install PropertyChanged, I start getting the "not available in this context" error.
Thanks to #BACON for leading me down the right path to figuring this out.
Here's a link to an issue I posted on the PropertyChanged site:
http://code.google.com/p/propertychanged/issues/detail?id=6&thanks=6&ts=1330494634
Edit
And subsequently, it turns out this is probably a bug in Mono-Cecil, which PropertyChanged uses:
https://github.com/jbevain/cecil/issues/90
I did this in a litte test app, in the constructor..
Trying to put a watch on Math lets me see the values of E and PI.
You cannot put one on Sin.
Putting one on val works just fine.
So, no, I don't think that it's quite normal, unless you clicked on the wrong name. I.e., not the variable, but the "Sin" portion...
Here is where I highlighted the entire thing...
Is there something wrong with the .dll file? Shouldn't it just consider the code as closed source since it's all byte code and try NOT to step through it? Is there any way to make this possible?
For example, I have an ASP.net MVC 3 project which is using both Fluent NHibernate and NHibernate. Regardless of which version I use, I can't debug what is happening without having actual access to the source code.
This, I believe poses a problem, for I've installed the necessary binaries to build the project, and therefore SHOULD be able to just debug and get the necessary information available on my variables without stepping through the code itself. If this is not the case (which it isn't, obviously), what can I do about it?
Note: my whole goal here is to see if it's possible to debug my code WITHOUT requiring the source files, as I have the .dll installed, and therefore shouldn't require the source to view the data that variables hold on the stack.
Check to see if Just My Code is enabled in your debug options and settings.
From above link:
Sometimes, while you are debugging, you might want to look at only the code you have written and ignore other code, such as system calls. You can do this with Just My Code debugging. Just My Code hides non-user code so that it does not appear in the debugger windows. When you step, the debugger steps through any non-user code but does not stop in it.
Trying to debug a controllers action method, and when I attach to process the debug icon goes hollow and says the 'current breakpoint will not be hit'
But I am doing a response.write at that point and when the page renders it does output the test text.
So that section is indeed being executed, why does debug mode not work?
Your source code may be different than the version of the corresponding process that you are attaching to. Your other process may also be built in release mode, i.e., there is no debug info.
There are a few reasons why you may see this message:
You are attached to the wrong process
You are attached to the right process but the AppDomain hasn't loaded the assembly yet
You are attached to the right process but you have forgotten to build so the source code and the PDB file are out of sync
I've noticed this happen when using reflection and dynamically loading .dll projects. If the code isn't specifically reference (i.e. you are using interface animal but dynamically loading implementations of animal such as cat/dog) it will say it won't hit the breakpoint, but actually does.
I do not like to play with knives but the only thing that worked for me involves editing the .csproj file itself. So, unload the project file, edit it by cutting and pasting the three asp.net files so that they are together in the ItemGroup. However, sometimes it is necessary to go further as explained here: http://carnotaurus.tumblr.com/post/4130422114/visual-studio-debugging-issue-with-files-of-the-same - Also, I give a list of other proposed solutions that did not work for me. I hope it helps.
Another reason is when you attach to the process to quickly.
For example, when I attach to Excel to debug a VSTO add-in (I am using Add-In Express), if I Build, then Start > Run > Excel, then quickly press Ctrl+Alt+P to attach to process, then press E to highlight Excel and press Enter I see this, before Excel has loaded:
The result is no Breakpoints will be hit.
However, if I give Excel a couple of seconds to load and then press Ctrl+Alt+P, notice the Title is showing:
The result is Breakpoints will be hit.
It also tells me your source code is different from the version but it is not true. I build the whole solution, then attach to process, but still it says the breakpoints won't be hit because the source code is different. Maybe it is a bug?