2011-11-15 3 views
20

VS 2010でWebサイトのプロジェクトを構築するとき、私は次の例外を取得しています:ActivationManagerビルドプロセス中の例外?

The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..  

は、どのように私はこれをデバッグについては行くのですか? VS.NETやコマンドラインから(例えば、NAnt/MSBuild経由で)ビルドすると起こります。

+0

答えはどれですか? –

答えて

2

詳細なエラーメッセージを表示するには、msbuildタスクまたはコマンドラインの冗長レベルを上げます。

たとえば、/verbosity:detailedを使用します。

http://msdn.microsoft.com/en-us/library/ms164311.aspx

あなたはNinjectを使用していますか?を参照してください。 http://groups.google.com/group/ninject/browse_thread/thread/1934e9260ba07ecd?pli=1この:
もしそうなら、これを参照してくださいhttp://www.techques.com/question/1-6173194/Strange-behaviour-when-using-Ninject-to-resolve-a-service-within-a-controller-factory

あなたがRavenDBを使用していますか?
もしそうなら、これを参照してください。http://groups.google.com/group/ravendb/browse_thread/thread/437738caf4760ce1/b7e92fd6cfeaaa17?#b7e92fd6cfeaaa17

23

は、この問題を解決するには、aspnetcompilerに-errorstack引数を指定する必要があります。それが失敗すると、今見ている例外のスタックトレースだけでなく、ラップしているInnerExceptionも取得します。例えば、ここでビルドエラーがロードされていないカセットDLLでの問題によって引き起こされる出力です:

error ASPRUNTIME: The pre-application start initialization method Run on type We 
bActivator.ActivationManager threw an exception with the following error message 
: Exception has been thrown by the target of an invocation.. 

[TypeLoadException]: Could not load type 'Cassette.Configuration.ICassetteConfig 
uration' from assembly 'Cassette, Version=0.8.1.0, Culture=neutral, PublicKeyTok 
en=null'. 
    at Cassette.Web.StartUp..cctor() 

[TypeInitializationException]: The type initializer for 'Cassette.Web.StartUp' t 
hrew an exception. 
    at Cassette.Web.StartUp.PreApplicationStart() 

[TargetInvocationException]: Exception has been thrown by the target of an invoc 
ation. 
    at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Ob 
ject target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAt 
tributes, RuntimeType typeOwner) 
    at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Obj 
ect target, Object[] arguments, Signature sig, MethodAttributes methodAttributes 
, RuntimeType typeOwner) 
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke 
Attr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisib 
ilityChecks) 
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke 
Attr, Binder binder, Object[] parameters, CultureInfo culture) 
    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) 
    at WebActivator.BaseActivationMethodAttribute.InvokeMethod() 
    at WebActivator.ActivationManager.RunActivationMethods[T]() 
    at WebActivator.ActivationManager.RunPreStartMethods() 
    at WebActivator.ActivationManager.Run() 

[InvalidOperationException]: The pre-application start initialization method Run 
on type WebActivator.ActivationManager threw an exception with the following er 
ror message: Exception has been thrown by the target of an invocation.. 
    at System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection` 
1 methods) 
    at System.Web.Compilation.BuildManager.CallPreStartInitMethods() 
    at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appMan 
ager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, Host 
ingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception a 
ppDomainCreationException) 

[HttpException]: The pre-application start initialization method Run on type Web 
Activator.ActivationManager threw an exception with the following error message: 
Exception has been thrown by the target of an invocation.. 
    at System.Web.Compilation.ClientBuildManager.EnsureHostCreated() 
    at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuil 
dManagerCallback callback, Boolean forceCleanBuild) 
    at System.Web.Compilation.Precompiler.Main(String[] args) 
+16

将来のシークャを保存するには、 'aspnet_compiler.exe -errorstack -p C:\ physical \ path \ to \ MyApp -v MyApp'を実行してください。 – neontapir

+2

aspnet_compiler.exeの場所:' C \ Windows \ microsoft.net \ framework \ \ aspnet_compiler.exe \ –

+0

コマンドラインパラメータの詳細:https://msdn.microsoft.com/en-us/library/ms229863(v=vs.140).aspx –

5

私がアップ投票Xoltarの答えたいのですが、これはSOそうに私の最初の貢献であります私は担当者を持っていない!

私はここにビルドログからのクリップですが、私たちのビルドサーバー(チームシティー)に非常によく似た問題を抱えていた:

[00:10:39]: (MvcBuildViews target) -> 
[00:10:39]: error ASPRUNTIME : The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation.. [C:\TeamCity\buildAgent\work\1ee8c94c32e676ad\source\Project.Site\Project.Site.csproj] 
[00:10:39]:  0 Warning(s) 
[00:10:39]:  1 Error(s) 
[00:10:39]: Time Elapsed 00:00:27.93 

私は-errorstackを使用して、ASPNET_COMPILERを実行した問題を診断するには引数に対して何かMSBUILDがサイト用に生成しています。この場合:(ビルドサーバーにインストールされていない)Azureのアセンブリの1に私の場合は

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_compiler -p "C:\TeamCity\buildAgent\work\1ee8c94c32e676ad\source\Project.Site" -v anything -errorstack 

Utility to precompile an ASP.NET application 
Copyright (C) Microsoft Corporation. All rights reserved. 

error ASPRUNTIME: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message : Exception has been thrown by the target of an invocation.. 

[FileNotFoundException]: Could not load file or assembly 'msshrtmi, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 
    at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeEnvironment() 
    at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment..cctor() 

error ASPRUNTIME: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message : Exception has been thrown by the target of an invocation.. 

依存性が問題の根本的でした。

1

私の場合、TeamCityでメッセージ[AspNetCompiler] error ASPRUNTIME error message: Value cannot be null.が表示されていました。フルビルドログで

は、下でより多くの有益なメッセージがあった。

error ASPRUNTIME : The pre-application start initialization method InitializePreStart on type MyApplication.MvcApplication threw an exception with the following error message: Value cannot be null. 

それは私がPreApplicationStartMethodを使用して、私が定義されていたメソッドがスローされた例外を持っていた結局のところ:

[assembly: System.Web.PreApplicationStartMethod(typeof(MyApp.MvcApplication), "InitializePreStart")] 

namespace PrintFleet.PFE.RestService 
{ 
    public class MvcApplication : System.Web.HttpApplication 
    { 
     //.... 
     public static void InitializePreStart() 
     { 
      // exception thrown here 
     } 
    } 
} 

私の場合は、プレスタートメソッドがレジストリから設定をロードしていたため、ビルドサーバーには存在しませんでした(ただし、マシン上で実行したため、ビルド時に機能しました)。私はWebdeploymentプロジェクトがこのコードを実行する理由を知りません。

私は試しに全体をラップしました。致命的なメッセージを記録するcatch(私のアプリでは、ログファイルとWindowsイベントログの両方に行きます)。ビルドでは、何もする必要がないので、失敗するかどうかは気にしません。実際のインストールでは、設定が不足していると、アプリケーションは機能しません(ログでその理由が説明されます)。


ここで、問題はWebアクティベータにあるようです。私はWebActivatorから来ているように見えるようにエラーを投げているApp_Startフォルダにwebactivorを使用するメソッドがある場合、私は驚かないでしょう。最初にチェックし、必要に応じて試してみてください。 webactivator自体にバグが存在する可能性もあります。


この問題を調査している間にこの記事を読んだので、この情報は少なくとも他の人にとっては有益です。

TL; DR:Web配置プロジェクトは、コンパイル時にApplicationPreStartメソッドを実行します。事前開始時に実行されるコードの周りにtry..catchブロックがあることを確認するか、IIS /ホスティング環境外のビルドサーバーでコンパイル時にコードが実行される状況を処理することができます。

関連する問題