Ir para conteúdo
Fórum Script Brasil
  • 0

Problema ao remover componente do COM+


Guest --Roberval --

Pergunta

Guest --Roberval --

Estou usando o código abaixo para remover componentes do COM+, mas executa o comando "objCatalogComponentCollection.SaveChanges" ocorre um erro. A mensagem de erro é somente "Automation error". Não sei o que pode ser. Alguém pode ajudar?

Estou utilizando uma máquina com Windows 2000.

Private Function RemoveComponent(ByVal AppName As String) As Boolean
     'removes the component installed in the Application
     On Error GoTo Err_RemoveComponent

     Dim objCatalog As COMAdminCatalog
     Dim objCatalogApplicationCollection As COMAdminCatalogCollection
     Dim objCatalogComponentCollection As COMAdminCatalogCollection

     Dim iCounter As Integer
     Dim iComponentCounter As Integer
     Dim bRemoved As Boolean

     Set objCatalog = New COMAdminCatalog
     'getting all the Applications in the server
     Set objCatalogApplicationCollection = objCatalog.GetCollection("Applications")
     objCatalogApplicationCollection.Populate

     'looping through all the Applications to get the current Application
     bRemoved = False
     For iCounter = 0 To objCatalogApplicationCollection.Count - 1
         'Debug.Print objCatalogApplicationCollection.Item(iCounter).Name
         If objCatalogApplicationCollection.Item(iCounter).Name = AppName Then ' if application is found
             'Shutdown the application first
             objCatalog.ShutdownApplication AppName

             'getting the current collection
             Set objCatalogComponentCollection = objCatalogApplicationCollection.GetCollection _
                                          ("Components", objCatalogApplicationCollection.Item(iCounter).Key)
             objCatalogComponentCollection.Populate
             'check if the remove option is enabled
             If objCatalogComponentCollection.RemoveEnabled Then
                 For iComponentCounter = 0 To objCatalogComponentCollection.Count - 1
                     'remove the component, which is always the top one
                     objCatalogComponentCollection.Remove 0
                 Next
             Else
                 'raise an error
                 Err.Raise vbObjectError, "Method:RemoveComponent", "RemoveEnabled property returned false"
             End If

             'saves changes
             objCatalogComponentCollection.SaveChanges

             bRemoved = True
             Exit For
         End If
     Next
     
     RemoveComponent = bRemoved
     
     Exit Function
     
Err_RemoveComponent:
     RemoveComponent = False
     Err.Raise Err.Number, Err.Source, Err.Description
End Function

Editado por kuroi
Adicionar tag CODE
Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...