Question

.Net tlb not exposing all Classes

Asked by: benblanco

I'm writing COM compatible .Net DLL. In other words I'm writing a .Net DLL that, and I need it compatible with VBA so I have already set "Make Assembly COM-Visible"=True and checked "Register for COM interop". When I compile the Project it generates the tlb file and I'm able to reference the tlb from VBA. But once I go to instantiate a class I find a problem. Only one of the many public classes is availible.

My assembly is called TAS_RS_Calcs and I have several public classes including RefProp, Fluid, StreamPath, etc. So I should be able to see Fluid, for example, under TAS_RS_Calcs, but all I get in the intelliscense is RefProp.

Dim g As New TAS_RS_Calcs.Fluid fails from VBA, but Dim g As New TAS_RS_Calcs.RefProp works.

While Dim g As New TAS_RS_Calcs.Fluid works fine in .Net

So it seems that in the translation from COM to CLR there is a problem or vise-versa. This DLL was fully functional before I don't know what I could have done to cause this.

Here are my Class Declarations:
<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual)> _
Partial Public Class RefProp

<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual)> _
Public Class Fluid

<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual)> _
Public Class StreamPath
 
and I've tried removing the class interface prefixes to see if that would help and it doesn't.

Can someone please tell me why only one class is accessible via the tlb COM reference?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-01 at 10:43:46ID24777850
Tags

Interop COM .Net DLL

Topics

ActiveX

,

.NET

,

Microsoft Excel Spreadsheet Software

Participating Experts
1
Points
250
Comments
26

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Use of LOCK# SIgnal Prefix in inline assembler
    I am using the CMPXCHG assembler instruction in some inline assembler in a C routine. Intel doc says I need to use the LOCK prefix with the CMPXCHG instruction to make it atomic. How do I do that? LOCK seems to be an instruction in the doc, but is invalid in the inline a...
  2. Calling Acrobat tlb MenuItemExecute from VBA
    Hi I am using Access with the Adobe Acrobat tlb. I have added a menu item within Acrobat to allow page numbering, and I want to call it with MenuItemExecute. I cannot find any detail on MenuItemExecute and what to pass as its parameters. I have seen examples on the web ...
  3. Create a .TLB file from a .NET DLL?
    I am using adodb.dll in a C# class. why am I not able to do this: regasm adodb.dll /tlb I get the following error: [[command line output]] C:\EES\BIN\RELEASE>regasm adodb.dll /tlb Microsoft (R) .NET Framework Assembly Registration Utility 1.0.3705.288 Copyright (C) ...
  4. Is it possible to make a tlb of .Net assembly using regasm …
    Is it possible to make a tlb of .Net assembly using regasm or by whatever utility and use this tlb in an ASP page of a system that doesn't have .Net framework at all.
  5. objectdatasource assembly prefix
    Hi All! HELP! i m getting a "ambiguous reference" using objectdatasource in web application. To avoid this, the system ask me to apply a "assembly prefix". how can i do that? thx in advance.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ToddBeaulieuPosted on 2009-10-01 at 11:39:21ID: 25471814

Oh boy. This stuff can be messy and frustrating, indeed. I went through similar struggles a few years back and don't envy you.

I wouldn't use AutoDual, for one thing.

I just dug out an old document that I had created on this topic and posted it to my blog. Please read through it carefully, as a single missed point can be a major road block.

http://toddbeaulieu.spaces.live.com/blog/cns!2A634C4E26554001!309.entry


 

by: benblancoPosted on 2009-10-01 at 12:56:04ID: 25472606

OK, so I have to manually build and interface,  Assign a GUID and ClassinterfaceType.None for each Class? And Change my Assembly GUID because it was initially registered with AutoDual?

But I don't waannaa.. <in a whiney voice>
I have tens of properties in each class. It there not a reliable way of having the interface generated?

Do you think the tlb is "stuck" with the original GUID because of the use of AutoDual?

 

by: ToddBeaulieuPosted on 2009-10-01 at 13:44:21ID: 25473056

Sadly, I don't remember a lot of the details. I learned a lot of this stuff from the book I mentioned. There was a reason for not wanting the AutoDual and I forget exactly why at this point. I seem to remember that you absolutely must have a seperate interface for this to work. It had something to do with how Com accessed objects. I think vbscript uses IDispatch and VB6 either/or. They're calling it "custom" here (http://publib.boulder.ibm.com/infocenter/cicstg/v6r1m0/index.jsp?topic=/com.ibm.cics.tg.doc/cclao/cclaom0059.htm), but that doesn't sound familiar to me.

Anyway, the steps I described in the document were guaranteed to work. I certainly suspect not every one of them is critical (some are). I had so much trouble getting my solution to work that I think I took the brute force approach to guarantee success.

Honestly, declaring interfaces in any context seems equally tedious. I don't know of a shortcut. But, quit your wining, it's not that big a deal! :)

 

by: benblancoPosted on 2009-10-02 at 07:03:06ID: 25477977

ok, I set the Created and interface for on class and implemented it. I also assigned GUIDs, set the Com visibility and set the interface type tpo none.

<ComVisible(True), Guid("756C858E-5C9B-427e-BFCB-03C6411B0CFB")> _
Public Interface IFluid
    ReadOnly Property FluidName() As String
    ReadOnly Property Quality_() As Double
    Function GetExergyFlow(Optional ByVal sFlow As Double = 0, Optional ByVal sFlowUnits As String = Nothing) As Double
End Interface

<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None), ComVisible(True), Guid("27E16904-00A2-4be1-AFC7-2C14D2623DD9")> _
Public Class Fluid
   ....

At the assembly level, I created a new GUID and tried both AutoDispatch and None for interface type:
<Assembly: ComVisible(True)>
<Assembly: ClassInterface(ClassInterfaceType.None)>
' old <Assembly: Guid("183f40c1-f1b0-479e-bf1e-8e7a9799b9a0")> <--commented out
<Assembly: Guid("6584A37D-A400-43b2-A929-F33C504ED2A8")>

I rebuilt, unregistered and reregisterd/installed on test machine and it still only shows the one (RefProp) class

 

by: ToddBeaulieuPosted on 2009-10-02 at 07:37:31ID: 25478321

So your interface has all the methods and properties you want to be seen in COM?

Public Interface IFluid
    ReadOnly Property FluidName() As String
    ReadOnly Property Quality_() As Double
    Function GetExergyFlow(Optional ByVal sFlow As Double = 0, Optional ByVal sFlowUnits As String = Nothing) As Double
End Interface

I don't even see RefProp in this list.

btw - I'm not sure if COM supports "optional" arguments. I don't know. You might want to keep your eye on that one.

When you change GUIDs and recompile, you have to unregister the OLD ASSEMBLY before you can reregister the new. It's super easy to end up with remnant registry entries referencing the old interface. I remember manually yanking lots of entries with regedit. After an unregister, you should not find any mention of the method names. I suspect you're still missing a step and you're seeing artifacts from previos experiments.

 

by: benblancoPosted on 2009-10-02 at 07:38:37ID: 25478330

I was also able to add a new class with it custom interface and it works great, but my other classes that were there at the time when i built using AutoDual (like Fluid) still will not show up even if I do the same things.

this works fine:
Public Interface IExpander4
    ReadOnly Property CGS() As String
End Interface
<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)> _
Public Class Expander4
    Implements IExpander4
    Public ReadOnly Property CGS() As String Implements IExpander4.CGS
        Get
            Return "hi"
        End Get
    End Property
End Class

 

by: ToddBeaulieuPosted on 2009-10-02 at 07:40:33ID: 25478349

Good. That seems to confirm my last message about having garbage in the registry.

 

by: benblancoPosted on 2009-10-02 at 07:51:46ID: 25478477

ok, Maybe i missed something.

1) I unregisterd using regasm:
c:\Program Files\Microsoft Visual Studio 9.0\VC>regasm /u "C:\Documents and Sett
ings\bblanco\My Documents\Visual Studio 2008\Projects\TAS_RS_Calcs\TAS_RS_Calcs\
bin\Debug\TAS_RS_Calcs.dll" /tlb:"C:\Documents and Settings\bblanco\My Documents
\Visual Studio 2008\Projects\TAS_RS_Calcs\TAS_RS_Calcs\bin\Debug\TAS_RS_Calcs.tl
b"
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.3053
Copyright (C) Microsoft Corporation 1998-2004.  All rights reserved.

Types un-registered successfully
Type library 'C:\Documents and Settings\bblanco\My Documents\Visual Studio 2008\
Projects\TAS_RS_Calcs\TAS_RS_Calcs\bin\Debug\TAS_RS_Calcs.tlb' un-registered suc
cessfully

I did this for both the Debug and Release version.


2) Then I generated a new GUID and put it in the AssembyInfo.vb file. Is there somewhere else I should be putting this?  <Assembly: Guid("86DE7B1D-006C-4993-8951-4C1DDF892618")>  


3) I rebuilt the assembly

4) I re-referenced in in Excel

But it still doesn't show the Fluid Class and it still shows RefProp

 

by: ToddBeaulieuPosted on 2009-10-02 at 09:12:00ID: 25479298

You're registering a TLB with regasm? I've never seen that. I registered the DLL itself. The /tlb extracts the type library from the assembly and registers all public/com visible members. Since I'm not familiar with that syntax, I can't be sure if it's the same thing.

Once you're on your way you definitely don't want to be changing guids.

My point of cleaning the registry is that it's too easy to miss unregistering something before changing guids, especially when you're changing them, or allowing the compiler to auto-assign them. You can unregister the new one all day long, but you'll still have remnants from previous versions registered with the same member names if you forgot to unregister them. I'd definitely do an audit. I can't overstate how important that it. You can spin your wheels, not realizing there are orphaned entries masking your new ones.

After you've done this and if the problem remains, you'll have to post some code. It's just not possible to know what's going on without seeing it all, especially when the code you have posted doesn't match what you're reporting.

 

by: benblancoPosted on 2009-10-02 at 13:59:57ID: 25482154

:(

Well, Unregistered the tlb and the dll:
c:\Program Files\Microsoft Visual Studio 9.0\VC>regasm /u "C:\Documents and Sett
ings\bblanco\My Documents\Visual Studio 2008\Projects\TAS_RS_Calcs\TAS_RS_Calcs\
bin\Release\TAS_RS_Calcs.dll" /tlb:"C:\Documents and Settings\bblanco\My Documen
ts\Visual Studio 2008\Projects\TAS_RS_Calcs\TAS_RS_Calcs\bin\Release\TAS_RS_Calc
s.tlb"
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.3053
Copyright (C) Microsoft Corporation 1998-2004.  All rights reserved.

Types un-registered successfully
Type library 'C:\Documents and Settings\bblanco\My Documents\Visual Studio 2008\
Projects\TAS_RS_Calcs\TAS_RS_Calcs\bin\Release\TAS_RS_Calcs.tlb' un-registered s
uccessfully

c:\Program Files\Microsoft Visual Studio 9.0\VC>regasm /u "C:\Documents and Sett
ings\bblanco\My Documents\Visual Studio 2008\Projects\TAS_RS_Calcs\TAS_RS_Calcs\
bin\Release\TAS_RS_Calcs.dll"
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.3053
Copyright (C) Microsoft Corporation 1998-2004.  All rights reserved.

Types un-registered successfully

Then removed any reference to either in the registry.

Created a new GUID and rebuilt the assembly.

Still the same.

This is the new test class that I added that works properly
______________________________________
Public Interface IExpander4
    ReadOnly Property CGS() As String
End Interface
<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)> _
Public Class Expander4
    Implements IExpander4
    Public ReadOnly Property CGS() As String Implements IExpander4.CGS
        Get
            Return "hi"
        End Get
    End Property
End Class



This is an old class does refuses to show up:
____________________________________
<ComVisible(True)> _
Public Interface IFluid
    ReadOnly Property FluidName() As String
    ReadOnly Property Quality_() As Double
    Function GetExergyFlow(Optional ByVal sFlow As Double = 0, Optional ByVal sFlowUnits As String = Nothing) As Double
End Interface

<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)> _
Public Class Fluid
    Inherits RefProp
    Implements IFluid
    Dim lFluidName As String
    Dim lUnits As RefProp.Units
    Dim lOutputUnits As Units

    Public ReadOnly Property FluidName() As String Implements IFluid.FluidName
        Get
            Return lFluidName
        End Get
    End Property

    Public ReadOnly Property Quality_() As Double Implements IFluid.Quality_
        Get
            If IsMissing(lQ) Then
                lQ = QualityC(lInpCode, lProp1, lProp2)
            End If
            Return lQ
        End Get
    End Property
    ...
    ...'and so on
End Class



This is the only original class that show up:
____________________________
<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)> _
Partial Public Class RefProp
    ...
    ...
end class

_____________________________
Partial Public Class RefProp
    ...
    ...
end class
_____________________________

 

by: ToddBeaulieuPosted on 2009-10-03 at 04:38:38ID: 25484873

If you notice in my blog, I'm NOT registering or unregistering a type library file (TLB). I'm registering the DLL itself, but extracting the type library. You still haven't hit on the exact sytax I had listed. Check that out. I can only assume that I had a reason for that.

Why do you keep changing the GUIDs? That will only add to your heartburn - a sure fire way to accumulate registry remnants.

In fact, as I look at your sample and read through my instructions, I see other differences, but it may be because you're pasting in snippets. The Fluid class isn't marked com visible, nor does it have a guid. The IFluid interface is marked visible, but has no guid.

This is a tough problem to troubleshoot without another computer. I was thinking of trying a sample, but I don't have another computer here.

Unless you just left out the above mentioned items from this post, I think you really need to go back and re-read the instructions and compare the two carefully. If you do all that and it still doesn't work, you should post a small, complete project that demonstrates the problem.

 

by: benblancoPosted on 2009-10-05 at 08:03:48ID: 25495940

.Net actually registers the tlb automatically when the assembly is built(compiled).

As for the syntax, I assume you mean the use for the InteropServices prefixes like the GUID and the ComVisible setting. I tried using that syntax and it did not work. I found that these arguments were not neccessary when defining the new test classes that I added either, so after I tried them on the Fluid class it they had no effect I removed them. My third post shows the following:

<ComVisible(True), Guid("756C858E-5C9B-427e-BFCB-03C6411B0CFB")> _
Public Interface IFluid
    ReadOnly Property FluidName() As String
    ReadOnly Property Quality_() As Double
    Function GetExergyFlow(Optional ByVal sFlow As Double = 0, Optional ByVal sFlowUnits As String = Nothing) As Double
End Interface

<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None), ComVisible(True), Guid("27E16904-00A2-4be1-AFC7-2C14D2623DD9")> _
Public Class Fluid
   ....


Am I missing something? It's been known to happen. I'll go ahead and add these arguments back, just in case.

I thought the old class definition was somehow "stuck" with the GUID. I understood that changing the GUID was key. i also found that unregistering the tlb was effective in removing all references to the tlb, dll, and the associated GUID from the registry.

I would post the project, but I'm not sure it would do any good, since it depends on a set of COM dlls from a licensed tool called REFPROP from the National Institute of Science and Technology, so you would be able to compile it unless you bought REFPROP.

 

by: ToddBeaulieuPosted on 2009-10-05 at 08:49:39ID: 25496368

>>.Net actually registers the tlb automatically when the assembly is built(compiled).

This is not the case on the remote box, of course. That's what we're discussing, with regards to regasm /tlb. The "auto register" is controlled by "register for com" checkbox on the project properties. I'm under the impression that your problem is on the other box, and thus everything I've discussed about registration was centered there.

As long as you unregister the OLD version before replacing the assembly with the new version and registering that, changing the guid wouldn't be necessary. Hard-coding the guid simply ensures it never changes, which would break your bindings.

I know I had such a hard time getting this all to work back then, I carefully documented the steps in case I had to do again sometime. Until proven otherwise, I have to trust what I wrote. I understand why you'd be tempted to remove atrtibutes that didn't seem to work, but my concern is that if you missed some other step it could appear that the attributes didn't work and thus were unecessary.

So, where do we stand? Can you get a test library to work, with multiple classes with multiple members to work 100%? You talk about a 3rd party library, but I thought that was the only one that DID show up via COM.

 

by: benblancoPosted on 2009-10-05 at 10:07:14ID: 25497136

My problem is not just on the remote box. I've been trying to get it to work on my dev machine first. either way i get the same result. No update to the tlb.

What do you mean by replaced the assembly with a new version? Create a new project in .Net or just building it with a new Assembly version?

I do have those class interface interop attributes added back.

I'm sure I can get a test library to work. I've had no problem adding new clases to this library an making them show up, but the problem seems to be with th classes in this library that were already there when i used autodual.

REfPROP is a third party COM dll. I'm creating a .Net wrapper for it so that it can be used by both .Net and COM clients. I'm also adding a bunch of classes of my own to this wrapper to extend it sfundtionality

 

by: ToddBeaulieuPosted on 2009-10-05 at 11:20:30ID: 25497952

Imagine you create a library with 10 guids in it. You register that library on a remote box. Then you change all the guids and recompile it. If you register THAT library on the remote box you'll have orphaned garbage with the old guids. You can't unregister it, because you've already replaced it. So you'd need to unregister the new one, restore the original assy and unregister THAT one to get rid of everything.

What do you mean by no update to the tlb? When the .net assy is copied to the remote box and registered with regasm /tlb, the type lib data is extracted from the assembly, not a tlb file. But it does create a tlb in the process. So in THAT file is where you can't find your other classes?

I really suggest you try to pick up the recommended book. I just dragged them out and was looking through the chapter about this very topic. There's so much to this that you should read through.

Note that any class to be exposed to COM must have a parameterless constructor. Probably not your issue, but you should be aware of it.

I'm not sure what to tell you. This is tough to work through in this format. You're saying that you can add new classes to this library and they show up? But existing classes that are all marked correctly with attributes don't? That would be very odd. What if you renamed them as a test? I don't understand how new classes can be added, but existing ones don't show up. Unless there's a problem with the registry as far as this assy is concerned.

 

by: benblancoPosted on 2009-10-06 at 13:46:47ID: 25509781

>> You're saying that you can add new classes to this library and they show up? But existing classes that are all marked correctly with attributes don't? That would be very odd. What if you renamed them as a test? I don't understand how new classes can be added, but existing ones don't show up. Unless there's a problem with the registry as far as this assy is concerned.


That is correct. Or at least as of yesterday.

And I just tried renaming them to no avail.

AAAAnd the new classes I added today will not show up now.

Guess I'll submit the project for scrutiny.

 

by: benblancoPosted on 2009-10-06 at 13:51:02ID: 25509828

 

by: benblancoPosted on 2009-10-07 at 07:19:54ID: 25515711

Yesterday before I left for the day, I was able to create a few COM visible test Classes successfully.

So this morning a I created another one called MaterilaStream with only two props. It worked.
Then I moved over allt he methods and props from Fluid to MaterialStream. Only the orininal two showed.
I backed up and slowly added the props and methods from Fluid a few at a time and the class finally showed everyhting.

Then I created a new empty class in another class module to do this same thing for the MaterialStreamPath class. So the new streamPath class showed up, BUT MaterialStream class was was just successfully added disapperared!!

This thing is flakey!

 

by: benblancoPosted on 2009-10-12 at 05:43:14ID: 25550692

I registered the the dll with regasm verbose and got a strage result. Where the output is supposed to list the classes registered it says "Type 'T' exported" several times. Then i tried having regasm create a Registry file and it only generated reg entries for Refprop and the new empty test classes. It still ignored several classes. I don't think regasm like my assembly. Any ideas?

 

by: ToddBeaulieuPosted on 2009-10-12 at 07:03:29ID: 25551296

I meant to work on this last week. I even started a new project for it. Got sidetracked with work. So you can add new classes and see them. RefProp is there. But the other classes, like "Fluid" are not visible?

So I just worked up the a test library. I created a base class Fruit, along with its interface. Applied the COM attributes by copying the code from your Fluid module, chaning the GUID.

Next I created another class called Banana and based it on Fruit. Applied the attributes the same way.

I did NOT enable COM Interop in the project because I wanted to make sure the typelib was being generated correctly (manually) and nothing behind the scenes (visual studio) was masking an error in the manual generation.

Compiled.

regasm interoptestlib.dll /tlb /verbose

I got a simular mesage as you:

>regasm interoptestlib.dll /tlb /verbose
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.4016
Copyright (C) Microsoft Corporation 1998-2004.  All rights reserved.

Types registered successfully
Type 'I' exported.
Type 'I' exported.
Type 'I' exported.
Type 'I' exported.
Assembly exported to '...interoptestlib.tlb', and the type library was registered successfully

Next, I looked at the typelib with OLE View. I could see my classes and properties (methods get/put) in the interfaces.

Next, I went into VB6. After setting the reference I could easily see the properties of both the base class and the sub class. Intellisense was perfect. When referencing the child class, I did not see any of the base class' properties. I don't know if there's a way to get that behavior. That would be a research item.

Option Explicit

Public Sub main()
    Dim fruit As InteropTestLib.fruit
    Dim banana As InteropTestLib.banana
   
    fruit.Color = ""
    fruit.Name = ""
   
    banana.Length = ""
End Sub

Everything went quite smoothly. I really don't know what to say! Does this sound exactly like what you're doing?

 

by: benblancoPosted on 2009-10-12 at 08:51:25ID: 25552259

Pretty much, except, that VBA will only see Refprop and those test classes I added last.

Did your interoptestlib.dll assembly have Refprop and my other classes in it or was it a fresh new assembly???

if so, I guess maybe the regasm and TLBExp are tripping on one of my classes then failing to build the interface structure for the others.

 

by: ToddBeaulieuPosted on 2009-10-12 at 11:07:36ID: 25553516

Ok, I think I figured it out.

You had the "make com visible" option enabled on the "assembly properties" dialog, off the main application properties tab.

As soon as I turned that off I could see the classes that I explicitly made visible, including "Fluid".

 

by: ToddBeaulieuPosted on 2009-10-12 at 11:18:19ID: 25553613

I see that I actually mentioned this in the blog. I noticed that I had NOT used this feature in the past project, so I must have documented the theory of the option, but not tested it in use. To understand how to use that global settings would take some research. For now, it seems that you should be able to export those members you want exported. Perhaps this finding could be used as a clue in searches if you really wanted to get it working on a global level. I don't know why it prevented items from appearing that were explicitly made visible.

Something I noticed, though, was that even those these classes wouldn't appear in intellisense as Types, they DID appear in the object browser as classes. I'll bet it's something simple.

 

by: benblancoPosted on 2009-10-12 at 12:17:51ID: 31636025

Boy, do I feel dumb!? You were right about the class needing a parameterless constructor. that was it. I kind of blew that off because I thought that applied to another type of interop.

"...COM must have a parameterless constructor"

Didn't need the GUID's. Here is what worked

Imports System.Runtime.InteropServices
<ComVisible(True)> _
Public Interface IMotor
...
End Interface
<ClassInterface(ClassInterfaceType.None)> _
Public Class Motor
    Implements iMotor
    ...

    Public Sub New()

    End Sub
    ...

End Class

 

by: ToddBeaulieuPosted on 2009-10-12 at 12:20:13ID: 25554133

If I were you'd I'd experiment with the "no GUID" just to make sure it all works. What I'd look out for is changing GUIDs, which will break COM references. That's why I assigned them explicitly.

 

by: benblancoPosted on 2009-10-12 at 13:53:49ID: 25554945

Cool, Thanks for the advise.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...