0

我正在尝试将组件添加到 vb.net 应用程序中的 com 服务。除了为组件分配用户角色之外,我已经完成了所有工作。如果没有此指定角色,则无法访问该组件。

下面是我添加对象的代码,我不断收到“值不在预期范围内”错误。

对此的任何帮助将不胜感激。

 Public Function InstallComPlusComponent(ByVal applicationName As String, _
        ByVal componentAddress As String, ByVal serverName As String) As Boolean

            Dim catalog As New COMAdmin.COMAdminCatalog
            Dim componentName, localAddress As String
            Dim componentClass() As String

            Try
                catalog.Connect(serverName)
            Catch COMEx As COMException
                catalog.Connect(My.Computer.Name)
                'Return False
            End Try

            If Not CheckComPlusAppExists(serverName, applicationName) Then
                Try
                    AddComPlusApplication(applicationName, serverName)
                Catch Ex As COMException
                    Debug.WriteLine(Ex.Message.ToString)
                    Return False
                    Exit Function
                End Try
            End If

            Try
                localAddress = GENERATE_LocalPath(componentAddress)
                catalog.InstallComponent(applicationName, localAddress, "", "")

                'componentName = Microsoft.VisualBasic.Right(componentAddress, 26)
                'componentName = Microsoft.VisualBasic.Left(componentName, 22)
                'componentClass = Microsoft.VisualBasic.Split(Microsoft.VisualBasic.Right(componentName, 11), ".")
                'componentName = componentName & "." & componentClass(0)

                componentName = My.Settings.ComName

                Dim apps As COMAdmin.COMAdminCatalogCollection = CType _
                (catalog.GetCollection("Applications"),  _
                COMAdmin.COMAdminCatalogCollection)

                apps.Populate()

                Dim app As COMAdmin.COMAdminCatalogObject

                For Each app In apps
                    If applicationName = app.Name.ToString Then
                        'GET Component Collection of Application and Populate
                        'FINDS ALL COMS in INTEGRATION OBJECTS
                        Dim Comps As COMAdmin.COMAdminCatalogCollection = CType _
                        (apps.GetCollection("Components", app.Key),  _
                            COMAdmin.COMAdminCatalogCollection)
                        Comps.Populate()

                        'Transaction Option Enum Setting
                        Dim TransactionOption As COMAdminTransactionOptions = _
                                                 COMAdminTransactionOptions.COMAdminTransactionNone

                        Dim iCounter As Integer
                        'looks through the components to find component
                        For iCounter = Comps.Count - 1 To 0 Step -1
                            Dim str As String = Comps.Item(iCounter).Name
                            Console.WriteLine(str)
                            Console.WriteLine(componentName)
                            Console.WriteLine("---------------------")
                            'If Comps.RemoveEnabled Then
                            If Comps.Item(iCounter).Name = componentName Then
                                Dim Comp As COMAdmin.COMAdminCatalogObject
                                Comp = Comps.Item(iCounter)
                                'Comp.Value("Transaction") = CType(TransactionOption, Object)
                                'Comp.Value("Authentication") = CType(COMAdminAuthenticationLevelOptions.COMAdminAuthenticationConnect, Object)
                                Comp.Value("Identity") = CType(frmLogin.strUser.ToString, Object)
                                Comp.Value("Password") = CType(frmLogin.strpassword.ToString, Object)

                                Comps.SaveChanges()
                            End If
                            'End If
                        Next iCounter
                        Exit For
                    End If
                Next 'appOnj In apps
            Catch COMEx As Exception
                Debug.Print("Cannot Install COM+ DLL to Server")
                MessageBox.Show("Cannot Install COM+ DLL to Server" + vbNewLine + COMEx.ToString)
                Return False
            End Try

                Return True
        End Function
4

1 回答 1

0

仅供参考,如果有人有同样的问题。

我一直在看错。基本上,在部署组件时,它使用 Windows 资源管理器路径“\machinename\c$....”(应该只是“C:\filepath....”)这意味着如果本地计算机没有可以访问“远程访问”本身,然后它无法访问该组件。

我能够访问包含组件“DLL”路径的属性。但由于它是只读的,因此无法更改。

仍在尝试不同的事情,看看我是否可以使用机器本地路径部署它,但只是想我会为其他有此问题的人发布更新。

于 2015-06-04T08:10:13.320 回答