.NET She​​llExtension(框架4.5时,Windows 8.1,SharpShell)不工作 [英] .NET ShellExtension (Framework 4.5, Windows 8.1, SharpShell) not working

查看:314
本文介绍了.NET She​​llExtension(框架4.5时,Windows 8.1,SharpShell)不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows 8.1 ,以实现自定义ShellExtension。研究发现,真正的好 SharpShell教程

I tried to implement a custom ShellExtension in Windows 8.1. Found that really good SharpShell tutorial.

[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());
    } 
}

我在的Windows 8.1 RTM 64 环境,所以我改变了我的构建plattform到x64的的Visual Studio 2013 RC 。增加了密钥文件让我签字* .dll文件。 但是,如果我想注册我的* .dll没有happends:

I am in a Windows 8.1 RTM x64 environment, so I changed my build plattform to x64 in Visual Studio 2013 RC. Added a Key-File to sign my *.dll. But if I want to register my *.dll nothing happends:

regasm ShellExtensions.dll

在命令行称注册成功,但在上下文菜单中没有该项。 我在做什么错在这里?这是否适用于Windows 8.1没有更多?

The command line says registering was successful but in the context menu there is no entry. What I am doing wrong here? Does this work with Windows 8.1 no more?

推荐答案

我在使用了同样的问题 regasm.exe
此外,还有很多事情通过 regasm 注册组件时,提了。
例如,你必须使用regasm.exe的64位/ x86版本,这取决于你的系统。

I had the same problem while using regasm.exe.
Furthermore there are many things to mention when registering an assembly through regasm.
For example you have to use the x64/x86 version of the regasm.exe, depending on your system.

  • 64: C:\ WINDOWS \ Microsoft.NET \ Framework64 \ v4.0.30319 \ regAsm.exe
  • 86: C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ 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工具的一部分。它可以下载在项目页面
用法很简单:

After having so many problems, I switched to the ServerManager.exe, which is part of the SharpShell Tools. It can be downloaded on the project page.
The usage is quite easy:

  • 加载DLL与加载服务器...
  • 点击安装服务器(XYZ)
  • 在这之后的注册服务器(XYZ)

重新启动Windows资源管理器,你应该做的(不是必需的)。

Restart the Windows Explorer and you should be done (not necessarily needed).

我完全同意的提到了笔者的点<一个href="http://www.$c$cproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus">tutorial:

I fully agree with the point of the author of the mentioned tutorial:

服务器管理工​​具是我的preferred方法来   在安装/卸载和注册/注销,至少在   发展,是因为它可以让你安装并注册为独立的   脚步。它也将让您指定不管你是   安装/卸载等32位或64位模式。

The Server Manager Tool

The Server Manager Tool is my preferred approach for installing/uninstalling and registering/unregistering, at least during development, because it lets you install and register as separate steps. It will also let you specify whether you're installing/uninstalling etc in 32 bit or 64 bit mode.

这篇关于.NET She​​llExtension(框架4.5时,Windows 8.1,SharpShell)不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆