从网络驱动器启动时,Structuremap 不加载注册表 [英] Structuremap does not load registries when started from Network drive

查看:40
本文介绍了从网络驱动器启动时,Structuremap 不加载注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 structuremap 的狂热(新)用户,但我在加载注册表时遇到问题.

当我从本地驱动器启动应用程序时,应用程序中的所有注册表都用于解析类型.我通过 ObjectFactory.WhatDoIHave() 验证了这一点但是,当我从共享启动相同的应用程序时,并非所有注册表都已加载.似乎只有当前加载在 appdomain 中的注册表才用于注册类型.奇怪的是,该应用程序确实有效.最近我把我的应用从 .Net 3.5 升级到了 4.0,可能跟这个有关系.

这是我到现在为止发现的,这可能是问题吗?.NET 4.0 中的Assembly.LoadFrom() 权限

我注册我的注册表的代码是:

var _container = new Container(x =>{x.扫描(扫描 =>{scan.AssembliesFromApplicationBaseDirectory();scan.LookForRegistries();});});

解决方案

我自己解决了这个问题.问题在这里解释:http://msdn.microsoft.com/en-我们/杂志/ee677170.aspx我将以下内容添加到我的 .config 文件中,然后它就像一个魅力:

<预><代码><配置><运行时><!-- 警告:将从远程位置加载程序集作为完全受信任的!--><loadFromRemoteSources enabled="true"/></运行时></配置>

I am an enthousiastic (new) user of structuremap but I am experiencing a problem loading registries.

When I start my application from a local drive all the registries in my application are used to resolve types. I verified this by ObjectFactory.WhatDoIHave() However when I start the same application from a share then not all registries are loaded. It seems only the registries that are currently loaded in the appdomain are used to register types. The weird thing is that the application did work. Recently I upgraded my application from .Net 3.5 to 4.0, maybe this has something to do with it.

This is what I found until now, could this be the problem? Assembly.LoadFrom() permissioning in .NET 4.0

my code to register my registries is:

var _container = new Container(x =>
            {
                x.Scan(
                    scan =>
                    {
                        scan.AssembliesFromApplicationBaseDirectory();
                        scan.LookForRegistries();
                    });
            });

解决方案

I was able to solve this problem myself. The problem is explained here: http://msdn.microsoft.com/en-us/magazine/ee677170.aspx I added the following to my .config file and then it worked like a charm:

<configuration>
  <runtime>
    <!-- WARNING: will load assemblies from remote locations as fully trusted! -->
    <loadFromRemoteSources enabled="true" />
  </runtime>
</configuration>

这篇关于从网络驱动器启动时,Structuremap 不加载注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆