Scanning Assemblys using StructureMap in Asp.net MVC 5

342 Views Asked by At

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 :)

1

There are 1 best solutions below

1
On BEST ANSWER

Please try this way:

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