all groups > dotnet web services > january 2008 >
You're in the

dotnet web services

group:

Exposing VB6 COM dll via WCF


Exposing VB6 COM dll via WCF chriscap
1/15/2008 8:58:01 AM
dotnet web services: I tried searching the forums for this already and didn't find anything. I
want to expose functionality from a vb6 COM component via a WCF service. I
am trying to evaluate if exposing this webservice and using a COM component
is scalable. I have heard there are problems with this revolving around the
apartment threading models.

I know COM dll's are STA and a WCF service is MTA. Since there is no way to
force a WCF service to be STA, I am expecting all my webservice calls to
block as they are forced through the STA pipe. However, this is not
happening and I am wondering why. To test, I have a web method that takes a
boolean parameter. the web method calls some functions from the COM
component and then if the parameter is true, it pauses the current thread,
otherwise it doesn't. I have two clients that hit the service at the same
time and while one is paused the other is constantly hitting the service. I
am expecting the second client to block while first one is paused. Can
anyone tell me why this isn't happening? Do I need to pause or perform some
long running process from within the COM component to see the behavior I am
talking about?

The end goal is to make sure exposing portions of this COM dll will scale if
called from within a WCF service. I have read articles like the following
that make me very cautious of doing this:

http://msdn.microsoft.com/msdnmag/issues/06/10/WickedCode/

If this is indeed a problem, does anyone know a work around like the one
Re: Exposing VB6 COM dll via WCF chriscap
1/16/2008 11:25:01 AM
No it has not been tested in a multi-threaded environment. Can you recommend
any resources to help detect this? Can you explain why this would be an
issue?

[quoted text, click to view]
Re: Exposing VB6 COM dll via WCF chriscap
1/16/2008 12:47:01 PM
To reiterate, this is a vb6 component. I've only heard of heap corruption
from c++ when manually allocating memory. Is this still an issue with vb6?
I can't seem to find much on the topic.

[quoted text, click to view]
Re: Exposing VB6 COM dll via WCF John Saunders [MVP]
1/16/2008 2:01:58 PM
[quoted text, click to view]

Scalability may not be your greatest problem. Has this COM component ever
been tested in a multi-threaded environment (especially, on a multiple CPU
system)? If it hasn't been tested in such an environment, then it may not
work in that environment. I've seen heap corruption problems and such from
COM components that claimed to be thread safe and were not.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Re: Exposing VB6 COM dll via WCF John Saunders [MVP]
1/17/2008 8:06:32 AM
[quoted text, click to view]

Heap corruption was just an example of one issue I've encountered before.
It's one instance of the general problem: "if you don't test it, then don't
expect it to work".

Unless VB6 takes special precautions to permit code that was not written for
a multi-threaded environment to work in a multi-threaded environment, then I
wouldn't expect it to work. Instead, I'd expect you to receive a number of
strange crashes and other failures over the lifetime of the application.
They may or may not seem to be related to the COM component, but they
actually will be.

I would recommend that you find another strategy that doesn't involve the
expectation that your VB6 component "just happens to work".

Otherwise, Good Luck!
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

AddThis Social Bookmark Button