如何为我的COM DLL项目注册DocumentFormat.OpenXml.dll

时间:2017-07-17 12:31:37

标签: c# dll com gac regasm

我在项目中使用程序集有一个小问题。 我必须使用COM dll,在其他应用程序中使用,使用OpenXML SDK来加快xlsx文件的加载速度。它在我的机器上完美运行。但是有问题,然后我试图将我的项目移植到另一台机器上。 对于COM dll,我按" regasm"创建reg文件。注册我的COM DLL类注册表。没有参考OpenXML dll它可以很好地工作,但是参考OpenXML dll会导致80040154错误。 我用dll&reg和资源中的reg文件制作小程序,在新机器上注册我的COM dll。 在manifest.app中添加:

<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />

正如我所说的没有OpenXML dll - COM dll可行。 起初我认为,我应该在GAC中注册新机器DocumentFormat.OpenXml.dll。我试图用Publish.Gacinstall()来做,但没有结果。

namespace Reger_XLSReader
{
    class Program
    {
        static void Main()
        {
            string dir = @"c:\windows\system32\";
            File.WriteAllBytes(dir + "XLSReader.dll", Properties.Resources.XLSReader);
            File.WriteAllText("xls.reg", Properties.Resources.xls);
            File.WriteAllBytes(dir  + "DocumentFormat.OpenXml.dll", Properties.Resources.DocumentFormat_OpenXml);
            Publish pub = new Publish();
            pub.GacInstall(dir  + "DocumentFormat.OpenXml.dll");
            Process.Start("xls.reg");
        }
    }
}

我尝试在新机器上手动安装OpenXML SDK并检查DocumentFormat.OpenXml.dll的GAC注册 - 它已注册,但我仍然有错误。 80040154 - 班级未注册。 我不明白,VS2015对我的DLL和DocumentFormat.OpenXml.dll的正常工作以及如何在没有VS的机器上进行操作。 在我的实验中,我使用DocumentFormat.OpenXml.dll制作了Windows窗体应用程序,并将其移植到其他机器上。无需在GAC中注册并在机器上安装OpenXML SDK即可完美运行。所有它需要 - DocumentFormat.OpenXml.dll与exe目录相同。

所以问题是 - 我该怎么做,在任何机器上使用我的COM dll参考DocumentFormat.OpenXml.dll?

抱歉错误的英语。

0 个答案:

没有答案