首页 新闻 赞助 找找看

关于AppDomain动态加载dll问题

0
悬赏园豆:40 [已关闭问题] 关闭于 2010-11-03 13:19

我用AppDomain实现动态加载dll,AppDomainLoader类创建程序域AppDmain,RemoteLoader加载dll,问题是我在AppDomainLoader调用RemoteLoader方法:

public Assembly LoadAssembly(string dllurl)
        {
            _assembly = Assembly.LoadFile(dllurl);
            return _assembly;
        }

该方法执行完没有问题,执行到AppDomainLoader的  return  _remoteLoader.LoadAssembly(dllUrl);时抛出下面异常:

未能加载文件或程序集“Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。

我直接将创建AppDomain和Assembly放到windows服务里面写成一堆的话就没有错误,这是怎么回事?

还有在windows服务的OnStart里面利用反射加载多个dll文件,怎样写?

我尝试以:

                TcpChannel tc = new TcpChannel(8999);
                ChannelServices.RegisterChannel(tc, false);
                Assembly asm = Assembly.LoadFile(@"F:\Work\Test\RemotingTest\ConsoleApplication1\bin\Debug\dll\Test.dll", "Test.Test");
                Type type = asm.GetType("Test.Test");
                RemotingConfiguration.RegisterWellKnownServiceType(type, "test", WellKnownObjectMode.SingleCall);

                TcpChannel tc = new TcpChannel(8899);
                ChannelServices.RegisterChannel(tc, false);
                Assembly asm = Assembly.LoadFile(@"F:\Work\Test\RemotingTest\ConsoleApplication1\bin\Debug\dll\Test1.dll", "Test.Test");
                Type type = asm.GetType("Test.Test");
                RemotingConfiguration.RegisterWellKnownServiceType(type, "test1", WellKnownObjectMode.SingleCall);
这样的形式直接放在windows服务的启动里面,结果出错了。

萧鼎的主页 萧鼎 | 初学一级 | 园豆:106
提问于:2010-10-29 15:58
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册