How a AppDomain Can load an assembly by it's physical path.
来源:互联网 发布:软件项目验收管理制度 编辑:程序博客网 时间:2024/06/15 06:09
AppDomain Only have the Load() method which can only load assembly by name. What if you want to load from the physical path? See the code following:
// Assembly you want to load
String assemblyFileName = @"D:TestTest.exe";
String assemblyName = @"Test";
// Setup the evidence
Evidence evidence = new Evidence( AppDomain.CurrentDomain.Evidence );
AppDomain TestDomain = AppDomain.CreateDomain(
// The friendly name of the domain.
"TestDomain",
// Evidence mapped through the security policy to establish a top-of-stack permission set.
evidence,
// The base directory that the assembly resolver uses to probe for assemblies.
AppDomain.CurrentDomain.BaseDirectory,
// The path relative to the base directory where
// the assembly resolver should probe for private assemblies.
System.IO.Path.GetFullPath( assemblyFileName ),
// If true, a shadow copy of an assembly is loaded into this application domain.
true );
Console.WriteLine( TestDomain.Load( assemblyName ).FullName );
AppDomain.Unload( TestDomain ); // Unload the AppDomain
String assemblyFileName = @"D:TestTest.exe";
String assemblyName = @"Test";
// Setup the evidence
Evidence evidence = new Evidence( AppDomain.CurrentDomain.Evidence );
AppDomain TestDomain = AppDomain.CreateDomain(
// The friendly name of the domain.
"TestDomain",
// Evidence mapped through the security policy to establish a top-of-stack permission set.
evidence,
// The base directory that the assembly resolver uses to probe for assemblies.
AppDomain.CurrentDomain.BaseDirectory,
// The path relative to the base directory where
// the assembly resolver should probe for private assemblies.
System.IO.Path.GetFullPath( assemblyFileName ),
// If true, a shadow copy of an assembly is loaded into this application domain.
true );
Console.WriteLine( TestDomain.Load( assemblyName ).FullName );
AppDomain.Unload( TestDomain ); // Unload the AppDomain
- How a AppDomain Can load an assembly by it's physical path.
- HOW TO: Create an Assembly with a Strong Name
- How to embed a manifest in an assembly
- 关于Assembly.Load(path).CreateInstance
- How to load an ImageView by URL in Android
- How can I send an email by Java application?
- Could not load file or assembly ... An attempt was made to load a program with an incorrect format.
- How to see the Physical SQL generated by a request in Presentation Service ?
- Could not load file or assembly system.data.sqlite.dll or one for it's depedencies
- dynamic load an assembly from GAC
- An example of how to do a simulation by LAMMPS
- How can I change a file's encoding with vim?
- c# Runtime load library; Load Assembly from Specific Directory Path
- How to Shrink A LVM Physical Volume
- An interface is not a pointer to an object. It's an interface.
- how hard can it be? Estimating the difficulty of visual search in an image
- 《How hard can it be? Estimating the difficulty of visual search in an image》和 PPT
- Oracle 11g Active Data Guard step by step: How to create a Physical Standby Database using RMAN
- http://blog.csdn.net/lovetangtang linux unix 相关
- 开张!
- QTP日志实践的几点总结
- file控件只有一个可以的写数据地方,但可读,其它控件一般是可读也可写
- 穿过代理服务器取远程用户真实IP地址:
- How a AppDomain Can load an assembly by it's physical path.
- ASP.NET中的窗体身份验证
- 组策略--分发软件
- 权限控制的设计思路
- Vi使 用 说 明
- 多层架构简述
- 鱼和水的故事--完整版
- delphi中的时间操作技术(1)
- 图解eclipse+myelcipse开发EJB[ZZ] + My Deployment