首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >组件服务。以编程方式添加具有特定用户凭据的组件。vb.net

组件服务。以编程方式添加具有特定用户凭据的组件。vb.net
EN

Stack Overflow用户
提问于 2015-05-29 10:09:20
回答 1查看 394关注 0票数 0

我试图在vb.net应用程序中向com服务添加组件。除了给组件分配用户角色之外,我已经让一切都正常工作了。如果没有指定的角色,则无法访问该组件。

下面是我添加对象的代码,我一直得到一个“值不属于预期范围”的错误。

如果能对此提供任何帮助,我们将不胜感激。

代码语言:javascript
复制
 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-04 08:10:13

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

我看错了。基本上,在部署组件时,它使用windows资源管理器路径“\machinename\c$.”部署它。(应该是“C:\filepath……”)这意味着,如果本地机器无法访问“远程访问”本身,那么它就无法访问组件。

我能够访问包含组件集"DLL“路径的属性。但由于它的可读性,它是不能改变的。

我还在尝试不同的方法,看看我是否可以用机器本地路径来部署它,但我只是想为其他人发布一个关于这个问题的更新。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30526873

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档