的ActiveX DLL错误 [英] ActiveX DLL Error

查看:235
本文介绍了的ActiveX DLL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK,而我从来没有在2012年我会写我的第一个ActiveX控件(当然有它一个很好的理由),我用得到它的Windows 7(64位)下运行挣扎想。

OK while I never thought in 2012 I would be writing my first ActiveX control (and yes there is a good reason for it) I am struggling with getting it running under Windows 7 (x64).

解决方案短篇小说:我是从我的一些regasm来电丢失/代码库,并混合了32位和64位的过程,但是这不是由帮助标VS2010命令提示符下混合为regasm和CSCRIPT 32位和64位的路径

The Solution Short Story: I was missing /codebase from some of my regasm calls and also mixing up 32 and 64 bit processes, but that wasn't being helped by the standard VS2010 command prompt mixing up 32 and 64 bit paths for regasm and cscript.

长的故事如下:

我一直

<罢工>的使用C#在.net中创建ActiveX控件

哎呀我有错误的链接。虽然它看起来像我最初提供被别人复制原始博客页面的链接)

(Oops I had the wrong link .. although it looks like the link I initially supplied was someone copying the original blog page)

创建ActiveX使用C#控制在.ne​​t中

Creating an ActiveX control in .Net using C#

C#ActiveX控件(CSActiveX)

和我看起来是建设项目顺利(对于后者,我不得不改变资源编译器的位置到正确的位置)。

And I appear to be building the projects successfully (for the latter one I had to change the resource compiler location to the correct location).

有关的第一个项目,我使用建议的安装程序,第二个项目,我想直接使用regasm。

For the first project I am using the suggested installer, for the second project I am trying to use regasm directly.

但经过这一点,一切顺利下山。我尝试注册所有的,但无论是:

But after this it all goes down hill. I try and register the all's but either:


  1. 我不知道我应该如何注册它们,或者:

  2. 我不知道我应该如何注册它们。

我的测试案例已经包含了一个简单的JScript文件

My test case has been a simple JScript file containing

var x = new ActiveXObject( "name of object" );

哪些失败,出现错误:

test.js(1,1)的Microsoft JScript运行时错误:自动化服务器不能创建对象

test.js(1,1) Microsoft JScript runtime error: Automation Server can't create object

我不知道这是否是权限问题,或32和64位的问题或组合。

I am not sure if this is a permissions issue, or a 32 vs 64 bit issue or a combination.

了很多的ActiveX提供帮助网站都假设你将通过网页来访问它,所以我试图寻找IE的权限(即使我想加载控制成第三部分程序)。

A lot of sites offering help on ActiveX are assuming you will be accessing it via a web page , so I have tried looking at IE permissions (even though I want to load the control into a 3rd part program).

我知道,如果我请使用框架或regasm的framework64版本,我可以控制在注册表项获得把 - 而我所看到的运行CSCRIPT为32位或64位取决于调用CMD外壳(这可能会影响什么注册表的一部分进行搜索)一些参考(我已经试过两种方式,以及尝试一个管理员壳)。

I know if I use either the 'framework' or 'framework64' versions of regasm I can control where in the registry entries get put - and I have seen some references to running cscript as either 32 or 64 bit (which possible affects what part of the registry is searched) depending on the cmd shell invoked (and I have tried both ways, as well as trying an "administrator" shell).

所以基本上,在这一点上我不知道我在做什么或者我应该做的。

So basically at this point I have no idea what I am doing or what I should be doing.

我的目标是注册在Windows 7 x64上的ActiveX控件,并将它能够通过加载:

My goal is to register an ActiveX control on Windows 7 x64 and have it be able to be loaded by:


  1. 系统测试脚本.js文件从默认的Windows命令提示符

  2. 装入同一控制成类似Excel 2007中的VBA(只用于测试)
  3. 加载控件到第三部分的应用程序(的RSView Studio的罗克韦尔),并把它主持了VBA应用程序中(我需要检查,如果这32 ISA或64位程序。我怀疑是前者)

备注

有关的项目,用户安装程序(使用C#在.NET中创建一个ActiveX控件),它会安装代码到C:\program文件(x86)\和注册表编辑器的样子,我觉得Computer\HKEY_CLASSES_ROOT\Wow6432Node\\项下\\CLSID\我相信是告诉我,该DLL安装为32位进程。我试图运行的同时从32位和64位CMD我CSCRIPT测试,他们都失败。注意,安装程序正在创造regasm /基本代码时,它跑的等价物。

For the project that users the installer (Creating an ActiveX control in .Net using C#), it installs the code into "c:\program Files (x86)\" and looking with regedit I find entries under "Computer\HKEY_CLASSES_ROOT\Wow6432Node\CLSID\" which I believe is telling me that the DLL was installed as a 32 bit process. I have tried running my cscript test from both a 32 and 64 bit cmd and they both fail. NOTE that the installer was creating the equivalent of "regasm /codebase" when it ran.

有关,我使用regasm注册它(C#ActiveX控件试图项目(CSActiveX )),它有注册的ActiveX COM控件一些额外的代码。此代码提到注册32位进程内服务器(见ActiveXCtrlHelpers.cs)

For the project where I tried using regasm to register it (C# ActiveX control (CSActiveX)), it has some additional code for registering an ActiveX COM control. This code mentions registering 32 bit in-process servers (see ActiveXCtrlHelpers.cs)

(顺便说一句,我此刻也骂自动在Safari /狮子正确的,不断变化的小写的DLL到全能)

(BTW I'm also cursing auto correct in Safari/Lion at the moment, keeps changing lower case "DLL" into "all")

修改2012-08-07

这是艺术的回答提示我发现:

Prompted by Art's answer I discovered:

从标准VS2010命令提示符

当通过标准VS2010命令提示符下运行'regasm /基本代码(和管理员允许regasm进行改变),条目得到倒入HKEY_CLASSES_ROOT\Wow6432Node下的注册表\CLSID和测试脚本从相同的提示失败。

When running 'regasm /codebase' through the standard VS2010 command prompt (and as administrator to allow regasm to perform changes), the entries got dumped into the registry under HKEY_CLASSES_ROOT\Wow6432Node\CLSID and the test scripts failed from the same prompt.

不过,我可以在Excel中看到ActiveX控件2007(32位)

However I can see the ActiveX control in Excel 2007 (32 bit)

从64 Win64的VS2010命令提示符

当在Visual Studio 2010的64位Win64的命令提示符下运行(再次作为管理员)的注册表项出现HKEY_CLASSES_ROOT\CLSID下,但这次的测试脚本来自相同的提示,也从工作标准Windows的命令提示符(但他们从32位提示失败)

When running under the VS2010 x64 Win64 command prompt (again as admin) the registry entries appeared under HKEY_CLASSES_ROOT\CLSID but this time the test scripts worked from the same prompt and also from a standard Windows cmd prompt (however they fail from a 32 bit prompt)

不过!我不能看到从Excel 2007的Active X控件(32位)

But!! I can't see the active X control from Excel 2007 (32 bit)

<击>现在我只需要弄清楚什么窗户相当于* nix中的其中命令,以确保其regasm我使用)的',其中'命令

纵观VS2010和Windows 7的命令提示:

Looking at the VS2010 and Windows 7 command prompts:

    VS2010 (standard prompt): cscript => c:\windows\system32\cscript.exe
                              regasm  => c:\windows\Microsoft.net\framework\v4.0.30319\regasm.exe

    VS2010 (x64 Win 64):      cscript => c:\windows\system32\cscript
                              regasm  => c:\windows\Microsoft.net\framework64\v4.0.30319\regasm.exe

    Windows 7  std. prompt:   cscript => c:\windows\system32\cscript.exe

    Windows 7 32 bit prompt:  cscript => c:\windows\SysWOW64\cscript.exe

这是一切开始做一些我的困惑可以理解的。 !我已经在不知不觉中混合和匹配32位和64位系统,但在VS2010标准提示没有帮助

This is all starting to make some of my confusion understandable. I have been unknowingly mixing and matching 32 and 64 bit systems, but the VS2010 standard prompt didn't help either!

(和我的最新怨恨 - VS2010将文件保存为UTF -8 BOM)

(and my latest peeve - VS2010 saving files as UTF-8 with BOM)

推荐答案

我是能够使这项工作既可以通过IE浏览器,并通过执行下面的VBScript:

I was able to make this work both via IE and vbscript by doing the following:


  1. 创建一个名为.NET类库ActiveXTest

  2. 添加一个名为myObject的类定义如下:

  1. Create .NET class library named 'ActiveXTest'
  2. Add a class named MyObject which is defined as follows:

namespace ActiveXTest
{
    [System.Runtime.InteropServices.ComVisible(true)]
    [System.Runtime.InteropServices.ProgId("ActiveXTest.MyObject")]
    [System.Runtime.InteropServices.Guid("df2dac4d-ba8a-4ecc-b76e-958c1bc32f1f")]
    public class MyObject
    {
        public string HelloWorld()
        {
            return "This is Hello World from the COM component!";
        }
    }
}


  • 编译该类。转至您编译类,并执行从Visual Studio命令提示符下键入以下文件夹:regasm /基本代码ActiveXTest.dll

  • Compile the class. Go to the folder where you compiled the class and do the following from a Visual Studio command prompt: regasm /codebase ActiveXTest.dll

    要从一个.vbs测试脚本,创建在记事本中调用test.vbs的文件。键入以下到文件:

    To test from a .vbs script, create a file in notepad call test.vbs. type the following into the file:

    Dim myObject
    set myObject = CreateObject("ActiveXTest.MyObject")
    MsgBox(myObject.HelloWorld)
    


  • 打开一个命令提示符并导航到您创建Test.vbs和类型,其中:WScript的test.vbs。应显示一个对话框,指出这是Hellow世界从COM组件

    Open a command prompt and navigate to where where you created the Test.vbs and type: wscript test.vbs. A dialog should be displayed stating "This is Hellow World from the COM component"


    1. 要从IE测试这一点,我创建了一个包含以下内容的test.html文件:

    1. To test this from IE, I created a TEST.HTML file with the following contents:

    <HTML>
        <HEAD>
            <script language="JScript" language="JavaScript">
              var obj = new ActiveXObject("ActiveXTest.MyObject");
              alert(obj.HelloWorld());          
            </script>
        </HEAD>
    
       <body>
           <span>nothing to see here!</span>
       <body>
    </HTML>
    


    打开IE中的test.html文件。你会得到一个关于ActiveX控件的警告;只说是允许的互动。你会得到一个警告对话框,指出这是从COM组件的Hello World。

    Open the TEST.HTML file in IE. You will get a warning about the ActiveX control; just say Yes to allow the interaction. You will get an alert dialog stating "This is Hello World from the COM Component".

    类似的步骤也可以用来做它从一个.js文件或从Excel工作VBA。请注意,如果您更改的ActiveX组件的COM方法签名,我相信你会需要重新注册。

    Similar steps can be used to make it work from a .js file or from Excel VBA. Note that if you change the COM method signature of the ActiveX assembly I believe you will need to re-register it.

    这篇关于的ActiveX DLL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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