0

I have an ASP.NET application and I want to use a VB6 component. I know that I have to use the ASPCOMPAT tag. Is there anything that needs to be done to the VB6 code to make it thread safe?

I have run some tests and it seems to work perfectly, however I have read comments on here about developers that have run into problems, but the comments are not elaborated. Is there anything that needs to be done to the VB6 code to ensure that it is thread safe? It seems too straightforward. Also I have placed the ASPCONFIG tag on one page only - the page that uses the COM component.

I have imported the component in Visual Studio using the tlbimport tool, which places a .NETwrapper around the COM object.

1 Answer 1

1

The thread safety of VB6 code depends largely on how it was written. A special "subset" of COM was written to conceal most of the hard plumbing involved in COM-based development in the VB6 days, and part of what was concealed was thread management (Multi-threaded apartments, single-threaded apartments, etc) and the VB6 runtime handled threading under the hood. As a result, if you followed the rules, thread safety was more or less taken care of for you.

In most cases, if you attempted to delve into independent thread management, eg calling Windows API functions to create threads outside the VB6/COM "sandbox," then you were playing with fire, and no amount of protection from the .NET side will make it "thread safe." Doing so broke all the internal thread management/marshalling/etc code that VB6 purposely tried to hide. That's pretty much the essence of the difference between the unmanaged (VB6/COM) and managed code (.NET) worlds.

Hope that helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. The VB6 DLL was built relatively well using classes and no threads. Therefore based on what you have said there should not be a problem. There is only one function I want to reuse in an ASP.NET application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.