I suspect that the "Object reference not set to an instance of an object" message is thown by your first project as this function runs fine here. Perheps your first project use some late binding types from Type.GetTypeFromProgId() or Type.GetTypeFromCLSID() ?