首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.NET ShellExtension (Framework4.5,Windows8.1,SharpShell)无法工作

.NET ShellExtension (Framework4.5,Windows8.1,SharpShell)无法工作
EN

Stack Overflow用户
提问于 2013-09-17 06:46:27
回答 1查看 3.5K关注 0票数 3

我尝试在Windows8.1中实现一个自定义ShellExtension。发现了非常好的SharpShell教程

代码语言:javascript
复制
[ComVisible(true)]
[COMServerAssociation(AssociationType.AllFiles)]
public class CountExtProvider : SharpContextMenu
{
    protected override bool CanShowMenu()
    {
        //  We will always show the menu.
        return true;
    }

    protected override ContextMenuStrip CreateMenu()
    {
        //  Create the menu strip.
        var menu = new ContextMenuStrip();

        //  Create a 'count lines' item.
        var itemCountLines = new ToolStripMenuItem
        {
            Text = "Count Lines"
        };

        //  When we click, we'll call the 'CountLines' function.
        itemCountLines.Click += (sender, args) => CountLines();

        //  Add the item to the context menu.
        menu.Items.Add(itemCountLines);

        //  Return the menu.
        return menu;
    }

    private void CountLines()
    {
        //  Builder for the output.
        var builder = new StringBuilder();

        //  Go through each file.
        foreach (var filePath in SelectedItemPaths)
        {
            //  Count the lines.
            builder.AppendLine(string.Format("{0} - {1} Lines",
              Path.GetFileName(filePath), File.ReadAllLines(filePath).Length));
        }

        //  Show the ouput.
        MessageBox.Show(builder.ToString());
    } 
}

我是在一个Windows8.1RTM x64环境中,所以我在Visual 2013 RC中将构建平台更改为x64。添加了一个密钥文件来签署我的*.dll。但是,如果我想注册我的*.dll,什么都不会发生:

代码语言:javascript
复制
regasm ShellExtensions.dll

命令行表示注册是成功的,但是在上下文菜单中没有条目。我在这里做错了什么?这在Windows8.1中不再适用吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-17 19:50:24

我在使用regasm.exe时也遇到了同样的问题。

此外,在通过regasm注册程序集时,还有许多事情要提及。

例如,您必须使用x64/x86版本的regasm.exe,这取决于您的系统。

  • x64:C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regAsm.exe
  • x86:C:\Windows\Microsoft.NET\Framework\v4.0.30319\regAsm.exe

在有了这么多问题之后,我切换到了ServerManager.exe,它是SharpShell工具的一部分。它可以在项目页上下载。

使用起来非常容易:

  • 用"Load server.“加载DLL
  • 点击“安装服务器(xYZ)”
  • 然后是“注册服务器(xYZ)”

重新启动Windows资源管理器,您应该完成(不一定需要)。

我完全同意上述教程作者的观点

服务器管理器工具 服务器管理器工具是我最喜欢的安装/卸载和注册/注销方法,至少在开发期间是这样的,因为它允许您作为单独的步骤安装和注册。它还将允许您指定是在32位还是64位模式下安装/卸载etc。

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

https://stackoverflow.com/questions/18843008

复制
相关文章

相似问题

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