Can an assembly be executed or loaded within C#.NET COM component? -


I have COM (written in writing) which requires an appdomain and load / execution. NAT conferences in it That's because I can unload that app, later all loaded DLLs together. While working fine in general (eg WinForms) .NET app, I get security related exceptions, if this code runs within the COM context Assuming that the strong name of the COM Assembly has been given and kept in the GAC, there is a complete confidence policy in it. Can anyone explain that this is possible, and if not - why?

Yes, this is possible. To be a CAS, you have to do this:

  [Assembly: System. Security. Allow] Abandoned Callers Attribute ()]  

Specialty Load Assemblies in the COM Assembly will need to add appropriate permissions to the new app domain in such a way to create objects and make assemblies:

  AppDomainSetup setup = New AppDomainSetup (); Setup.ApplicationBase = Path. GetDirectoryName (path); Permission trust trustPermissionSet = new permissions sheet (allowed content unrestricted); AppDomain newDomain = AppDomain.CreateDomain ("Descriptive Name", Blank, Setup, TrustPermissionSet);  

Then you can simply create an object through the CreateInstanceFromAndUnwrap () or executeAssembly . Catalyst :

  System.Rentime.Remote.ObjectHandle objHandle = Activator.CreateInstanceFrom (_pluginStore [Path], to use the path - An alternative solution to this problem Also is pluginClass); If (objHandle! = Null) {Object unwrappedInstance = objHandle.Unwrap (); Result.Add (unwrappedInstance); }  

But after its execution code there is no right to do any "complex stuff".

You can get more information.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -