Hello,
I want to have a callback function implemented by an addin. The function should generate an array of elements which are returned and are used by the host application.
Let's assume a simple class A
public class A
{
public String m_B;
public String m_C;
public A(String B, String C)
{
m_B = B;
m_C = C;
}
}
The signature of the callback function should be something like
public A[] MyCallbackFunction(String Param1, String Param2)
For easy programming I define the method
virtual public A[] MyCallbackFunction(String Param1, String Param2)
{ return null; }
in the host class (isAddInEntryPoint = true). I generate the proxy for the object model and a proxy class for A is generated.
The idea is to overwrite that method in the addin like
public override MyCallbackFunction(String Param1, String Param2)
{
return new A[] { new A(Param1, "0815"), new A(Param2, "42") };
}
The problem is that the proxy class for A has only one constructor
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
[global::System.ComponentModel.BrowsableAttribute(false)]
public A(global::System.AddIn.Contract.IContract contract, global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager) {
this.remoteObject = null;
if (contract == null)
throw new global::System.ArgumentNullException("contract");
if (typeInfrastructureManager == null)
throw new global::System.ArgumentNullException("typeInfrastructureManager");
global::System.AddIn.Contract.Automation.IRemoteObjectContract remoteObjectContract =
(global::System.AddIn.Contract.Automation.IRemoteObjectContract)contract.QueryContract(typeof(global::System.AddIn.Contract.Automation.IRemoteObjectContract).AssemblyQualifiedName);
remoteType = null;
this.RemoteObject = new global::Microsoft.VisualStudio.Tools.Applications.RemoteObject(remoteObjectContract, typeInfrastructureManager);
this.RemoteType = this.RemoteObject.GetType();
}
So it looks like I always have to create object instances at host context and are only able to pass them from the host to the addin and not vice versa?