I'm having a AppDomainUnloadedExcpetion from time to time on some machines when calling an addin hosted using MAF (System.AddIn). This is what my pipeline looks like:
[AddInContract]
public interface IGatewayV2 : IContract
{
ITopUpResultContract TopUpPhoneAccount(ITopUpRequestContract request);
}
This is my Host Adapter:
[HostAdapterAttribute()]
public class GatewayContractToViewHostSideAdapter : Dogs.Pipeline.HostView.IGatewayV2
{
private Dogs.Pipeline.Contracts.IGatewayV2 _contract;
private ContractHandle _handle;
public GatewayContractToViewHostSideAdapter(Dogs.Pipeline.Contracts.IGatewayV2 contract)
{
_contract = contract;
_handle = new ContractHandle(contract);
}
public TopUpResult TopUpPhoneAccount(TopUpRequest request)
{
var topupRequestViewToContractHostSideAdapter = new TopUpRequestViewToContractHostSideAdapter(request);
return
new TopUpResultContractToViewHostSideAdapter(
_contract.TopUpPhoneAccount(topupRequestViewToContractHostSideAdapter));
}
}
always on the host adapter side I have a topupRequestViewToContractHostSideAdapter:
class TopUpRequestViewToContractHostSideAdapter : ContractBase, ITopUpRequestContract
{
private TopUpRequest _topUpRequest;
public TopUpRequestViewToContractHostSideAdapter(TopUpRequest topUpRequest)
{
this._topUpRequest = topUpRequest;
}
//properties here
)
and a TopUpResultContractToViewHostSideAdapter which handles the reference to the external appdomain:
public class TopUpResultContractToViewHostSideAdapter : TopUpResult
{
private ITopUpResultContract _contract;
private ContractHandle _handle;
public TopUpResultContractToViewHostSideAdapter(ITopUpResultContract contract)
{
this._contract = contract;
_handle = new ContractHandle(contract);
}
//properties here
}
On the addin side instead I have the following code:
[AddInAdapter()]
public class GatewayViewToContractAddInSideAdapter : ContractBase, Dogs.Pipeline.Contracts.IGatewayV2
{
private Dogs.Pipeline.AddinViewV2.IGatewayV2 _view;
public GatewayViewToContractAddInSideAdapter(Dogs.Pipeline.AddinViewV2.IGatewayV2 view)
{
this._view = view;
}
public ITopUpResultContract TopUpPhoneAccount(ITopUpRequestContract request)
{
var result = _view.TopUpPhoneAccount(new TopUpRequestContractToViewAdapter(request));
return new TopUpResultViewToContractAdapter(result);
}
}
where the TopUpResultViewToContractAdapter is:
public class TopUpResultViewToContractAdapter : ContractBase, ITopUpResultContract
{
private TopUpResult _topUpResult;
public TopUpResultViewToContractAdapter(TopUpResult result)
{
this._topUpResult = result;
}
//properties here
}
and the TopUpRequestContractToViewAdapter is:
public class TopUpRequestContractToViewAdapter : TopUpRequest
{
private ITopUpRequestContract _contract;
private ContractHandle _handle;
public TopUpRequestContractToViewAdapter(ITopUpRequestContract contract)
{
_contract = contract;
_handle = new ContractHandle(contract);
}
//properties here
}
Everything seems compliant with what I've read so far and in particular with what I can read at this link: http://msdn.microsoft.com/en-us/library/bb384186(v=vs.100).aspx So I'm wondering if I'm doing something wrong or there is a possibility that the pipeline doesn't work on certain machines (as I'm having problem not on all the machines I'm using for testing).
Thanks for any hint.