views:

36

answers:

1

I am doing some work on a windows CE 6.0 application. The application loads a number of external assemblies dynamically using.

Assembly assembly = Assembly.Load(path);

These .dll files are outside of the solution, but there are classes in each of them that implement a common interface.

Once the assemblies are loaded the application loops through each of the classes and instansiates an instance, then calls the .Load() method on each of them.

//in class definition
private log4net.ILog _log = log4net.LogManager.GetLogger(this.GetType());


//in looping method
foreach (IPlugin plugin in _plugins)
{
    try
    {
        plugin.Load();
    }
    catch (Exception e)
    {
        string message = string.Format("Plugin load error: {0}", plugin.Name); //breakpoint gets set here.
        if (_log.IsErrorEnabled) _log.Error(message, e);
    }
}

This works fine when I deploy the application to the device and run it. However, when I run this in the debugger (attached to the device, not an emulator) the Load() method of one of the plugins is throwing a 'System.NotSupportedException', which is caught and we attempt to log it. However, the _log.IsErrorEnabled property of the Log4Net log is also throwing a NotSupportedException also.

I get some very odd behavior when I set a breakpoint on the line where I build the message. If I inspect the _log object in the watch window I see that the IsErrorEnabled and IsFatalEnabled properties are both throwing NotSupportedExceptions, but the other IsXXXEnabled Properties return True or False as they should.

Additionally, if I inspect the Exception 'e' (which is a NotSupportedException), I am seeing the following in it's StackTrace Property:

'((System.Exception)($exception)).StackTrace' threw an exception of type 'System.NotSupportedException'

My question is what could be causing this apparent breakdown in the debugging environment? I feel like the fact that some of Log4Net's IsXXXEnabled methods are working and others are not could be a clue.

A: 

Is sounds very suspiciously like you're low on memory and the runtime is having problems loading the debug info for your targets. What does the memory division look like on the device?

ctacke