Results 1 to 2 of 2

Thread: How does the COM+ transaction timeout work?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    2

    How does the COM+ transaction timeout work?

    I do not understand, how the transaction timeout works in COM+. I have the class ClassComPlus which inherits from ServicedComponent, has transaction timeout attribute set to 1 second, and has a method SubSleep, that sleeps 3 seconds. I expect, the client which calls the method SubSleep to get an exception, because the transaction timeout has elapsed, but I do not get such an exception, the method completes without an exception.

    Here is the code in VB.NET. I am sorry it is not in VB6, but unfortunately they could not help me in the VB.NET forums, because they say that COM+ is outdated, and that it was used primarily by VB6 developers.

    1. Project Test1BO.vbproj as Class Library signed with a strong key, having the two files:

    1.1 AssemblyInfo.vb:

    Imports System.EnterpriseServices
    Imports System.Reflection
    Imports System.Runtime.InteropServices
    <Assembly: ApplicationActivation(ActivationOption.Server)>
    <Assembly: ApplicationAccessControl(CType(AccessChecksLevelOption.Application, Boolean))>
    <Assembly: Guid("799facfd-af56-4496-bc18-618e2522e5f7")>
    <Assembly: AssemblyVersion("1.0.0.0")>
    <Assembly: AssemblyFileVersion("1.0.0.0")>

    1.2 ClassComPlus.vb

    Imports System.EnterpriseServices

    <Transaction(TransactionOption.Required, isolation:=TransactionIsolationLevel.ReadCommitted, timeout:=1), _
    EventTrackingEnabled(True), _
    JustInTimeActivation(True)> _
    Public Class ClassComPlus
    Inherits ServicedComponent

    Public Sub SubSleep()
    Try
    Threading.Thread.Sleep(3000)
    ContextUtil.SetComplete()
    Catch
    ContextUtil.SetAbort()
    Throw
    End Try
    End Sub
    End Class

    Test1BO must be registered in COM+ for example with the following RegisterComPlus.bat file in the folder where the dll is created:

    set regsvcs=C:\Windows\Microsoft.NET\Framework\v4.0.30319\regsvcs
    set topdir=%~dp0
    set dllname=Test1BO
    %regsvcs% /u "%topdir%\%dllname%.dll"
    %regsvcs% "%topdir%\%dllname%.dll"
    pause


    2. Project Test1CA.vbproj as Console Application with reference to Test1BO.dll has just Module1.vb:

    Module Module1
    Sub Main()
    Dim obj = New Test1BO.ClassComPlus
    Try
    obj.SubSleep()
    Console.WriteLine("SubSleep finished normally (unexpected)")
    Catch ex As Exception
    Console.WriteLine("SubSleep threw exception (expected)")
    Console.WriteLine(ex.ToString)
    Finally
    obj.Dispose()
    End Try
    Console.ReadKey()
    End Sub
    End Module

    I would expect, that because the transaction timeout is 1 second, but the sleep time is 3 seconds, that the statement obj.SubSleep would throw an exception. Instead, obj.SubSleep finishes normally.

    1. What am I doing wrong?
    2. Did I wrongly understood the transaction timeout?

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How does the COM+ transaction timeout work?

    I'm not sure we can help but you may get lucky and somebody will do the research needed.

    .Net programmers just aren't very sophisticated, that's why they turned up their noses.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width