Код: Выделить всё
MyAddInmyaddin.dll зарегистрирован для Com Interop. Он реализует requestComadDinaUtomationservice (MS Office Thing), который возвращает объект COM, который затем позволяет приложению вызовать метод SetController . Это выглядит примерно так: < /p>
Код: Выделить всё
using MyWordAddIn;
using System.Runtime.InteropServices;
namespace MyWordAddIn;
[ComVisible(true)]
[Guid(IAddInUtilities_GUID)]
public interface IAddInUtilities
{
void SetController(object obj);
}
[ComVisible(true)]
[Guid(AddInUtilities_GUID)]
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(IAddInUtilities))]
public class AddInUtilities : StandardOleMarshalObject, IAddInUtilities
{
public void SetController(object obj)
{
Globals.ThisAddIn.Controller = obj;
}
}
Код: Выделить всё
var comInstance = ...;
var addInUtilities = (MyWordAddIn.IAddInUtilities)comInstance;
var ctrl = new Controller();
ctrl.Text = "test";
addInUtilities.SetController(ctrl);
< /code>
с контроллером, определенным таким: < /p>
[ComVisible(true)]
[Guid(Controller_GUID)]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Controller
{
public string Text { get; set; }
}
Код: Выделить всё
string txt = ((dynamic)this.Controller).Text;
Подробнее здесь: https://stackoverflow.com/questions/794 ... e-assembly