tags:

views:

24

answers:

1

Hi,

We are doing the following in the Application_Start (Global.ascx.cs) for a WCF Service hosted by IIS 7.0 (integrated pipeline).

        var mapperConfigurations = AppDomain.CurrentDomain.GetAssemblies()
            .SelectMany(a => a.GetExportedTypes().Where(t => typeof (IMapperConfiguration).IsAssignableFrom(t) && t.IsClass))
            .ToList();

The web-service has 8-10 assemblies in its bin folder and each of them have multiple implementations of IMapperConfiguration. After an IIS Reset, no mapper configurations are found (found this using debug.write). However, this behaviour is inconsistent and at other times all implementations of IMapperConfiguration are found.

When exactly does IIS load assemblies and what is wrong with this code?

Thanks

+1  A: 

its simple. .net loads a assembly only if it is really needen. this means that you want to have a instance of a type in a assembly.

in your case you must load them explicit.

Jack
Then why does it fail only intermittently?
SharePoint Newbie
because at this time the assemblies are not loaded and then "GetAssemblies()" do not reach the expected assemblies.if the iis restarts the page, the appdomain is newly created and then this assemblies must be loaded explicit. the best place to do it is in the global.asax in the applicationstart method.
Jack