Hanging RPC Listeners under a .NET service in COM object
-
This is a re-post of an article I put in the COM section. It refers to .NET, COM and RPC so it's kind of hard to get coverage by people with appropriate skillsets. Here is the problem: As soon as I installed XPSP2 the startup code in a COM object instantiated by a .NET Service hangs. This in turn cause the service to hang. Observations: The COM object is instantiating an RPC Listener when it hangs. It specifically hangs on an endpoint registration, though raaaarely it continues through after getting an error code. The function in question is RpcServerUseProtseqEp and it returns 1740 (duplicate endpoint) or hangs. I am very sure the endpoint is NOT already registered. If I manually start my service it will work. If I delay the service start by 5 minutes (in code) it will start. If I add almost every service dependency I can it will still hang. If I have another service start the COM object (query a web page in background) it starts fine!! This all seems to work fine under 2000 SP4 and under the previous XP. I may just require a service environment (if it works under 2003), but I would really like to fix this behavior. This requires .NET, COM & RPC familiarity so I may have to move this to another forum. Assert(this); -- modified at 11:21 Monday 3rd April, 2006 Ok, found the fix for this. The RPC listener code was initiated in the DllMain section of the COM object. The DllMain section is a bad section to put any init code in due to lots of system locks etc... being set when that is called. Evidently XPSP2 has added some that were not there before and a previously working app. can now lock up.