首页 > 技术文章 > OSGI.NET 插件无法启动之情景一

wisdo 2016-06-30 21:41 原文

  关于osgi.net 的使用网上也有不少的资料,最近在使用osgi.net  开发插件的时候,遇到了这样的bug,造成插件甚至整个项目都无法启动,异常的具体消息如下:

  Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "UIShell.iOpenWorks.WinForm.Properties.Resources.resources" was correctly embedded or linked into assembly "ConfigFileConvert" at compile time, or that all the satellite assemblies required are loadable and fully signed.

  在网上查了很多资料也没能解决,最后发现,是扩展点的名称写错了。为了避免以后犯同样的错误,同时也方便其它开发人员参考,就有了这篇博客。废话不多说,具体解决方法如下:

1.在Mainfest.xml 文件中,Extension 节点中的 Point 属性,要正确的赋值。

 

<Extension Point="UIShell.Applications">
    <Application Title="Wisdo Demon" ToolTip="Wisdo Demon" Icon="ConfigFileConvert.SvgPlugin.Resources.Conversion128.png.png.png.png">
      <Menu Text="Wisdo Demon" ToolTip="Wisdo Demon" Icon="ConfigFileConvert.SvgPlugin.Resources.OneFileConvert.png.png.png" Class="ConfigFileConvert.SvgPlugin.SvgControl" />
    </Application>
  </Extension>
  <Extension Point="PageFlowService.PageNode">
    <PageNode Name="AppCenterPage" Priority="50" Value="ConfigFileConvert.SvgPlugin.SvgControl" />
  </Extension>
  <Extension Point="UIShell.BundleManagementOptions">
    <BundleManagementOption AllowToStarted="true" AllowToStopped="false" AllowToUninstalled="false" />
  </Extension>

  其中Point 的属性值,不是随便定义的,它是预先定义好的,也就是说,它一定存在于另一个插件中,该插件向外公开自己的扩展点,并定义了对该扩展点进行监听的事件,如果某个插件扩展了该扩展点(或引用了该扩展点),那么定义扩展点的插件就会对扩展了该扩展点的插件自动监听,这也是OSG.NET  的特点。插件在定义扩展点的时候,使用的是 ExtensionPoint 节点,其中有Point属性,提供给其它插件进行扩展,而在扩展插件中,使用 Extension 来扩展一个定义好的扩展点,Point 属性值 就是所谓的扩展点名字(ExtensionPoint 节点中的Point属性值 )。

关于扩展点的定义如下:

  <ExtensionPoint Point="PageFlowService.PageFlow" />
  <ExtensionPoint Point="PageFlowService.PageNode" />

  

2. 查看日志文件来定位异常

    OSGI.NET 框架都有运行日志记录的,如果遇到了异常或插件无法启动,这时可以查看日志文件来准确定位

 

3 . 相关资料

  UIOSP 官网:http://www.iopenworks.com/

  OSGI.NET 官网:http://osgi.codeplex.com/

 

推荐阅读