Reputation:
In this video (at 8:20) the Assembly code for the C# code is displayed. It doesn't tell how to display it (all I hear is press F11, but it is not working for me), maybe it doesn't work for the Express edition of Visual Studio?
Upvotes: 9
Views: 16934
Reputation: 7483
There's a problem with all of these answers.
If your version of MSVC supports it, you can indeed see the assembler instructions in the Debug/Disassembly window (only available while actively debugging an application).
However, the jit compiler detects when you are trying to run it under the debugger. So even if you are doing a Release build, it still won't be quite the same as the Release build that you run from the command line.
On the plus side it will be easier to debug. On the minus side, it makes the .Net compiler look really bad as the code isn't as efficient as it will be when run "for real."
There's a trick I use to see the 'real' assembler output. From within MSVC, launch the app using CTRL-F5 (Start Without Debugging). Then use Debug/Attach to Process to... umm... attach to the process.
You can now break the process with the debugger and examine the 'real' asm output. Actually debugging will be more difficult since the code has been optimized more, but the Disassembly window will give you a better picture of how well the jit compiler can work.
I'm sure there's a way to do this with NGEN too (maybe this?), but just attaching has worked well for me.
Upvotes: 9
Reputation: 5357
The window you are looking fro is Debug -> Windows -> Disassembly
You have to be debugging something for it to be present, and while the debugger is attached you can press Ctrl + Alt + D to get to it.
You cannot view the assembly code (machine code) at any other time, because it doesn't exist. The only time it exists as machine code is when it is loaded and running. .Net does not compile to machine code, it compiles to MSIL, so it has to be JIT Compiled before it is present (just in time). Which only happens when it runs.
Upvotes: 5
Reputation: 736
As explained here you should run your code and stop in a break point then Debug -> Windows -> Disassembly or Ctrl + Alt + D
if it is not there you should open your options Dialog and set Address-leve debugging to enabled
Upvotes: 3
Reputation: 3861
In the menu you select Debug - Windows - Assembly. If that menu is not there in Express Edition, then yeah, it isn't supported.
Upvotes: 4