System.Addin “The target application domain has been unloaded”

I have just escaped an Alice in Wonderland type maze with System.AddIn namespace. It’s a bit of a nightmare to create the plumbing for an add-in so stay tuned in Visual Studio Magazine for a column on how to generate this so you only do the logical work

a)      Define the add-in API

b)      Write the add-in

If you have created one of these in .NET 3.5 you know how tremendously painful it can be. The particular gotcha that I spent numerous days spread over the last three months is that the host adapter much set the contract handle:

    Private _handle As System.AddIn.Pipeline.ContractHandle    Public Sub New(ByVal contract As ILinqGenerator)      Me.contract = contract      _handle = New System.AddIn.Pipeline.ContractHandle(contract)   End Sub 

Now, you might be like me and look at that line of code and say “Hey, no one anywhere is using the _handle variable, so why not just drop it.” That would be consistent with the fact the same sample has numerous Friend methods that are never used. Heck, FxCop is even going to tell me to get rid of this line of code.

However, it’s required. Without this line of code, you get the error “The target application domain has been unloaded.”

But I said I spent days on this, over months which meant I kept coming back its fair to ask why? But that’s the subject for another post.


2 thoughts on “System.Addin “The target application domain has been unloaded””

Leave a Reply

Your email address will not be published. Required fields are marked *