0

I have created AppDomainSetup and applied to console project and it works fine. But when I applied it with VSIX, it doesn't work and I don't know why. Could you someone look into it and help me get out of it.

public class Proxy : MarshalByRefObject
{
    public Proxy()
    {
    }

    public Type[] GetTypes(string assemblyName)
    {
        var assembly = Assembly.LoadFile(assemblyName);
        return assembly.GetExportedTypes();
    }
}

The code on VSIX MenuItemCallback

private void MenuItemCallback(object sender, EventArgs e)
{
    string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName);
    string title = "ProxyCommand";

    var cachePath = Path.Combine(@"D:\Temp", "ShadowCopyCache");
    var pluginPath = Path.Combine(@"D:\Temp", "Plugins");
    if (!Directory.Exists(cachePath))
    {
        Directory.CreateDirectory(cachePath);
    }

    if (!Directory.Exists(pluginPath))
    {
        Directory.CreateDirectory(pluginPath);
    }
    var setup = new AppDomainSetup
    {
        CachePath = cachePath,
        ShadowCopyFiles = "true",
        ShadowCopyDirectories = pluginPath
    };

    domain = AppDomain.CreateDomain("MyDomain", AppDomain.CurrentDomain.Evidence, setup);

    domain = AppDomain.CreateDomain("MyDomain", AppDomain.CurrentDomain.Evidence, setup);
    var proxy = (Proxy)domain.CreateInstanceAndUnwrap(typeof(Proxy).Assembly.FullName, typeof(Proxy).FullName);
    var types = proxy.GetTypes("TestAssembly");           
    AppDomain.Unload(domain);
}
thehennyy
  • 4,020
  • 1
  • 22
  • 31
Joon w K
  • 777
  • 1
  • 6
  • 27

0 Answers0