问题
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

回答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
来源:https://stackoverflow.com/questions/16300144/setting-application-recycling-settings-for-com-component-from-code-command-li