0

ioc で structuremap を使用したい。

これは私のコードです:

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);
                }
            }
        }
    }

RegisterTypesFromAssembly 関数を呼び出すと、この行にエラーがあります

Assembly implAssembly = Assembly.Load(assemblyImplName);

そして、私はこのエラーが表示されます:

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("")]

エラーがあるという私のコードのエラーは何ですか

4

1 に答える 1