0
ioc에서 구조 맵을 사용하고 싶습니다. 내가 RegisterTypesFromAssembly 함수를 호출 할 때이 줄은 오류IOC의 구조 맵
Assembly implAssembly = Assembly.Load(assemblyImplName);
을 가지고 있으며,이 오류를 참조
public class StructureMapDependencyResolverConfigurator : IDependencyResolverConfigurator
{
public static bool _isStarted = false;
public void Configure()
{
ObjectFactory.Initialize(x =>
{
try
{
RegisterTypesFromAssembly("ImenBourse.Data", "ImenBourse.Data.AdoSql", typeof(IDaoBase), x);
RegisterTypesFromAssembly("ImenBourse.Data", "ImenBourse.Data.AdoSql", typeof(IQueryBase), x);
RegisterTypesFromAssembly("ImenBourse.Domain.Service", "ImenBourse.Domain.Impl", typeof(IServiceBase), x);
}
catch (Exception e)
{
}
});
}
public IControllerFactory ControllerFactory { get { return new StructureMapControllerFactory(); } }
public IContainer Container { get { return ObjectFactory.Container; } }
private void RegisterTypesFromAssembly(string assemblyInterfaceName, string assemblyImplName, Type baseType, IInitializationExpression initializer)
{
Assembly intAssembly = Assembly.Load(assemblyInterfaceName);
var interfaceList = intAssembly.GetTypes().Where(assemblyType => assemblyType.IsInterface && baseType.IsAssignableFrom(assemblyType) && baseType != assemblyType).ToList();
if (interfaceList.Count == 0)
interfaceList = intAssembly.GetTypes().Where(assemblyType => assemblyType.IsInterface && baseType != assemblyType).ToList();
Assembly implAssembly = Assembly.Load(assemblyImplName);
var implList = implAssembly.GetTypes().Where(assemblyType => assemblyType.IsClass && baseType.IsAssignableFrom(assemblyType)).ToList();
foreach (var type in interfaceList)
{
foreach (var implType in implList)
{
if (type != implType && type.IsAssignableFrom(implType))
{
initializer.ForRequestedType(type).Use(implType);
}
}
}
}
:
Could not load file or assembly 'ImenBourse.Data.AdoSql' or one of its dependencies.The system cannot find the file specified.
및 ImenBourse을
이 내 코드입니다. Data.AdoSql 어셈블리는 다음과 같습니다.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ImenBourse.Data.AdoSql")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ImenBourse.Data.AdoSql")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
내가 오류 RegisterTypesFromAssembly에서 어셈블리 이름에 ".DLL"을 추가
파일이 존재합니까? 프로세스에 액세스 할 수있는 권한이 있습니까? –
예, 모든 폴더에 권한이 있지만 오류가 표시됩니다. –