Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some auto-load assemblies logic

  • Loading branch information...
commit dff9c423da72e2460edc30ea66b6b4757924e4f6 1 parent 0811ef1
@randyburden authored
Showing with 23 additions and 6 deletions.
  1. +21 −0 src/Scrumee.Web/Global.asax.cs
  2. +2 −6 src/Scrumee.Web/Web.config
View
21 src/Scrumee.Web/Global.asax.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
@@ -42,6 +43,8 @@ protected void Application_Start()
RegisterRoutes( RouteTable.Routes );
+ LoadAllBinDirectoryAssemblies();
+
ControllerBuilder.Current.SetControllerFactory( new Scrumee.Infrastructure.StructureMapControllerFactory() );
Scrumee.Infrastructure.StructureMapBootstrapper.BootstrapStructureMap();
@@ -54,5 +57,23 @@ protected void Application_EndRequest()
{
Scrumee.Infrastructure.StructureMapBootstrapper.ReleaseAndDisposeAllHttpScopedObjects();
}
+
+ public static void LoadAllBinDirectoryAssemblies()
+ {
+ string binPath = System.IO.Path.Combine( System.AppDomain.CurrentDomain.BaseDirectory, "bin" ); // note: don't use CurrentEntryAssembly or anything like that.
+
+ foreach ( string dll in Directory.GetFiles( binPath, "*.dll", SearchOption.AllDirectories ) )
+ {
+ try
+ {
+ Assembly loadedAssembly = Assembly.LoadFile( dll );
+ }
+ catch ( FileLoadException loadEx )
+ { } // The Assembly has already been loaded.
+ catch ( BadImageFormatException imgEx )
+ { } // If a BadImageFormatException exception is thrown, the file is not an assembly.
+
+ } // foreach dll
+ }
}
}
View
8 src/Scrumee.Web/Web.config
@@ -9,14 +9,10 @@
<connectionStrings>
<add name="SqliteProjects" connectionString="Data Source=|DataDirectory|Projects.db" providerName="System.Data.SQLite" />
</connectionStrings>
-
+
<system.data>
<DbProviderFactories>
- <remove invariant="System.Data.SQLite"/>
- <add name="SQLite Data Provider"
- invariant="System.Data.SQLite"
- description=".Net Framework Data Provider for SQLite"
- type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
+ <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
</DbProviderFactories>
</system.data>
Please sign in to comment.
Something went wrong with that request. Please try again.