非强名称互操作库第2部分 [英] Non-strong named interop libraries Part 2

查看:45
本文介绍了非强名称互操作库第2部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有,


我现在正在经历一个小小的地狱 - 我已经完全失去了它:)


我做了一个项目,使用来自交换的两个互操作库(在这篇msdn文章中将它们创建为


HTTP://msdn.microsoft.com/library/de ... gmngsinks.asp)。我将
设置我的项目属性为''注册为COM interop''为true,我可以

将我的项目安装在我的开发机器上没有任何缺陷。太棒了。


现在我想在另一台带有.NET框架的机器上安装它。我将注册为COM互操作设置为错误,重新编译,并将文件复制到另一台机器上。

。我使用regsvcs.exe工具进行注册,因为Nicholas Paldino在我的另一个问题中向我指出了
。现在我得到

我的dll没有强名的错误。


回到我的开发机器。当我使用sn.exe工具创建一个

强键时,我把这个信息放在项目属性和

assemblyinfo.cs文件中,我重新编译,我得到另一个错误:一个(不是两个!)
来自Exchange的interop dll文件的
没有强名称。如果我看看这些互操作文件的属性,我可以清楚地看到其中一个

他们将''强名称'属性设置为''true' '和一到''假''。为什么

他们都没有一个强大的名字对我来说是一个谜,因为我按照前面提到的MSDN文章中的

步骤,你会期望他们''

方便两者都有很强的名字,但是唉。


所以,在这个新闻组的Patty O''dors的另一篇文章中我读了一个解决方案这个...... b $ b这个...但是不起作用。如果我在VS.NET项目中设置密钥文件

属性,这不起作用。


tlbimp.exe是oldInterop.dll /密钥文件:如果我用用就

oldInterop文件tlbimp.exe是工具(不带强名称)someKeyFile .snk /out:newInterop.dll


我收到错误:oldInterop.dll不是有效的类型库


AAArrrgh我的意思是。 .. 这是为什么?我可以添加它作为参考,浏览

它和所有,现在喷射另一个错误。这让我很沮丧。我只想要

在另一台机器上部署我的精美工作项目,我必须通过这一切去

:)无论如何,任何人都可以帮我这个吗?


万分感谢,


Razzie

解决方案

嗯我以前做的确实是弱dll。

但是,如果我现在尝试在我的项目DLL文件上使用tlbimp,我仍然得到

''不是有效的类型库''错误:(


" Patty O''Dors"< Pa ******** @ discussion.microsoft.com>在消息中写道

新闻:E2 ********************************** @ microsof t.com。 ..

从我读Nicholas回复给我的方式来看,你不要在
(弱)互操作DLL上使用tlbimp.exe来转换它,你在* ACTUAL COM DLL *上使用它。
所以,如果我想创建一个强大的命名互操作库来替换
弱名的SQLDMO.Interop.dll我s自动生成

我会输入
tlbimp" c:\program files\microsoft sql server \80 \tools \binn \sqldmo.dll"
/keyfile:sqldmokey.snk /out:SQLDMO.StrongInterop.dll



tlbimp" sqldmo.interop.dll" /keyfile:sqldmokey.snk
/out:SQLDMO.StrongInterop.dll

这就是你在做什么?


Razzie,


Patty是对的,因为你不应该在互操作上使用TLBIMP

汇编本身。现在看来你正试图在你的项目的输出上使用它?
?您需要在COM dll / tlb上运行TLBIMP,其中包含要从COM导入的类型

,然后添加对由此生成的DLL的引用

TLBIMP。


希望这会有所帮助。


-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Razzie" < RA **** @ quicknet.nl>在消息中写道

新闻:e6 ************* @ TK2MSFTNGP12.phx.gbl ...

我以前做过的是确实弱的dll。
但是,如果我现在尝试在我的项目DLL文件上使用tlbimp,我仍然得到''不是一个有效的类型库''错误:(

Patty O'Dors"< Pa ******** @ discussion.microsoft.com>在消息中写道
新闻:E2 *********** *********************** @ microsof t.com ...

从我读尼古拉斯回复我的方式,你不要在
(弱)互操作DLL上使用tlbimp.exe来''转换''它,你在* ACTUAL COM DLL *上使用它。
所以,如果我想创建一个强大的命名互操作库来替换
自动生成的弱命名的SQLDMO.Interop.dll

我会输入
tlbimp " c:\program files\microsoft sql server \\\\tools \ binn \sqldmo.dll"
/keyfile:sqldmokey.snk /out:SQLDMO.StrongInterop.dll



tlbimp" sqldmo.interop.dll" /keyfile:sqldmokey.snk

是/>这个特殊照顾做什么?


嗨尼古拉斯,


那是......不可能。请你看看这个吗?
http://msdn.microsoft.com/library/de...ngmngsinks.asp

如果滚动一点点下来,你会看到''建立互操作''。

这产生了我的第一个互操作......这是强大的。

在这一步中接下来,''构建包装器',

Microsoft.Exchange.Transport.EventWrappers.dll是弱库。


我可以''在那个上使用tlbimp。然而,MSDN文章告诉我使用该示例构建它

。但它不强,而且因为我知道什么是tlbimp等真正的知识,我不知道这是否可以解决?


Razzie


" Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com>写在

消息新闻:eK ************* @ TK2MSFTNGP15.phx.gbl ...

Razzie,

Patty是对的,因为你不应该在互操作组件本身上使用TLBIMP。现在看来你正试图在项目的输出上使用它?您需要在COM dll / tlb上运行TLBIMP,它具有您要从COM导入的类型,然后添加对TLBIMP生成的DLL的引用。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

Razzie < RA **** @ quicknet.nl>在消息中写道
新闻:e6 ************* @ TK2MSFTNGP12.phx.gbl ...

我以前做过的确是弱dll 。
但是,如果我现在尝试在我的项目DLL文件上使用tlbimp,我仍然得到''不是有效的类型库''错误:(

" ; Patty O'Dors"< Pa ******** @ discussion.microsoft.com>在留言中写道
新闻:E2 *************** ******************* @ microsof t.com ...

从我读尼古拉斯回复我的方式来看,你不要使用tlbimp.exe
(弱)互操作DLL来''转换''它,你在* ACTUAL COM DLL *上使用它。
所以,如果我想要的话创建一个强大的命名互操作库来替换
自动生成的弱命名的SQLDMO.Interop.dll

我会输入
tlbimp" c: \program files\microsoft sql server \80\tools\binn\sqldmo.dll"
/keyfile:sqldmokey.snk / out: SQLDMO.StrongInterop.dll



tlbimp" sqldmo.interop.dll" /keyfile:sqldmokey.snk

是/>这个特殊照顾做什么?



Hey all,

I''m really going through a small hell right now - I''ve completely lost it :)

I made a project, using two interop libraries from exchange (created them as
in this msdn article:
http://msdn.microsoft.com/library/de...gmngsinks.asp). I
set my project properties as ''Register as COM interop'' to true, I can
install it my project on my developement machine without a flaw. Great.

Now I wanted to install it on another machine with a .NET framework. I set
the ''Register as COM interop'' to false, recompiled, and copied the files to
the other machine. I used the regsvcs.exe tool for it to register it, as
pointed out to me by Nicholas Paldino in another question of mine. Now I get
the error that my dll does not have a strong name.

So back to my developement machine. When I use the sn.exe tool to create a
strong key, I put this info in the project properties and the
assemblyinfo.cs file, and I recompile, I get another error: one (not both!)
of the interop dll files from exchange does not have a strong name. If I
look at the properties of these interop files, I can clearly see that one of
them has the ''Strong name'' property set to ''true'' and one to ''false''. Why
they both do not have a strong name is a mystery to me since I followed the
steps in the MSDN article as mentioned before, and you''d expect they''d
conveniently both have strong names, but alas.

So, in another post of Patty O''dors in this newsgroup I read a solution to
this... but doesn''t work. If I set the key file in the VS.NET project
properties, this doesn''t work. If I use the tlbimp.exe tool on the
oldInterop file (without the strong name) using:

tlbimp.exe oldInterop.dll /keyfile: someKeyFile.snk /out:newInterop.dll

I get the error: oldInterop.dll is not a valid type library

AAArrrgh I mean... why is that? I can add it as a reference, browse through
it and all, and now jet ANOTHER error. It really frustrates me. I only want
to deploy my fine working project on another machine, and I have to go
through all this :) Anyway, can anyone please help me with this?

Thanks a million,

Razzie

解决方案

Well what I did before was indeed the weak dll.
However, if I try now to use tlbimp on my project DLL file, I still get the
''is not a valid type library'' error :(

"Patty O''Dors" <Pa********@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...

From the way I read Nicholas'' reply to me, you don''t use tlbimp.exe on the
(weak) interop DLL to ''convert'' it, you use it on the *ACTUAL COM DLL*.
So, say if I wanted to create a strong named interop library to replace
the
weak-named SQLDMO.Interop.dll that is generated automatically

I would type
tlbimp "c:\program files\microsoft sql server\80\tools\binn\sqldmo.dll"
/keyfile:sqldmokey.snk /out:SQLDMO.StrongInterop.dll

NOT

tlbimp "sqldmo.interop.dll" /keyfile:sqldmokey.snk
/out:SQLDMO.StrongInterop.dll

is this what you''re doing?



Razzie,

Patty was right, in that you should not use TLBIMP on the interop
assembly itself. It seems now you are trying to use it on the output of
your project? You need to run TLBIMP on the COM dll/tlb that has the types
you want to import from COM, and then add a reference to the DLL that is
produced by TLBIMP.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Razzie" <ra****@quicknet.nl> wrote in message
news:e6*************@TK2MSFTNGP12.phx.gbl...

Well what I did before was indeed the weak dll.
However, if I try now to use tlbimp on my project DLL file, I still get
the ''is not a valid type library'' error :(

"Patty O''Dors" <Pa********@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...

From the way I read Nicholas'' reply to me, you don''t use tlbimp.exe on
the
(weak) interop DLL to ''convert'' it, you use it on the *ACTUAL COM DLL*.
So, say if I wanted to create a strong named interop library to replace
the
weak-named SQLDMO.Interop.dll that is generated automatically

I would type
tlbimp "c:\program files\microsoft sql server\80\tools\binn\sqldmo.dll"
/keyfile:sqldmokey.snk /out:SQLDMO.StrongInterop.dll

NOT

tlbimp "sqldmo.interop.dll" /keyfile:sqldmokey.snk
/out:SQLDMO.StrongInterop.dll

is this what you''re doing?




Hi Nicholas,

That is... not possible. Would you please take a look at this?
http://msdn.microsoft.com/library/de...ngmngsinks.asp
If you scroll just a little bit down, you will see ''To build the interop''.
This produces number one of my interops... that is the strong one.
In the step that follows, ''To build the wrappers'', the
Microsoft.Exchange.Transport.EventWrappers.dll is the weak library.

I can''t use tlbimp on that one. Yet the MSDN article tells me to build it
using that example. But it ain''t strong, and since I have little knowledge
what tlbimp etc really does, I don''t know if this can be fixed?

Razzie

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eK*************@TK2MSFTNGP15.phx.gbl...

Razzie,

Patty was right, in that you should not use TLBIMP on the interop
assembly itself. It seems now you are trying to use it on the output of
your project? You need to run TLBIMP on the COM dll/tlb that has the
types you want to import from COM, and then add a reference to the DLL
that is produced by TLBIMP.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Razzie" <ra****@quicknet.nl> wrote in message
news:e6*************@TK2MSFTNGP12.phx.gbl...

Well what I did before was indeed the weak dll.
However, if I try now to use tlbimp on my project DLL file, I still get
the ''is not a valid type library'' error :(

"Patty O''Dors" <Pa********@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...

From the way I read Nicholas'' reply to me, you don''t use tlbimp.exe on
the
(weak) interop DLL to ''convert'' it, you use it on the *ACTUAL COM DLL*.
So, say if I wanted to create a strong named interop library to replace
the
weak-named SQLDMO.Interop.dll that is generated automatically

I would type
tlbimp "c:\program files\microsoft sql server\80\tools\binn\sqldmo.dll"
/keyfile:sqldmokey.snk /out:SQLDMO.StrongInterop.dll

NOT

tlbimp "sqldmo.interop.dll" /keyfile:sqldmokey.snk
/out:SQLDMO.StrongInterop.dll

is this what you''re doing?





这篇关于非强名称互操作库第2部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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