首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >srm.exe安装外壳扩展:失败,并显示“无法转换基础导出值”

srm.exe安装外壳扩展:失败,并显示“无法转换基础导出值”
EN

Stack Overflow用户
提问于 2014-08-22 14:11:50
回答 1查看 985关注 0票数 1

我用SharpShell编写了这个简单的外壳扩展(浏览器上下文菜单):

代码语言:javascript
复制
[ComVisible(true)]
[COMServerAssociation(AssociationType.AllFiles)]
public class SampleExtension : SharpContextMenu
{
    protected override bool CanShowMenu()
    {
        return true;
    }
    protected override ContextMenuStrip CreateMenu()
    {
        var menu = new ContextMenuStrip();
        var item = new ToolStripMenuItem
        {
            Text = "Hello world!"
        };
        menu.Items.Add(item);
        return menu;
    }
}

它可以与SharpShell服务器管理器一起调试,但当我尝试通过srm.exe在命令行上安装它时,我得到:

代码语言:javascript
复制
srm.exe install ..\SampleExtension\bin\Debug\CountLinesExtension.dll -codebase  

System.ComponentModel.Composition.CompositionContractMismatchException was unhandled
  HResult=-2146233088
  Message=Cannot cast the underlying exported value of type 'SharpShell.SharpShellServer (ContractName="SharpShell.ISharpShellServer")' to type 'SharpShell.ISharpShellServer'.
  Source=System.ComponentModel.Composition
  StackTrace:
       at System.ComponentModel.Composition.ExportServices.CastExportedValue[T](ICompositionElement element, Object exportedValue)
       at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)
       at System.ComponentModel.Composition.ExportServices.<>c__DisplayClassa`1.<CreateStronglyTypedLazyOfT>b__7()
       at System.Lazy`1.CreateValue()
       at System.Lazy`1.LazyInitValue()
       at System.Lazy`1.get_Value()
       at ServerRegistrationManager.Application.<LoadServerTypes>b__2(Lazy`1 st)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at ServerRegistrationManager.Application.InstallServer(String path, RegistrationType registrationType, Boolean codeBase)
       at ServerRegistrationManager.Application.Run(String[] args)
       at ServerRegistrationManager.Program.Main(String[] args)

如何解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2014-12-20 06:44:05

我们遇到了同样的问题。事实证明,我们只是没有从与我们的dll相同的目录运行srm.exe。我们的dll包含了其他dll,所以它不能以这种方式加载。一旦我们将所有dll放在同一个目录下运行srm.exe,它就可以工作了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25440626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档