DLL和TLB引用的问题 [英] DLL and TLB referenced issue

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

问题描述

大家好1,

我创建了一个"Sample.Dll"和"sample.tlb"文件,其中包含一个返回值的函数,使用Visual Studio 2005类库在Microsoft Office Excel的宏中对其进行访问以获取单元格值.
在构建解决方案之前,我在Visual Studio 2005中设置了一些属性.更改为:
-应用程序->装配体信息->使装配体COM可见选中复选框.
-编译->注册COM interop复选框已选中(将创建"Sample.tlb"文件)
-签名->在装配体上签名.选中复选框(创建"Sample.snk"文件)

我构建了解决方案,并且Release文件夹中有三个文件
-Sample.Dll
-Sample.tlb
-Sample.snk
-sample.Pdb
-sample.xml

现在,我将"sample.dll"和"sample.tlb"放入System32,然后在另一台计算机上两次注册sample.dll
1.通过gacutil/i sample.dll
2.通过RegAsm sample.dll

现在,我打开Excel,然后创建一个宏,并添加来自系统32和Microsoft ActiveX数据对象2.1库和Microsoft DAO 3.6库的"sample.tlb"引用. 现在,我创建DLL的类文件的对象.
单元格(1,1)= object.Function()


它在创建sample.Dll的同一台计算机上返回值,但在另一台计算机上,在执行Function时给出错误,但未返回该单元格的值.
该函数给出了错误代码.
1.错误代码429
2.错误代码-2147024894

我研究了这两个错误,但没有得到任何有力的结果.
为什么在没有编译它的任何其他机器中出现它?
或我未执行的步骤.

谢谢您,

Hi Every1,

I Created a ''Sample.Dll'' and ''sample.tlb'' file containing a function which returns a value, using Visual Studio 2005 class library for access it in the Microsoft Office Excel''s Macro to getting a cells value.
I Set some properties in visual studio 2005 before building the Solution.the Changes are:
- Application -->Assembly Information-->Make Assembly COM visible Check box Checked.
- Compile --> Register for COM interop Check box Checked(Which creates ''Sample.tlb'' file)
- Signing --> Sign the Assembly.Check Box Checked(Which creates ''Sample.snk'' file)

I Build the Solution and There is three files in the Release folder
- Sample.Dll
- Sample.tlb
- Sample.snk
- sample.Pdb
- sample.xml

Now i place the ''sample.dll'' and ''sample.tlb'' in the System32 then register the sample.dll on the another machine two times
1. by gacutil /i sample.dll
2. by RegAsm sample.dll

Now I Open the Excel then Create a Macro and add a reference of the ''sample.tlb'' from system 32 and Microsoft ActiveX Data Objects 2.1 Library and Microsoft DAO 3.6 Library.
now i create a object of the class file of the DLL.
Cells(1,1)=object.Function()


It returns value in the same machine where the sample.Dll build but on another machine it gives an error when executes the Function and did not return the value of that cells.
the function gave Error Code.
1.Error Code 429
2.Error Code -2147024894

I researched on that two error but did not got any strong result.
why it occurs in any other machine where i did not compile it?
or What step i did not perform.

Thank You,

推荐答案



您是否尝试过将文件(在有问题的计算机上)移动到excel exe所在的位置?我之前曾经历过DLL的地狱,通常是应用程序无法找到" DLL的情况(即使将DLL放入system32文件夹中也是如此).

它可以在编译的机器上工作的原因是,当您编译DLL时,它会为DLL做一些安装工作,从而使它在运行excel时可以工作.至少这是我在经验中发现的.我还建议您创建一个虚拟机,以便可以在其上测试您的东西,至少您将拥有一个干净的机器",可以在其中玩耍:).

希望对您有所帮助:)
Hi,

Have you tried moving the files (on the offending machine) to where the excel exe is? I''ve gone through DLL hell before and usually it''s a case of the application not ''finding'' the DLL (even when you put the DLL in the system32 folder).

The reason why it would work on the machine that it was compiled on is because when you compile the DLL, somewhere along the line it does some installation stuff for the DLL which allows it to work when you run excel. At least that''s what I''ve found in my experience. I would also suggest that you create a virtual machine that you can test your stuff on and at least then you will have a ''clean machine'' where you can play around :).

Hope that helps :)


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

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