Edit 2008-08-13: Problem solved. See below for the initial error.
I was on the completely wrong track (of course). As i said below i'm creating an addin for SSMS, and addins is loaded from whitin SSMS and it looks for a class implementing interface IDTExtensibility2. All i got from in the output log from Visual Studio was two exceptions (System.NullReferenceException and System.TypeInitializationException) and the first should have put me on the right track but it didn't and i've lost 3 days of coding. I didn't get the contents of the exceptions (for example stacktrace or any innerexceptions) so i had nothing to continue my search.
The error message i got was "Error Message: <Unknown Error>. Error number: 80131534", which didn't help me at all. After 3 days i got a hunch and created a new empty project, adding the addin as a reference and executed it.
Connect connect = new Connect();
Array poff = null;
connect.OnConnection(null, Extensibility.ext_ConnectMode.ext_cm_Startup, null, ref poff);
[/code]
Now i got the exception dialog and was able to trace it to a static class with some static member variables using a helper class. In that helper class i had added a .toString() for one of the parameters and ofcourse the static member variables supplied null in the parameter and there is the System.NullReferenceException.
Problem solved!
------------------
I get the error below when trying to load my addin in SSMS. It might be that .Net framework 3.5 seems to be a bit corrupt on my machine since when i try to re-install framework 3.5 i get an error. Today 3.5 sp1 will be released so i'll try that and update this post.
Edit: I tried to do a repair in "Uninstall or change a program" which reported success, but i still get the same error.
Edit: Installed both sp1 of Visual Studio 2008 and sp1 of .Net 3.5 and still same error.
---------------------------
Microsoft SQL Server Management Studio
---------------------------
The Add-in 'xxx addin, SQL Server Management Studio Extension' failed to load or caused an exception.
Would you like to remove this Add-in?
If you choose yes, you will need to reinstall the Add-in to use it again.
Error Message: <Unknown Error>
Error number: 80131534
---------------------------
Yes No
---------------------------