Exposing a .Net assembly to both VB6 and .Net (1 more time)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry

    Exposing a .Net assembly to both VB6 and .Net (1 more time)

    I am finally able to call my .Net object from a VB6 project (see posting
    'Calling VB.Net classes from VB6', thanks to the reference Tony gave me to:
    article:http://msdn.microsoft.com/msdnmag/is...p/default.aspx

    The next step was to see if I could still use the assembly in a .Net
    application. I added another project to the original solution was was able
    to create a reference to it through the projects tab, no problems so far.

    I compiled the project with a strong signature and used the gacutil to place
    it in the GAC. I verified with Windows explorer that it was there, and again
    no problems.

    I then created a new .Net project and tried to add a reference to it (from
    the .Net tab) and it was not there! grrrr It was on the Com tab, so I tried
    to ad the reference to it and got the following error message:

    "A reference to 'Test Class' could not be added.

    The ActiveX type library C:...\TestClass .tlb' was exported from a .Net
    assembly and can not be added as a reference.

    Add a reference to the .Net assembly instead."

    BUT THE ASSEMBLY IS NOT LISTED ON THE .NET TAB!!!!

    Ok, what to do now? Shouldn't I be able to share this assembly with several
    ..Net projects w/o including a local copy of it into each one?
    --
    Terry
  • rmacias

    #2
    RE: Exposing a .Net assembly to both VB6 and .Net (1 more time)

    Terry,

    The reason you can not see your DLL in the ".NET" tab is becasue the tab
    does not reference the Global Assembly Cache. The files that you see in
    there are copies of what is in the Global Assembly Cache located in other
    locations. Look at the "Path" column of the ".NET" tab and you will see that
    the assemblies in that list are not located in "C:\Windows\Ass embly", but in
    other places "C:\Windows\Mic rosoft .NET\Framework\ ".

    The Global Assembly Cache is not a development feature, but a deployment
    feature. When an assembly looks for a referenced DLL, it searches for it in
    the following order:

    1. Checks the assembly name to see if it is already bound. If so, then use
    that one.
    2. Checks the Global Assembly Cache.
    3. Searches the app.config, machine.config, etc. for the location of the
    referenced DLL.
    4. Checks the application directory.

    So what you should probably do is in your new Solution, you can either add
    the Project or reference the *.DLL directly by browsing for it. Then, when
    you deploy your new solution, if you place your .NET dll in the GAC, you new
    solution will find it, as long as it was build with the same version number.

    Hope this helps.

    "Terry" wrote:
    [color=blue]
    > I am finally able to call my .Net object from a VB6 project (see posting
    > 'Calling VB.Net classes from VB6', thanks to the reference Tony gave me to:
    > article:http://msdn.microsoft.com/msdnmag/is...p/default.aspx
    >
    > The next step was to see if I could still use the assembly in a .Net
    > application. I added another project to the original solution was was able
    > to create a reference to it through the projects tab, no problems so far.
    >
    > I compiled the project with a strong signature and used the gacutil to place
    > it in the GAC. I verified with Windows explorer that it was there, and again
    > no problems.
    >
    > I then created a new .Net project and tried to add a reference to it (from
    > the .Net tab) and it was not there! grrrr It was on the Com tab, so I tried
    > to ad the reference to it and got the following error message:
    >
    > "A reference to 'Test Class' could not be added.
    >
    > The ActiveX type library C:...\TestClass .tlb' was exported from a .Net
    > assembly and can not be added as a reference.
    >
    > Add a reference to the .Net assembly instead."
    >
    > BUT THE ASSEMBLY IS NOT LISTED ON THE .NET TAB!!!!
    >
    > Ok, what to do now? Shouldn't I be able to share this assembly with several
    > .Net projects w/o including a local copy of it into each one?
    > --
    > Terry[/color]

    Comment

    • Walter Wang [MSFT]

      #3
      RE: Exposing a .Net assembly to both VB6 and .Net (1 more time)


      Thank you rmacias again for your input.

      Hi Terry,

      As I described in the other thread that you've posted, the exposed COM
      component from .NET using ComClassAttribu te is not a true COM component.
      When you want to use it from another .NET assembly, simply reference to it
      as normal .NET assembly.

      I totally agree with rmacias about the Visual Studio IDE reference tab and
      the Global Assembly Cache. You can refer to MSDN for more info:

      #Add Reference Dialog Box


      Have a nice day!


      Regards,
      Walter Wang
      Microsoft Online Community Support

      =============== =============== =============== =====
      When responding to posts, please "Reply to Group" via your newsreader so
      that others may learn and benefit from your issue.
      =============== =============== =============== =====

      This posting is provided "AS IS" with no warranties, and confers no rights.

      Comment

      Working...