We are writing a console app using .Net Core 2.0. In the app, we load several DLLs from a sub-folder dynamically (by using "Assembly.LoadFromFile()"). And when I set a break-point in which DLL was loaded dynamically, the break-point cannot be hit.
But I am pretty sure the code was called, because I printed out some log information to the console, and the log was there.
So i would like to know why my break-point is not hit? And I have put the corresponding "PDB" files in the sub-folder. And when I opened the "Debug->Windows->Modules" view, i can see the "PDB" files were loaded successfully. So what's the problem?
Related
I'm trying to create a C# class library which consists of a form with CefSharp WinForms browser inside it. The library is used by another application as a plugin. The application is set to run when pressing "start" in Visual Studio. Launching the application this way works fine and CefSharp browser shows up and works as it should.
The problems begin when I try to launch the application from the filesystem. This time the form opens, as well as the DevTools, but the CefSharp browser won't appear and the DevTools form/window is blank. The applications trace files show that the it indeed does load the CefSharp DLLs:
15.56.32.202 Requested assembly CefSharp.WinForms (version 51.0.0.0) LOADED from file C:\*PATH_TO_THE_FILES*\CefSharp.WinForms.dll (version 51.0.0.0)
15.56.32.205 Requested assembly CefSharp (version 51.0.0.0) LOADED from file C:\*PATH_TO_THE_FILES*\CefSharp.dll (version 51.0.0.0)
15.56.32.243 Requested assembly CefSharp.Core (version 51.0.0.0) LOADED from file C:\*PATH_TO_THE_FILES*\CefSharp.Core.dll (version 51.0.0.0)
The same trace file logs all thrown exceptions and in this case there are none.
Some other things to note:
- I'm using Visual Studio 2015 Community Edition
- I'm building this for an x64 CPU.
- I've tried both Debug and Release built files, both work through VS and both fail without VS
- I've made sure I have all the files mentioned here in the folder where from CefSharp is loaded
- I have Microsoft Visual C++ redists installed (11.0, 12.0, 14.0)
- Also tried including the msvcp120.dll & msvcr120.dll and their debug variants in the output folder (just in case).
- I've tried both CefSharp versions 51 and 57, behavior stays the same
My only guess is that, under the hood, Visual Studio includes references to some vital files/components/dlls/whatever that are not there when launching without it.
UPDATE
I tried debugging this further and attached methods to following events:
LoadingStateChanged
ConsoleMessage
I created a test html page running on localhost which just calls console.log() with a simple message. The message is written to trace by the method attached to ConsoleMessage and when running from VS it's written to trace as it should. Without VS, it's not.
The method attached LoadingStateChanged wrote to trace the value of IsLoading property of the second parameter LoadingStateChangedEventArgs e. Running with or without VS both wrote the same thing: first true and then false. The ConsoleMessage was logged between these lines in trace when running with VS.
Furthermore, I tried disabling hardware acceleration with:
CefSettings settings = new CefSettings();
settings.CefCommandLineArgs.Add("disable-gpu", "1")
but that didn't help either.
The problem was, as I suspected, related to missing references.
Adding the files of the VS output directory (bin/x64/Debug) to the external application's executable folder solved the problem.
I have a windows service that was written in VB6 that I want to attach to and debug in WINDBG.
The service is compiled without optimizations (also all boxes in "Advanced Optimizations" are unchecked), and "Create Symbolic Debug Info" is checked. I have the source file of a class I want to set breakpoints in. I can set breakpoints on some lines but not all... even though the lines where I can't put a breakpoint at don't have anything exotic, simple variable assignments and such.
Regardless, the breakpoints I can set are hit when I run the service with the g command, but when I start to "step over" (F10), the code does some strange leaps and doesn't (or at least doesn't appear to) evaluate all lines...
It seems to me that the source file and the symbols file are out of sync, but I just compiled the project and moved the files over to the computer where I want to debug... What could cause the source files and the pdb/dll file of the project to be out of sync?
I guess we can add this question to the list. Basically It's been taking me twice the time to try something out because everytime I try to debug my app I have to wait about a minute to lauch the app. There are 3 files in order that it complains about.
Resources file (.g)
Program Debug Database
DLL (.dll)
I tried removing the first two, but then it complains about the DLL file. Strangely enough I have never encountered this and I've been using the the WP7 emulator in VS2010 for about a year. Any ideas? Is there possibly a setting or cache that can be deactivated?
Basically when you add images to your project, by default they are added as a resource. By doing this everytime you try to build the project the images are saved in the dll file thus the long wait time. I set 95% of my images to content and have not had the issue since.
UPDATE: navigating to the process via menu:DEBUG / Attach Process / iexplore.exe shows "Automatic: Silverlight code". i.e. VS 2010 already attached to the process. Why doesn't it go to debug view?
I have a frustrating debug behaviour going on on my laptop which I'd like to fix. I was following along with the demo called Silverlight TV 46: What's Wrong with my WCF Service?
On my computer, I noticed that putting throw new ArithmeticException() in the RIA service causes the just-in-time debugger to get involved (a bad thing -- I want VS). I can put a break point on the the throw new ArithmeticExpression() line, and VS stops as it normally does. Press F10, and I still get the just-in-time debugger kicking in.
On Yvor's computer (the presenter in the Ch 8 link above), the visual studio debugger kicks in instead of the just-in-time one. What am I doing wrong? Could having Redgate Reflector installed previously have caused this (it is gone now).
ERROR:
Visual Studio Just-In-Time Debugger
Code: 4004
Category: ManagedRuntimeError
Message: System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid.
Check ...
Possible Debuggers:
New instance of MS VS 2010,
New instance of VS 2008.
[checked] Set currently selected debugger as the default.
[unchecked] Manually choose the debugging engines
Action: Hit Yes.
2nd ERROR:
Unable to attach to the crashing process. A debugger is already attached.
I've spent several hours looking for a way to solve this.
Browser is IE9 / Silverlight 4.
Previously, I started starting the silverlight app directly via the VS2010 environment... but then decided to get more deployment compliant (again).
http://msdn.microsoft.com/en-us/library/cc838267(VS.95).aspx
Down the bottom they mention repairing from control panel / VS2010. Did that. Waited for ages, made coffee, did something else. Finally complete. Problem sill there. Included this step just-in-case the fix is cumulative (you get superstitious after a while with these things).
I then deleted zap files, switched startup page from html to the aspx one. Wired aspx to the xap (it wasn't pointing to the /debug/ folder). [note: looks like you can remove the debug via Silverlight Project / build / Output path: Replace Bin\Debug\ with Bin. With Silverlight I feel that the relative Uri path should match up to your html / aspx files no matter what -- wheather you are in Debug or Release.
project properties / Web / Specific Page
debugging works again!
Did .html stop debugging? Casual inspection reveals the same javascript stuff firing up Silverlight. On the surface it looks the same. hmmm. I guess it isn't.
... here are a few extra things to look at for those who still have issues (I may as well list them
while they are fresh in my mind).
project / properties / Web / Debuggers: I now only have Silverlight checked. ASP.Net is not checked any more. (Not sure if this influences my result at this stage)
make sure your web project points to the silverlight project in project / properties / Silverlight Applications. This ensures that the silverlight project's binary "xap" is copied to a folder within the Web Site / Web App. Note: hitting the add button reveals a destination folder (should be ClientBin).
Your build configuration will add an additional sub foler e.g. debug.
Make sure your .aspx or .html files have the right path. For me, I just included the .ClientBin/debug/ folder. I don't think this is deploy friendly, so I will search for a better way later.
IE9 settings.
[X] Disable script debugging.
[X] Disable script debugging (Other)
[ ] Display notification about a script error
[ ] Show friendly HTTP error message
Again, unsure if these later setting have an impact.
Lastly, there's something that I forget about sometimes. Be sure to check Debug VS2010 / Exceptions / Common language Runtime. This ups the ability to catch exceptions.
I had a similar problem, but the above did not resolve it. However, starting the application without debugging (Ctrl-F5) and triggering the exception would allow me to select the Visual Studio instance that I started the application from. Amazingly, I got a sensible stack trace and resolve the problem within a few minutes.
Recently I tried to install a webpart through wspbuilder utility to the Sharepoint Site. I have created, built and deployed a project to the 12 hive. After that installed the solution through Cental Administration Site and activated in the site collection.
I just wonder how can I debug the complex feature/solution ? Because both processes (build-deploy and activate) totally independent, how can I attach a process with the worker process ?
In the WSPBuilder context menu there is an option "Attach to IIS worker process". As long as the app is loaded (generally means that you have accessed a page in the SharePoint site before trying to attach) and the code deployed in SharePoint is the same as the code you have in Visual Studio, you should be able to set breakpoints and step through the code.
First, you need to open up your browser and navigate to the SharePoint website in question. Then, In Visual Studio, go to Debug --> Attach to Process, and find the w3wp.exe process associated with the Sharepoint website that you want to debug. Click it (the process) and then click the Attach button. You should now be able to debug any activities associated with your SharePoint feature.
Sometimes it is a bit of a pain to figure out which w3wp process to attach to. Try adding the following to your code to break into the debugger:
System.Diagnostics.Debugger.Break();
System.Diagnostics.Debugger.Break()
Like Muhimbi suggested, this is actually very useful in certain cases. Say you want to debug custom code (e.g. feature_deactivating event) when it might be invoked with stsadm and not the browser. (for e.g. you will have to use stsadm for feature deactivation when feature is hidden in UI).When using stsadm you cannot attach to cmd.exe because that's a separate process. If you type the command and hit enter and then find its id of stsadm.exe process to attach to, its too late. In situations like these, the command above is the easist and best solution
I tried the steps as mentioned here
go to Debug --> Attach to Process, and find the w3wp.exe process associated with the Sharepoint website that you want to debug
But I get "Breakpoints will not be hit, no symbols have currently been loaded for this document". Should I have to register the custom deployed solution dll using GACUTIL ? Should I have to copy the PDB files at any particular location ?
What am I missing here ?