I'm using Team City for continual integration, for a .Net 4 ASP MVC 3 application.
On my dev machine I can build and run my application, but on the build sever I'm getting the following error:
ASPNETCOMPILER : error ASPRUNTIME: Type is not resolved for member 'FluentNHibernate.Cfg.FluentConfigurationException,FluentNHibernate, Version=1.2.0.712, Culture=neutral, PublicKeyToken=8aa435e3cb308880'
The FluentNHibernate assembly is referenced by the project and I've even added the assembly to the web.config assemblies section, but I still get the error.
What can I do to diagnose the problem?
To sum up Rob White's comment, the problem is certain code running in WebActivator.PreApplicationStartMethod
. The fix is to move that code into Application_Start
in the Global.asax
.
The WebActivator.PreApplicationStartMethod
is an assembly attribute for loading code extremely early in the build process. Phil Haack give a good description. The attribute is supposed to be used for registering build providers and other things that are used later in the build process. As such, the ASPNET compiler has to load and run this code in order to begin compilation of views.
I got this particular error on appharbor after I added some code to my IoC (StructureMap) startup code that accessed a resource (MongoDB). Since this resource wasn't accessible to the appharbor build machine, it threw all kinds of errors.
The takeaway is that PreApplicationStartMethod
is meant for pre-application-start things, like building, not initializing the application. If you're doing app initialization things, do it in Global.asax
Application_Start
. I know the default StructureMap NuGet package for MVC4 uses the attribute instead of Global
. There might be other packages that lead you to that same mistake.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With