我正在尝试整理一个小帮手工具来加密web.config文件.
Linqpad的例子:
var path = @"F:\project\"; var wcfm = new WebConfigurationFileMap(); wcfm.VirtualDirectories.Add("/",new VirtualDirectoryMapping(path,true)); var config = Configuration.WebConfigurationManager.OpenMappedWebConfiguration(wcfm,"/"); var c = config.Sections["customGroup"]; c.Section@R_72_404[email protected](null); config.Save();
这引发了异常:
Could not load file or assembly 'customGroupAssembly' or one of its dependencies. The system cannot find the file specified
将程序集添加到LinqPad可修复errpr.我认为这是因为它现在是编译时引用.
将代码移动到winforms应用程序,重新引入该问题.
我正试图在运行时加载所需的程序集:
if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { byte[] assemblyBuffer = File.ReadAllBytes(this.openFileDialog1.FileName); AppDomain.CurrentDomain.Load(assemblyBuffer); MessageBox.Show("Assembly loaded!"); }
但是它似乎仍然没有找到该文件.
有没有办法将自定义程序集加载到运行时应用程序域中,以便可以正确加载Web配置?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。