本文介绍了srm.exe安装外壳程序扩展名:失败并显示“无法转换基础导出的值";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经用SharpShell编写了这个简单的shell扩展(浏览器上下文菜单):
I have written this simplistic shell extension (explorer context menu) with SharpShell:
[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
安装它时,会得到:
It works in debug with SharpShell Server Manager, but when I try to install it via srm.exe
on command line I get:
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)
该如何解决?
推荐答案
我们遇到了同一问题.原来我们只是没有从与dll相同的目录中运行srm.exe.我们的dll包含其他dll,因此无法以这种方式加载.一旦我们在同一个目录中同时运行了dll的srm.exe,它就会起作用.
We ran in into the same issue. Turns out we were just not running srm.exe from the same directory as as our dll. Our dll included other dlls so it would fail to load that way. Once we ran srm.exe with our dlls all in the same directory, it worked.
这篇关于srm.exe安装外壳程序扩展名:失败并显示“无法转换基础导出的值";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!