签署F#装配(强名称组件)

我在CodeProject上发现了这篇文章
http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus

并且认为尝试一下是很好的,但是在F#中.所以我想出了以下代码

open System
open System.IO
open System.Text
open System.Runtime.InteropServices
open System.Windows.Forms
open SharpShell
open SharpShell.Attributes
open SharpShell.SharpContextMenu

[<ComVisible(true)>]
[<COMServerAssociation(AssociationType.ClassOfExtension,".txt")>]
type CountLinesExtension() =
    inherit SharpContextMenu.SharpContextMenu()

    let countLines =
        let builder = new StringBuilder()
        do 
            base.SelectedItemPaths |> Seq.iter (fun x -> builder.AppendLine(sprintf "%s - %d Lines" (Path.GetFileName(x)) (File.ReadAllLines(x).Length)) |> ignore  )
            MessageBox.Show(builder.ToString()) |> ignore

    let createMenu =
        let menu = new ContextMenuStrip()
        let itemCountLines = new ToolStripMenuItem(Text = "Count Lines")
        do
            itemCountLines.Click.Add (fun _ -> countLines)
            menu.Items.Add(itemCountLines) |> ignore
        menu

    override this.CanShowMenu() = true
    override this.CreateMenu() = createMenu

但是,我注意到在VS2012中不支持签名F#程序集(文章中的第4步).我了解到,如果我想这样做,我需要手动创建一个键(在命令提示符下键入“sn -k keyName.snk”),然后在“项目属性 – >构建 – >其他标志“(–keyfile:keyName.snk).

我还没有成功运行这个.此外,使用作者的应用程序(在“调试Shell扩展”部分)我收到一个错误,我的程序集不包含COM服务器.

我相信我在签署组件时发生错误.你能帮助我运行这个吗?

通过AssemblyFileKeyAttribute属性来签署F#程序集的一种方式.

创建一个新的模块,并在其中:

module AssemblyProperties

open System
open System.Reflection;
open System.Runtime.InteropServices;

[<assembly:AssemblyKeyFileAttribute("MyKey.snk")>]

do()

其中“MyKey.snk”是相对于项目目录的键的路径.

另一种方法,在Microsoft Connect的这个错误报告中发现,是将–keyfile:MyKey.snk添加到“属性”中的“其他标志”字段中.构建选项卡.

使用任一方法;运行sn -v myfsharpassembly.dll将声明程序集在编译后有效.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...