Accessing .NET components from VBScript

Accessing .NET components from VBScript

We have some legacy code used by a customer that originally had a COM model that worked with VBscript. We now have a combination of COM and .NET in a newer release. The methods can no longer be called by legacy VBscript without a "doesn't support method error," but it works just fine in VB or C# so the objects are obviously still there. Customer refuses to part with VBScript and I cannot have them killed. I think said objects giving us grief are now operating in .NET vs COM, hence the problem. Have no idea of the relationship between .NET and VBscript and I'm not sure how to gauge the right questions as I know just enough to be dangerous. Do you have any suggestions on how I should approach this problem?

    Requires Free Membership to View

    When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to provide a unique online resource for developers, architects and development managers tasked with building and maintaining enterprise applications using Visual Basic, C# and the Microsoft .NET platform.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchWinDevelopment.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchWinDevelopment.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

In order for .NET components to be accessible from VBScript, you have to expose them as COM objects. This can be done by assigning them a ProgIdAttribute, as well as a GuidAttribute and a ComVisibleAttribute(true). You also have to modify the project properties so that the output is registered with COM. Recall that the ProgId must follow COM rules, and you can't use a multi-dotted notation. So pick something that is meaningful but without being incredibly long as most .NET assembly names are.

This was first published in January 2005