首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Regasm在dll上不起作用

Regasm在dll上不起作用
EN

Stack Overflow用户
提问于 2013-09-02 21:43:44
回答 1查看 1.2K关注 0票数 0

我正在使用SharpShell在c#中创建一个IconHandler外壳扩展。这是我的dll的代码。

代码语言:javascript
复制
using SharpShell.Attributes;
using SharpShell.SharpIconHandler;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace DllIconHandler
{
    [ComVisible(true)]
    [COMServerAssocation(AssociationType.ClassOfExtension, ".jxe")]
    public class DllIconHandler : SharpIconHandler
    {
        protected override Icon GetIcon(bool smallIcon, uint iconSize)
        {
            Icon icon = null;
            FileInfo file = new FileInfo(SelectedItemPath);
            long size = file.Length;

            if (size > 0)
            {
                icon = new Icon("C:\\Users\\Owner\\Desktop\\icon1.ico");
            }
            else
            {
                icon = new Icon("C:\\Users\\Owner\\Desktop\\icon2.ico");
            }

            return GetIconSpecificSize(icon, new Size((int)iconSize, (int)iconSize));
        }
    }
}

我将其构建为dll并将其移动到我的桌面上。然后,我以管理员身份在命令提示符中使用以下命令在dll上运行regasm。

代码语言:javascript
复制
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe C:\Users\Owner\Desktop\DllIconHandler.dll /codebase

但是当我这样做时,会出现一个错误

代码语言:javascript
复制
RegAsm : error RA0000 : An error occurred inside the user defined Register/Unreg
ister functions: System.InvalidOperationException: Cannot open default icon key
for class jxe_auto_file
   at SharpShell.ServerRegistration.ServerRegistrationManager.SetIconHandlerDefa
ultIcon(RegistryKey classesKey, String className)
   at SharpShell.ServerRegistration.ServerRegistrationManager.RegisterServerAsso
ciations(Guid serverClsid, ServerType serverType, String serverName, Association
Type associationType, IEnumerable`1 associations, RegistrationType registrationT
ype)
   at SharpShell.SharpShellServer.DoRegister(Type type, RegistrationType registr
ationType)

注册表中似乎有问题。

EN

回答 1

Stack Overflow用户

发布于 2015-01-20 21:05:40

注册表中的条目应如下所示:

HKEY_CLASSES_ROOT

jxe_auto_file

DefaultIcon:(默认)(图标的路径)

我非常确定您的jxe_auto_file条目中没有"DefaultIcon“

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

https://stackoverflow.com/questions/18574753

复制
相关文章

相似问题

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