Does anybody know about the output "Module is optimized and the debugger option 'Just My Code' is Enabled"?
Asked Answered
M

4

46

As I said in my previous question I'm migrating my app to windows Metro app.

I'm getting an output like thisenter image description here

I don't understand this output, if anybody knows then this please say!

Mannered answered 23/11, 2012 at 12:13 Comment(3)
The debugger is just telling you that it didn't load symbols for the .NET framework assemblies because you have "Just my code" debugging enabled. You can change that with Tools + Options + Debugging. But focus on debugging your own code instead of the framework code.Pursuit
You should post what you did to solve the problem, if any resolution was achieved.Crushing
off topic IMO, and documented hereCorbin
P
50

Usually, you do not need the module load messages, but they are turned on in default.

Tools -> Options -> Debugging -> Output Window -> Module Load Messages -> Off

Pronunciamento answered 26/4, 2019 at 11:39 Comment(3)
Thank you, I found this while reading the top answer and was amused to see this answered 5 hours ago! It's been bugging me (a little) for ages.Antiserum
What does it mean "Usually you don't need the module load messages"? Usually this is the key to understand why some breakpoint doesn't work or you can't debug some module. Turning on by default is good thing.Grossularite
@Grossularite No, it's not a good thing to have it on by default. Most people don't need these messages, it's just spam if you are only debugging your own code.Constringe
K
21

When you run your application in the debugger, the debugger tries to locate the symbols of the code being run in order to allow you to set break points, view/change memory, examining the call stack etc...

As this task can introduce unwanted delays and/or could confuse the user under normal circumstances, Visual Studio is configured by default to skip the assemblies not being part of your solution. This is normally fine as you can focus on your code. However, there are case which you need to dig under your code to spot bugs not related to your code.

For this reason, the debugger is remembering you that the symbol is being skipped due to this setting, and the picture your are seeing is imcomplete as does not take into acccount what is not "yours".

You can disable this behaviour by unchecking the option Enable Just My Code under Tools->Options->Debugging.

Moreover, if you are interested in stepping through the .NET Framework code, you have to set the Enable .NET Framework source stepping option. Setting this option, also unsets the Enable Just My Code.

Kashgar answered 26/1, 2018 at 13:43 Comment(2)
It would be also useful to know if there's a way to tell the compiler to put that annoying message just once. It is fine to debug just my code, I would not like to uncheck this option, but having all those messages in the output window makes hard to find importan stuffOralee
To my knowledge, there is no way to have the compiler complain only once.Kashgar
B
13

In VS Code, if you do not want to disable "Just My Code" (because you're fine with debugging just your own code), then you can get rid of these messages by adding this to you launch.json configs:

"logging": {
    "moduleLoad": false
}

On the other hand, if you really want to debug external code, then add this to your launch.json config instead:

"justMyCode": false

Find below a full sample config in launch.json for debug just your own code:

{
    // Use IntelliSense to find out which attributes exist for C# debugging
    // Use hover for the description of the existing attributes
    // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
    "name": ".NET Core Launch (web)",
    "type": "coreclr",
    "request": "launch",
    "preLaunchTask": "build",
    // If you have changed target frameworks, make sure to update the program path.
    "program": "${workspaceFolder}/src/YourProject/bin/Debug/netcoreapp3.1/YourProject.dll",
    "args": [],
    "cwd": "${workspaceFolder}/src/YourProject",
    "stopAtEntry": false,
    "justMyCode": true, // You can change to false if you wanna debug 3rd-party code
    "logging": {
        "moduleLoad": false
    },
    // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
    "serverReadyAction": {
        "action": "openExternally",
        "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
    },
    "env": {
        "ASPNETCORE_ENVIRONMENT": "Development"
    },
    "sourceFileMap": {
        "/Views": "${workspaceFolder}/Views"
    }
}
Beekeeper answered 10/2, 2022 at 0:9 Comment(0)
R
4

you could start the application without the debugger attached by pressing Ctrl+F5 from within the Visual Studio environment

this not a error. you only release debugging process from it.

Recoil answered 27/1, 2020 at 10:26 Comment(1)
In my case your response helped me, but I had to do "clean" and "rebuild" solution.Gony

© 2022 - 2024 — McMap. All rights reserved.