May 31, 2010

The Following Module was built either with optimizations enabled or without debug information

So I am trying to debug this Win service (built with VS2008) that references a module (DLL containing Managed C++ that was built with VS2010) and I keep getting a message box (see title) when attaching to the service process with VS2010.

Plowing through the web, found this solution that oddly enough worked:

I unchecked the "Enable just my code(managed only)" in (VS2010) Debug -> Options -> Debugging -> General

The code that had breakpoints was built in Debug Mode and I am pretty sure that I wrote it. So disabling just my code in the debug options makes no sense.

And, there's not much to be found on the subject on the net. Hopefully this SO post will develop in the future.

May 8, 2010

Static constructor of a derived class is called before the static constructor of the base class

However, for non-static constructors, the order is the other way around. See examples below:

Example 1. Static constructors

public class Test
    {
        static Test()
        {
            Console.WriteLine("test constructor");
        }
    }

    public class TestExtended : Test
    {
        static TestExtended()
        {
            Console.WriteLine("test extended constructor");
        }
    }

Output:
test extended constructor
test constructor

Example 2. Public constructors

public class Base
    {
        public Base()
        {
            Console.WriteLine("base constructor");
        }
    }

    public class BaseExtended : Base
    {
        public BaseExtended()
        {
            Console.WriteLine("base extended constructor");
        }
    }

Output:
base constructor
base extended constructor