首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SharpShell服务器.dll未签名

SharpShell服务器.dll未签名
EN

Stack Overflow用户
提问于 2016-03-14 15:09:36
回答 2查看 1.4K关注 0票数 1

我需要开发一个引用其他自定义程序集的Shell上下文菜单扩展。我不想为那些自定义程序集分配强名称键!

我遵循的指南使用了SharpShell项目,并说明了如何对程序集进行签名(但不扩展为什么).这就是我的问题:如果我签署了我的最后一个.dll,那么在我的项目构建阶段有很多错误,因为有些程序集我的项目引用没有强命名(“引用的程序集没有强名称”)。

通常,谷歌有关C# Shell扩展实现,我发现的所有最好的教程签署最终的程序集.这是强制性的吗?

如果没有对程序集进行签名,ServerManager.exe将返回以下错误:"The file 'XYZ.dll' is not a SharpShell Server“。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-03-16 15:33:08

我终于解决了我的麻烦..。通过SharpShell.dll获得的NuGet文件是ServerManager.exe文件的不同版本。卸载SharpShell NuGet包并直接引用在ServerManager文件夹中找到的SharpShell.dll是我的解决方案!

而且,我在看文章的评论.请阅读问题。

票数 3
EN

Stack Overflow用户

发布于 2017-11-01 11:16:40

您不需要使用旧的DLL。请直接使用此代码,而不使用ServerManager.exe。

代码语言:javascript
复制
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;
            }
        }

安装代码:

代码语言:javascript
复制
ServerRegistrationManager.InstallServer(SelectedServerEntry.Server, RegistrationType.OS64Bit, true);

注册代码:

代码语言:javascript
复制
ServerRegistrationManager.RegisterServer(SelectedServerEntry.Server, RegistrationType.OS64Bit);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35991182

复制
相关文章

相似问题

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