开发者

ActiveRecord initialize method in Application_Start

开发者 https://www.devze.com 2023-02-01 00:54 出处:网络
I have a site that uses ActiveRecord. I\'m getting an exception that says \"An ActiveRecord class () was used but the framework seems not properly initialized. Did you forget about ActiveRecordStarter

I have a site that uses ActiveRecord. I'm getting an exception that says "An ActiveRecord class () was used but the framework seems not properly initialized. Did you forget about ActiveRecordStarter.Initialize() ?" This is a web application, and the Initialize() method is called by the Application_Start event handler.

I created a new page that also calls the initialize() method. If I visit that page once, then the rest of the site works. If I visit it a 开发者_如何学Gosecond time, I get an exception stating that the Initialize() method can only be called once.

I've tried modifying the web.config and resetting the application pool to force Application_Start to run.

This only happens in production; dev, my stage, and client stage are fine. Production is the only load-balanced environment--I'm not sure if that comes into play.

Edit: We have another site deployed in the same environment which successfully uses ActiveRecord with the same initialization code. One difference is that the site that is working has only the ActiveRecord code in Application_Start; the site that doesn't also sets up some URL routing in Application_Start.

Any ideas what would cause this?


It turns out that Application_Start was never called. There was a file called PrecompiledApp.config that must have been left in just the production site from a previous agency. The existence of that file prevents Application_Start from running.

0

精彩评论

暂无评论...
验证码 换一张
取 消