简体   繁体   中英

Scanning Assemblys using StructureMap in Asp.net MVC 5

I using StructureMap for dependency resulution.

I have 2 projects

  • Project.Web (Website)
  • Project.Web.DependencyResolution (Main Registry is located here and Scanning Starts here.)

I am unable to use :

        Scan(
            scan =>
            {
                scan.AssembliesFromPath("bin", AssemblyFilter);
                scan.LookForRegistries();
                });  

As this is not able to find the location and gives a Weird path for the assembly.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\project.web
\25abf8e7\23716017\assembly\dl3\7faa87f3\c3224109_5602d001
\project.Web.DependencyResolution.dll  

Why does the assembly not able to find the bin directory or the directory where the project get published/compiled ?? I have treis this using IIS and IIS Express

Any help/tips to setup this structure ?? Thanks :)

Please try this way:

Scan(
      scan =>
       {
         scan.AssembliesFromPath(Path.GetDirectoryName((new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath)), AssemblyFilter);
         scan.LookForRegistries();
        });  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM