我需要开发一个引用其他自定义程序集的Shell上下文菜单扩展。我不想为那些自定义程序集分配强名称键!
我遵循的指南使用了SharpShell项目,并说明了如何对程序集进行签名(但不扩展为什么).这就是我的问题:如果我签署了我的最后一个.dll,那么在我的项目构建阶段有很多错误,因为有些程序集我的项目引用没有强命名(“引用的程序集没有强名称”)。
通常,谷歌有关C# Shell扩展实现,我发现的所有最好的教程签署最终的程序集.这是强制性的吗?
如果没有对程序集进行签名,ServerManager.exe将返回以下错误:"The file 'XYZ.dll' is not a SharpShell Server“。
发布于 2016-03-16 15:33:08
我终于解决了我的麻烦..。通过SharpShell.dll获得的NuGet文件是ServerManager.exe文件的不同版本。卸载SharpShell NuGet包并直接引用在ServerManager文件夹中找到的SharpShell.dll是我的解决方案!
而且,我在看文章的评论.请阅读这问题。
发布于 2017-11-01 11:16:40
您不需要使用旧的DLL。请直接使用此代码,而不使用ServerManager.exe。
private static ServerEntry serverEntry = null;
public static ServerEntry SelectedServerEntry
{
get
{
if (serverEntry == null)
serverEntry = ServerManagerApi.LoadServer("xxx.dll");
return serverEntry;
}
}
public static ServerEntry LoadServer(string path)
{
try
{
// Create a server entry for the server.
var serverEntry = new ServerEntry();
// Set the data.
serverEntry.ServerName = Path.GetFileNameWithoutExtension(path);
serverEntry.ServerPath = path;
// Create an assembly catalog for the assembly and a container from it.
var catalog = new AssemblyCatalog(Path.GetFullPath(path));
var container = new CompositionContainer(catalog);
// Get the exported server.
var server = container.GetExport<ISharpShellServer>().Value;
serverEntry.ServerType = server.ServerType;
serverEntry.ClassId = server.GetType().GUID;
serverEntry.Server = server;
return serverEntry;
}
catch (Exception)
{
// It's almost certainly not a COM server.
MessageBox.Show("The file '" + Path.GetFileName(path) + "' is not a SharpShell Server.", "Warning");
return null;
}
}安装代码:
ServerRegistrationManager.InstallServer(SelectedServerEntry.Server, RegistrationType.OS64Bit, true);注册代码:
ServerRegistrationManager.RegisterServer(SelectedServerEntry.Server, RegistrationType.OS64Bit);https://stackoverflow.com/questions/35991182
复制相似问题