Windows Develop Bookmark and Share   
 index > Windows Forms General > Auto-register new type librarys
 

Auto-register new type librarys

Hi, I have a VB6 project that contains a reference to a tlb from another .Net project that I have.

The problem is that whenever I rebuild the .Net project the reference in the VB6 project becomes out-of-date and I have to re-enter it (i.e. when I open the project references window it says it's "MISSING"). Is there any way that the VB project reference will automatically update to pick up the new .tlb file which will always be in the same location?
I have tried using the GuidAttribute and the ProgId variables as follows:

[GuidAttribute("586D4B1C-B368-4cb5-8377-D3B5A7420000")]

[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]

[ProgIdAttribute("Namespace_Class1")]

public class Class1: IInterface

I hope this is explained properly.

Thanks,

Wallace

Wallace_  Wednesday, June 28, 2006 8:29 AM

Yes, by setting an explicit assembly GuidAttribute you're specifying the GUID for the type library (the LIBID). That's what VB stores as the reference information in the project file if I recall correctly.

Mattias Sjögren  Thursday, June 29, 2006 6:34 AM

You can use the GuidAttribute on the assembly level as well to specify a fixed LIBID.

Mattias Sjögren  Wednesday, June 28, 2006 10:59 AM

Hi thanks for the reply.

By the assembly level do you mean on the Interface like this:

namespace NspaceName

{

[GuidAttribute("B30D692C-7CEA-48b9-8EFF-09EA28E7A75A")]

public interface IInterfaceName

...

If this is the case I already have it done... If not then can you tell me a little more about it?

Thanks,

Wallace

Wallace_  Wednesday, June 28, 2006 1:23 PM

No I mean globally for the entire assembly, not for a specific type. Such attributes are often put in AssemblyInfo.cs.

[assembly: GuidAttribute(...)]

Mattias Sjögren  Wednesday, June 28, 2006 1:56 PM

Thanks this has worked forr me!  To make sure that I am doing everything correctly - what do you mean by "as well as to specify a fixed LIBID".  Is this just assigning the GUID using the GuidAttribute?  So far I have only set the GuidAttribute in the Assembly.cs

 

Thanks again for your help.

Wallace

Wallace_  Wednesday, June 28, 2006 2:25 PM

Yes, by setting an explicit assembly GuidAttribute you're specifying the GUID for the type library (the LIBID). That's what VB stores as the reference information in the project file if I recall correctly.

Mattias Sjögren  Thursday, June 29, 2006 6:34 AM

Thanks for all the help. This has answered my questions.

Thanks,

Wallace

Wallace_  Thursday, June 29, 2006 8:27 AM

You can use google to search for other answers

Custom Search

More Threads

• Mouseleave and mouseenter event bubbling problems
• Windows Forms/General Button_Click method/Calculator/operators/operands
• Problem with Screensaver
• How to convert a word .doc file into .tif file in c#?
• Show the Date time picker, Checkbox control in GridView contol C# Winforms
• WinForm control in IE example failed in .NET Framework 2.0
• Application icon - How to select different icon based on compiler directives?
• how to save graphics
• Dealing with PropertyGrid custom enumerations...
• how to scroll a disabled listview