简体   繁体   English

如何从EXE调用/调用VSTO生成的插件(DLL)

[英]How to call/Invoke a VSTO generated addin(DLL) from an EXE

I have created a VSTO Word Addin. 我创建了一个VSTO Word插件。 It has generated a DLL file. 它已生成一个DLL文件。 I don't want to deploy that as an EXE. 我不想将其部署为EXE。 But I want to use a C# application(EXE) to call or invoke this VSTO dll. 但是我想使用C#应用程序(EXE)来调用或调用此VSTO dll。 Is this possible? 这可能吗? If possible how do I implement? 如果可能的话,我该如何实施?

Please note that I don't want to deploy my Addin as an EXE. 请注意,我不想将我的外接程序部署为EXE。 I only want my VSTO addin to remain as a DLL and then to be called from an EXE. 我只希望我的VSTO插件保持为DLL,然后从EXE进行调用。

I have tried the below approach with no luck. 我没有运气尝试过以下方法。

1) WordAddIn.ThisAddIn addin = new WordAddIn.ThisAddIn(null, null);

Here the WordAddin is the VSTO dll. 这里的WordAddin是VSTO dll。

2) Using Reflection
Assembly newAssembly = Assembly.LoadFile("C:...bin\\Debug\\WordAddin.dll");

Type[] types = newAssembly.GetExportedTypes();
Type entryType = newAssembly.GetType("ThisAddin");
object o = Activator.CreateInstance(types[0], true);

I get 'No parameterless constructor defined for this object.' 我得到“没有为此对象定义无参数构造函数。” in this case. 在这种情况下。

Unable to go further!. 无法走得更远! Kindly suggest. 请提示。

VSTO is for purely for customizing MS Office via add-ins; VSTO仅用于通过加载项自定义MS Office。 there is no sane way to use this with your .Net exe. 没有明智的方法来与您的.Net exe一起使用。 For extending your own .Net exe with add-ins see the following resources: 有关使用加载项扩展您自己的.Net exe的信息,请参见以下资源:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM