リフレクションを使用して現在実行中のアセンブリのパスを取得し、いくつかの型の登録に使用しようとしています。これは静的/共有メソッドで呼び出されています
Dim Path = System.Reflection.Assembly.GetExecutingAssembly.Location
この行は、次の詳細で StackOverflow 例外をスローします。
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
System.StackOverflowException
Data: unable to evaluate expression.
HelpLink: unable to evaluate expression.
HResult: unable to evaluate expression.
InnerException: unable to evaluate expression.
Message: unable to evaluate expression.
Source: unable to evaluate expression.
StackTrace: unable to evaluate expression.
TargetSite: unable to evaluate expression.
呼び出しはメインスレッドで行われています。.Net 4.5/VS11 Beta を使用しています
記録のためにGetEntryAssembly
、、、GetCallingAssembly
など...すべて同じことをします。私はこれまでにこの動作を見たことがありません (または読んだことさえありません) - 誰か提案はありますか?
編集:
OS:Win7 x64 Ultimate Winformsアプリです
依存関係リゾルバーを返す必要がある共有メソッドがあります(抽象化するために独自のクラスにラップされています)。
Private Shared _Resolver As IDependencyResolver
Public Shared Function QuickResolver() As IDependencyResolver
If _Resolver Is Nothing Then
Dim Container = New WindsorContainer
''Line below was breaking so I exploded it into multiple lines as shown above
Dim CurrentPathFilter = New AssemblyFilter(IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location))
Container.Register(
Component.For(Of Interfaces.ISomeInterface)().
ImplementedBy(Of DAL.SomeType).LifestylePerThread)
''.... More registrations ....
Dim Resolver As New WindsorDependencyResolver(Container)
_Resolver = Resolver
End If
Return _Resolver
End Function
それはシングルトンっぽいです(初期化を別の方法にリファクタリングする必要があることは知っています-それは私のリストにあります)
Winforms UI スレッドから次のように呼び出されます。
Resolver = Common.DependencyResolverFactory.QuickResolver
ScanRepository = Resolver.Resolve(Of IRepository(Of Scan))()
例外はGetExecutingAssembly
行によってスローされています (例外が壊れる場所です) 私はそれが異常であることを認めているので、私のコードがそれを SO に近づけており、GetExecutingAssembly メソッドがオーバーフローするほど深くネストされていると仮定していますか?