Csharp/C#教程:.NET ShellExtension(Framework 4.5,Windows 8.1,SharpShell)无效分享


.NET ShellExtension(Framework 4.5,Windows 8.1,SharpShell)无效

我试图在Windows 8.1中实现自定义ShellExtension 。 发现真的很好的SharpShell教程 。

[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 x64环境中,所以我在Visual Studio 2013 RC中将构建平台更改为x64。 添加了一个密钥文件来签署我的* .dll。 但如果我想注册我的* .dll什么都不会发生:

 regasm ShellExtensions.dll 

命令行说注册成功但在上下文菜单中没有条目。 我在这做错了什么? 这不再适用于Windows 8.1吗?

我在使用regasm.exe遇到了同样的问题。
此外,通过regasm注册程序集时还有许多事情需要注意。
例如,您必须使用regasm.exe的x64 / x86版本,具体取决于您的系统。

遇到这么多问题之后,我切换到了ServerManager.exe ,这是SharpShell Tools的一部分。 它可以在项目页面上下载。
用法很简单:

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

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

服务器管理器工具

服务器管理器工具是我首选的安装/卸载和注册/取消注册的方法,至少在开发期间,因为它允许您作为单独的步骤进行安装和注册。 它还允许您指定是在32位还是64位模式下安装/卸载等。

上述就是C#学习教程:.NET ShellExtension(Framework 4.5,Windows 8.1,SharpShell)无效分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/943366.html

(0)
上一篇 2021年11月14日
下一篇 2021年11月14日

精彩推荐