dvboom

I've written a plug-in system for Compact Framework (v2.0) applications, and it's been running great for a while except for one problem.

When I debug the application by pressing F5 to run it, the assemblies I load via Assembly.LoadFrom(string assemblyFile) do not load the debugging symbols, and therefore breakpoints don't get hit, I can't step into code in those dynamically-loaded assemblies, etc.

The problem is also described in this older posting.
http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-compact-framework/8097/Debugging-question

This would have been a show-stopper for my plug-in architecture, except that I accidentally discovered a work-around for it. If I put a breakpoint on the Assembly.LoadFrom line, and hit F5 to allow it to continue after pausing on that breakpoint (for each plug-in), then the debugger symbols will in fact load. It seems like there's a timing problem, that the Visual Studio IDE needs a chance to "catch up" to hook into the DLL and load its symbols. If it loads too fast, without stopping at that breakpoint, more often than not (98%) the symbols don't get loaded. Stopping at that breakpoint each time, though, always works.

In extending my system for the non-CF world, I noticed that the Assembly class has some other Load methods that allow you to explicitly pass it the debugging symbol file:

Assembly.Load(byte[] rawAssembly, byte[] rawSymbolStore)

This is fantastic. It's sort of a shame that you can't just pass it the file name of the assembly, and the file name of the symbol file (why make it intuitive ), but it works.

So my question is: is there some way, via .NET CLR, P/Invoke, VS macro, voodoo witch doctor magic, or any other means, by which I could force Visual Studio to load the debugger symbols for my Compact Framework plugin assemblies

Dan


Re: .NET Compact Framework Assembly.LoadFrom not loading pdb debugging symbols

Noah Falk - MSFT

Hi Dan,

Apologies for replying to this so late, your post was just brought to my attention. The fact that placing a breakpoint allows the symbols to be loaded does seem very suspicious. I will need to investigate that issue a bit and see what I can find.

If the issue is just that VS can not find the pdbs you could certainly try things such as:

1) Add the path to the pdbs into the solution symbol paths using Tools->Options->Debugging->Symbols

2) From the modules window right click on a module that is lacking symbols, then select Load Symbols and browse to pdb location

Once I can investigate this a bit more I may be able to give you other options as well. Thanks for letting us know about this,

-Noah Falk

.Net Compact Framework





Re: .NET Compact Framework Assembly.LoadFrom not loading pdb debugging symbols

Noah Falk - MSFT

I tried to reproduce this issue but I was unsucessful (the symbols were found correctly and loaded). This is was I did:

Using VS 2005 and NetCF 2.0 I made a DeviceApplication project for a Windows Mobile 5 device. I placed this code in the Program.cs:

using System;

using System.Collections.Generic;

using System.Windows.Forms;

using System.Reflection;

namespace repro29340

{

static class Program

{

/// <summary>

/// The main entry point for the application.

/// </summary>

[MTAThread]

static void Main()

{

Assembly asm = Assembly.Load("ClassLibrary1");

Type t = asm.GetType("ClassLibrary1.Class1");

object obj = Activator.CreateInstance(t);

t.GetMethod("Foo").Invoke(obj, null);

Application.Run(new Form1());

}

}

}

And then I created an additional class library in the same project and placed this code in it:

using System;

using System.Collections.Generic;

using System.Text;

using System.Windows.Forms;

namespace ClassLibrary1

{

public class Class1

{

public void Foo()

{

MessageBox.Show("Hi there");

}

}

}

ClassLibrary1 references System.Windows.Forms.dll and the main app does not reference ClassLibrary1. I deployed both the executable and the class library, added a breakpoint on the MessageBox.Show line, and then did F5 on the exe project. Symbols loaded for the ClassLibrary1 correctly and the breakpoint was hit.

I would be happy to investigate the issue further but I will need a way to reproduce the problem. If it is useful to you in the future you can reference .Net Compact Framework bug #29340 which I created in our database for this issue.

-Noah Falk

.Net Compact Framework





Re: .NET Compact Framework Assembly.LoadFrom not loading pdb debugging symbols

dvboom

Hi Noah,

Thanks for your response. I thought nobody would take this one on! Smile

The issue is odd, and I'm guessing that a "hello, world" sort of example of code isn't going to trigger the bad behavior. In the real-world scenario, many add-ins are being loaded in rapid succession, and other work is being done. I wonder if something being "busy" or consuming a lot of CPU cycles could cause the delay.

As far as the suggestion to manually load the symbols... the whole point is that we're looking for these to load automatically. If we want a manual process, we already have one: we set a breakpoint, and step over it to make sure the symbols load. Letting this fly by, and then manually loading the symbol files would be more work.

I'm going to try to put together a bare bones version of what we've got here, and load multiple assemblies in a row rapidly to see if I can reproduce it outside of the production code. Maybe adding some "busy loops" or multiple threads will do it.

Thanks,

Dan






Re: .NET Compact Framework Assembly.LoadFrom not loading pdb debugging symbols

Noah Falk - MSFT

If/when you are able to put something together that reproduces the issue just let me know. I'll be happy to look at it.

-Noah Falk

.Net Compact Framework