Hi,
I am developing an add-in inwhich I need to create a new domain to load an assembly and retrieve vb component information. Though I could load the assembly to the current domain using system.reflection.assembly, there is no way I could unload it again. Because system.reflection.assembly does not have unload method. Following is the code which is generating security permission error
Dim pAppset As AppDomainSetup
pAppset = New AppDomainSetup
pappset.applicationbase = "C:\TESTING1\bin" ' Location of the assembly I am trying to load
pappset.ApplicationName = "new domain"
Dim adevidence As System.Security.Policy.Evidence = AppDomain.CurrentDomain.Evidence
Dim pmyEv As System.Security.Policy.Evidence
pmyEv = New System.Security.Policy.Evidence(adevidence)
pAppDom = AppDomain.CreateDomain("secondappdomain", pmyEv, pAppset)
Dim pAssmName As New AssemblyName
pAssmName = AssemblyName.GetAssemblyName("C:\TESTING1\bin\TESTING3.dll"
Dim pAssm As [Assembly]
pAssm = pAppDom.Load(pAssmName) 'here I am getting error
'error message is "Request for the permission of type System.Security.Permissions.FileIOPermission, mscorlib,.......... failed"
'if I add evidence as another parameter
pAssm = pAppDom.Load(pAssmName, pmyEv) 'Here the error is
"Request for the permission of type system.security.Permissions.securitypermission, mscorlib.......... failed"
Can someone help me fix this problem. Is there a easy way to load an assembly? I apprecaite your response.
I am developing an add-in inwhich I need to create a new domain to load an assembly and retrieve vb component information. Though I could load the assembly to the current domain using system.reflection.assembly, there is no way I could unload it again. Because system.reflection.assembly does not have unload method. Following is the code which is generating security permission error
Dim pAppset As AppDomainSetup
pAppset = New AppDomainSetup
pappset.applicationbase = "C:\TESTING1\bin" ' Location of the assembly I am trying to load
pappset.ApplicationName = "new domain"
Dim adevidence As System.Security.Policy.Evidence = AppDomain.CurrentDomain.Evidence
Dim pmyEv As System.Security.Policy.Evidence
pmyEv = New System.Security.Policy.Evidence(adevidence)
pAppDom = AppDomain.CreateDomain("secondappdomain", pmyEv, pAppset)
Dim pAssmName As New AssemblyName
pAssmName = AssemblyName.GetAssemblyName("C:\TESTING1\bin\TESTING3.dll"
Dim pAssm As [Assembly]
pAssm = pAppDom.Load(pAssmName) 'here I am getting error
'error message is "Request for the permission of type System.Security.Permissions.FileIOPermission, mscorlib,.......... failed"
'if I add evidence as another parameter
pAssm = pAppDom.Load(pAssmName, pmyEv) 'Here the error is
"Request for the permission of type system.security.Permissions.securitypermission, mscorlib.......... failed"
Can someone help me fix this problem. Is there a easy way to load an assembly? I apprecaite your response.