Re: Interop Interface from .Net to VB6

Tech-Archive recommends: Fix windows errors by optimizing your registry



Appologies, I hit send too quickly on my previous post

I'll try again.....

2) Start a command prompt with Visual Studio 2005 environment; type
command "midl classlibrary1.idl" to compile it into
"classlibrary1.tlb";

Ok this all appears to work..

A side note for any future novice viewers of this, is that....
-------------------------------------------------------------
// TLib : // TLib : mscorlib.dll : {BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
-------------------------------------------------------------
....should be ...
-------------------------------------------------------------
// TLib : // TLib : mscorlib.dll : {BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
-------------------------------------------------------------
... as a single line so as to keep the guid in the comment.

When I tried to compile my version, some part of the text had been altered to introduce a CRLF at this point (Not blaming Walter here. These things happen when using newsgroups :))

3) Type command "tlbimp classlibrary1.tlb
/out:classlibrary1.interop.dll" to generate the interop assembly. Type
commmand "regasm /codebase classlibrary1.interop.dll" to register it
in registry.

This step confuses me.

Using my existing code, I get no Interop Dll... just a tlb and a .net assembly. The tlb I get is not generated by the .net Compiler , but by my build process step of calling regasm -------------------------------------------------------------
"%windir%\Microsoft.NET\Framework\v1.1.4322\regasm.exe" Nova.Core.dll /TLB:Nova.Core.tlb
-------------------------------------------------------------
[Nova.Core.dll is my true assembly name :)]

I also call this during the installation of my software.

Perhaps this extra step is needed because the tlb is hand coded from MIDL.


4) Reference this interop assembly in your .NET class libraray and
implement the interface ICommand. Note it will require you implement
two Identity properties, one from IIdentity, one from ICommand; you
could simply delegate the second to the first one's implementation.

Again since, in my original system, the interface is created in .Net and then the tlb is generated from it, perhaps this is a side effect of doing things in a different order or a different dependancy chain.

Someone else suggested a solution in which both IIdentity and ICommand would have an Identity whilst still inheriting as before. I guess ICommand.Identity would shadow IIdentity.Identity.

This also would have had me needing to implement 2 interfaces, on the Identity property. I wasn't so keen on that Idea, but if this does effectively the same thing then I think the other solution is simpler (especially from the perspective of integrating into my build process)

Can you tell me if your solution and this other one achieve the same thing?

5) Make sure you've applied attribute
ClassInterface(ClassInterfaceType.None) to your .NET class and put the
ICommand interface to the first place (if you implements multiple
interfaces), this will make ICommand as the default interface the
coclass implements.

So I guess this configures the class to be exposed to COM whilst leaving the details down to the TLB.

6) After building the .NET class library, reference its generated .tlb
in your VB6 project and you should see the exposed coclass has one
method Execute and one property Identity.

Definitly the desired result. I'm just wondering if the side effects are more awkward to deal with.

I was not expecting to have an extra interop dll

I was kinda expecting that my .Net dll would still be the same but that the tlb would effectively include better info that would have been generated with my other method.

I am very much a beginner with Com stuff in general (Hense all the questions and assumptions) and would rather not have had to touch it in the first place in order to get my .Net code to run from vb6, but that's the road we must take :)

My current understanding of a tlb is that it is purely a way to define an abstract Interface. Therefore I could in theory define an interface to several completely disconnected routines in a standard dll. I'm not sure if this changes when you start to talk about .Net dlls but if this theory is true then what purpose does the interop.dll serve?

I would have thought that your tlb should define all the information needed to direct code to the right place in the .Net dll.

I hate to just implement stuff blindly... I realise that a full understanding of COM is probably well beyond me but I'd like to understand what it is that your telling me to do . Having said all of this I would like to thank you once again for the time and effort you have put in to [answering/putting up with] me :)

--
Rory



.



Relevant Pages

  • Re: object as parameter
    ... Interfaces Type Library Version 1.0" in the list of references. ... interface IDatabaseData: IDispatch ... I have a question on composing tlb at this point ... its similar to the issue with a dll and compatibility settings when you add ...
    (microsoft.public.vb.general.discussion)
  • Re: idl questions
    ... changed version number but left interface name the same ... un-referenced existing tlb ... Private moCProjectSpec as cProjectSpecConcrete ... I've been using a tlb created from idl and want to add some stuff to it. ...
    (microsoft.public.vb.general.discussion)
  • Re: How to Repubilsh the user defined datatypes in Atl component ?
    ... > Thank you for your answer, but I have only *.tlb and binarie files. ... You can get by with importlib alone: ... You seem to misunderstand how type libraries work. ... things happen if the same interface is defined in more than one TLB. ...
    (microsoft.public.vc.atl)
  • Re: How do I use a TOleServer derived object properly? (Yet another interface question).
    ... I think you're ok with using the object as an object reference, ... By the way, when you imported the TLB, did you tell it to support events? ... > TConnection = class ... > look like they're intended to implement the _IConnectionEvents interface ...
    (borland.public.delphi.language.objectpascal)
  • Re: Register a .NET DLL???
    ... Maybe you could tinker with the tlb in some way to fool tlbimp.exe, ... >I am trying to create a .NET DLL to use in NAVISION. ... >Executable as an example as not many people know Navision. ... > When we create a VB6 DLL, we would just REGSVR32 it and that is it. ...
    (microsoft.public.dotnet.general)