Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8932295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:18:00+00:00 2026-06-15T09:18:00+00:00

So, one of my websites has a PreApplicationStartMethod that should run before the application

  • 0

So, one of my websites has a PreApplicationStartMethod that should run before the application starts:

[assembly: PreApplicationStartMethod(typeof(ServiceStackAppHost), "Start")]

This methods does some bootstrapping and relies on some configuration being set.

Now, I want to compile the website as part of my automated build process – so I invoke aspnet_compiler.exe, which fails because it runs the PreApplicationStartMethod:

AfterBuild:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -v
temp -p C:\Projects\ error ASPRUNTIME : The pre-application
start initialization method Start on type
RedactedNameSpace.ServiceStackAppHost threw an exception with the
following error message: Resolution of the dependency failed, type =
“…”

How do I avoid aspnet_compiler.exe invoking the PreApplicationStartMethod when compiling the website ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:18:00+00:00Added an answer on June 15, 2026 at 9:18 am

    The short answer is that you can’t prevent it from running, and that this is by design but you can workaround the problem.

    Why PreApplicationStart methods run during aspnet_compiler.exe

    The reason is that PreApplicationStartMethod (or WebActivator, which builds on top of it) can be used for things that actually affect compilation, such that if you omitted it the site may not compile.

    To give you an example, you can add namespaces to the compilation in a PreAppStart method, which then affects compilation of your Razor pages.

    Obviously, not every PreAppStart method needs to run when you use aspnet_precompiler, but we do run all of them in case they are needed.

    Detecting whether you’re running under aspnet_compiler.exe

    If the code in there breaks under aspnet_compiler, it may be necessary to add conditional logic in the PreAppStart method to detect the situation and omit running the code.

    You can look at System.Web.Hosting.HostingEnvironment.InClientBuildManager propery to determine whether your PreAppStart method is running under the context of aspnet_compiler.exe (where it will be true), or at runtime (where it will be false). InClientBuildManager also applies to building a web site within VS, which uses basically the same code path as aspnet_compiler.exe.

    Try using PostStart methods instead

    Note that WebActivator also supports PostApplicationStartMethod, and those will not run under aspnet_compiler. That code runs after Application_Start, so it may or may not be appropriate to your scenario. But it may be a solution for you.

    aspnet_compiler.exe Debugging tip

    Not directly related but useful for debugging: you can pass -errorstack to aspnet_compiler.exe to get a more complete stack when there is an error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a box in one of my websites that has a these property:
We have an application that has been deployed to 50+ websites. Across these sites
I've seen several websites ( like this one and this one ) that says
One of our clients has two very similar websites that we are performing lead
I have a website that has one database I have also Desktop apps that
How can I add a drop shadow effect to a website that has one
I need to find out which account is running one of my websites application
I have a CMS application that manages multiple websites, today whenever i change the
Today one of my websites started showing Error Number: 2006 MySQL server has gone
Just today learned that one of my websites, TwitPeek.net, is not rendering properly in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.