Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5174958
  • 博文数量: 1696
  • 博客积分: 10870
  • 博客等级: 上将
  • 技术积分: 18357
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-30 15:16
文章分类
文章存档

2017年(1)

2016年(1)

2015年(1)

2013年(1)

2012年(43)

2011年(17)

2010年(828)

2009年(568)

2008年(185)

2007年(51)

分类: 嵌入式

2010-09-19 15:46:57

How to create Interop...dll's using tlbimp.exe like Visual studio

I am trying to automate a build. We first build COM dll's, register them,
then we want to create interop dlls so we can use them in .NET (v1.1). When
we add a reference to a COM dll in , we get a series of interop
dlls named: Interop.iboSubscription.dll, Interop.iboContentManagement.dll,
Interop.Util.dll, Interop.MsXL2.dll,... etc. 13 in all. These work great
when we create and use them with Visual studo. However I need to automate
the build to create the interops via the command line. Near as i can tell I
should be using the tlbimp.exe command. When I do this, I run a command like:

tlbimp.exe c:\temp\comdlls\iboContentManagement.dll

It gives me all 13 interop dlls (i think), each named without the Interop
prepended. The only way I was able to get the same naming convention, was to
create the interops in order, one at a time like:

tlbimp.exe c:\temp\comdlls\iboUtil.dll \out:Interop.iboUtil.dll \strictref
then
tlbimp.exe c:\temp\comdlls\iboProduct.dll \out:Interop.iboProduct.dll
\reference:Interop.iboUtil.dll \strictref

This gives me the interops (i think), however when I try to use them, the do
not work.

Am I off in left field? or is there a better way to do this?

thanks

dms
  #  
Old 02-21-2006, 12:48 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: How to create Interop...dll's using tlbimp.exe like Visual studio

Dean wrote:

> tlbimp.exe c:\temp\comdlls\iboUtil.dll \out:Interop.iboUtil.dll
> \strictref then
> tlbimp.exe c:\temp\comdlls\iboProduct.dll \out:Interop.iboProduct.dll
> \reference:Interop.iboUtil.dll \strictref
>
> This gives me the interops (i think), however when I try to use them,
> the do not work.


Your flags have backslashes. I presume you mean slashes.

I'm doing a similar thing to create Excel interop assemblies manually.
It's working for me.

I'm using the /safearray flag, because I read somewhere that it might
be helpful, although I'm not sure whether I really need it.

When you say it doesn't work, what do you mean?

-- Peter Gummer
  #  
Old 02-21-2006, 05:10 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: How to create Interop...dll's using tlbimp.exe like Visual stu

Hi Thanks for you rely and yes, i meant slashes for the arguments. I tried
"sysarray" and that didn't seem to help any.

I should clarify what my problem is. I have done some further testing and
see that if I run:

tlbimp.exe c:\temp\comdlls\iboContentManagement.dll

it generates 13 interop dlls without prepending the "Interop." to the dll
names like it does under Visual studio. When I use these as references to my
..NET assembly, all works fine.

But what i really want is the names of the dlls interops to be the same as
you would get if you generated them by adding a reference to it through
Visual Studio. So the only thing I could think of was to use 14 tlbimp
/out:interop. /strictrefs
statements.

Doing this seemed to create the interops, however when I include them via a
ref to my .NET assembly, it does not work.

thanks




"Peter Gummer" wrote:

> Dean wrote:
>
> > tlbimp.exe c:\temp\comdlls\iboUtil.dll \out:Interop.iboUtil.dll
> > \strictref then
> > tlbimp.exe c:\temp\comdlls\iboProduct.dll \out:Interop.iboProduct.dll
> > \reference:Interop.iboUtil.dll \strictref
> >
> > This gives me the interops (i think), however when I try to use them,
> > the do not work.

>
> Your flags have backslashes. I presume you mean slashes.
>
> I'm doing a similar thing to create interop assemblies manually.
> It's working for me.
>
> I'm using the /safearray flag, because I read somewhere that it might
> be helpful, although I'm not sure whether I really need it.
>
> When you say it doesn't work, what do you mean?
>
> -- Peter Gummer
>

  #  
Old 02-21-2006, 09:39 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: How to create Interop...dll's using tlbimp.exe like Visual stu

Dean wrote:

> Doing this seemed to create the interops, however when I include them
> via a ref to my .NET assembly, it does not work.


Ok, that's basically what you said in your first post. You still
haven't told us what you mean by "it does not work".

-- Peter Gummer
  #  
Old 02-22-2006, 12:16 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: How to create Interop...dll's using tlbimp.exe like Visual stu

Sorry about that. What doesn't work is after i create the Interops with the
/out: flag I try to compile using them as references and the compile fails
with errors saying it cannot find the interop namespace.

For instance one of the com objects that gets created when I create a
reference using visual studio on iboContactAdder.dll is
Inter.iboUserSecurity.dll (as well as Interop.iboContactAdder.dll). When I
run:

tlimp ..\iboUserSecurity.dll /out:InteropiboUserSecurity.dll

and then use that interop dll in the visual studio project instead of the
Interop which would get created through VS, i get the error:

error CS0246: The type or namespace name 'iboUserSecurity' could not be
found (are you missing a using directive or an assembly reference?)

if i delete the reference to this Interop.iboUserSecurity.dll and use the
iboUserSecurity.dll created without the /out: flag or if I use the original
Interop.iboUserSecurity.dll generated using the VS add referece from COM
space, I do not get this error.

(also, The size of all the three interop dlls are the same, but they don't
compare bit for bit...)



"Peter Gummer" wrote:

> Dean wrote:
>
> > Doing this seemed to create the interops, however when I include them
> > via a ref to my .NET assembly, it does not work.

>
> Ok, that's basically what you said in your first post. You still
> haven't told us what you mean by "it does not work".
>
> -- Peter Gummer
>

  #  
Old 02-27-2006, 12:35 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: How to create Interop...dll's using tlbimp.exe like Visual stu

Dean wrote:

> error CS0246: The type or namespace name 'iboUserSecurity' could not
> be found (are you missing a using directive or an assembly reference?)


Is this the namespace that tlbimp has generated? Have you used
Reflector or Ildasm to confirm that this is the namespace?

Try secifying the namespace explicitly, with tlbimp's /namespace flag.
This doesn't always work, however, if the type library forces the
namespace to be something else.

-- Peter Gummer
  #  
Old 03-07-2006, 03:28 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: How to create Interop...dll's using tlbimp.exe like Visual stu

Yes, that was it. The namespace was wrong. i was able to generate the
interops without using visual studio. It turns out that when you have a COM
dll named foocom.dll, visual studio creates a interop file called
Interop.foocom.dll with a namespace of foocom. If you use tlbimp foocom.dll
it creates a foocom.dll interop. If you use the /out: flag it also changes
the namespace to the /out value. So in my case, I used:

tlbimp /out:Interop.foocom.dll /namespace:foocom

Since the above would generated about a dozen dependent interops, i had to
run them all in order so I got the right names.

I also used the /asmversion flag to manually update the version number so
shield patch would update the thing.

"Peter Gummer" wrote:

> Dean wrote:
>
> > error CS0246: The type or namespace name 'iboUserSecurity' could not
> > be found (are you missing a using directive or an assembly reference?)

>
> Is this the namespace that tlbimp has generated? Have you used
> Reflector or Ildasm to confirm that this is the namespace?
>
> Try secifying the namespace explicitly, with tlbimp's /namespace flag.
> This doesn't always work, however, if the type library forces the
> namespace to be something else.
>
> -- Peter Gummer
>
阅读(1092) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~