1

I have following question:
How can I from c# code or command line script configure Application Recycling settings ?
( please see screenshot below ) I did not succeeded to find appropriate .NET attributes
Your help will be very valuable
Thanks in advance

enter image description here

4
  • Thanks for reply. YEs , I need that COM+component will be registered with the settings during installation . If it can be done from bat it will be OK . Commented May 1, 2013 at 6:22
  • Thanks for link . I tried sample code from the MSDN article, but after run , the settings were not changed . Do I need to perform more operations ( save , commit etc ) ? Thanks Commented May 1, 2013 at 12:53
  • I modified it for VBScript , and it already works . Thanks Commented May 2, 2013 at 15:17
  • Really - after running modified VBScript , you need only to refresh DCOMCNFG UI .. Commented May 3, 2013 at 10:16

1 Answer 1

1

Setting Application Recycling properties of COM+ application is certainly not possible with .bat script per se. To my knowledge, there is no .NET attribute or System.EnterpriseServices helper for doing that either.

COMAdmin is a way to set COM+ application's properties programmatically. See Configuring COM+ Application Recycling Values MSDN page. The page features sample VB6 code for configuring Application Recycling properties.

Below is straightforward port of MSDN sample to VBScript.

If Not SetMyApplicationRecycling("MyApp", 5, 10, 9, 100, 20) Then
    MsgBox "SetMyApplicationRecycling failed."
End If

Function SetMyApplicationRecycling( _
  strApplicationName, _
  lngLifetimeLimit, _
  lngMemoryLimit, _
  lngCallLimit, _
  lngActivationLimit, _
  lngExpirationTimeout _
)  ' Return False if any errors occur.

    SetMyApplicationRecycling = False  ' Initialize the function.
    On Error Resume Next  ' Initialize error handling.

    Dim objAppCollection
    Dim objApplication
    Set objCatalog = CreateObject("COMAdmin.COMAdminCatalog")
    Set objAppCollection = objCatalog.GetCollection("Applications")
    objAppCollection.Populate
    For Each objApplication In objAppCollection
        With objApplication
            If .Name = strApplicationName Then
                .value("RecycleLifetimeLimit") = lngLifetimeLimit
                .value("RecycleMemoryLimit") = lngMemoryLimit
                .value("RecycleCallLimit") = lngCallLimit
                .value("RecycleActivationLimit") = lngActivationLimit
                .value("RecycleExpirationTimeout") = lngExpirationTimeout
                objAppCollection.SaveChanges                

                MsgBox strApplicationName & _
                  " recycling values are now set to the following: " & _
                  vbNewLine & vbNewLine & _
                  "Lifetime Limit (minutes) = " & lngLifetimeLimit & vbNewLine & _
                  "Memory Limit (KB) = " & lngMemoryLimit & vbNewLine & _
                  "Expiration Timeout (minutes) = " & lngExpirationTimeout & vbNewLine & _
                  "Call Limit = " & lngCallLimit & vbNewLine & _
                  "Activation Limit = " & lngActivationLimit

                SetMyApplicationRecycling = True  ' Successful end to procedure
                Exit For
            End If
        End With
    Next

    Set objApplication = Nothing
    Set objAppCollection = Nothing
    Set objCatalog = Nothing

    If Err.Number <> 0 Then
        MsgBox "Error # " & Err.Number & " (Hex: " & Hex(Err.Number) _
        & ")" & vbNewLine & Err.Description 
        Exit Function
    End If
End Function
Sign up to request clarification or add additional context in comments.

Comments

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.