Reflection.Emitを使用して作成された動的生成アセンブリがあります。私は、次のようにウィンザーを使用して、そのアセンブリからコントローラタイプを登録しようとしています:キャッスルウィンザーはダイナミックアセンブリのタイプを登録できますか?
WindsorContainer.Register(Classes.FromAssembly(myDynamicAssembly).BasedOn<ApiController>().LifestylePerWebRequest());
私は、私は次のエラーを取得するこれらのコントローラの一つに指定されたエンドポイントに移動してみてください。
[NotSupportedException: The invoked member is not supported in a dynamic assembly.]
System.Reflection.Emit.InternalAssemblyBuilder.GetExportedTypes() +68
Castle.Core.Internal.ReflectionUtil.GetAvailableTypes(Assembly assembly, Boolean includeNonExported) +74
Castle.MicroKernel.Registration.FromAssemblyDescriptor.<SelectedTypes>b__0(Assembly a) +21
System.Linq.<SelectManyIterator>d__14`2.MoveNext() +267
Castle.MicroKernel.Registration.FromDescriptor.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) +296
Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations) +72
Castle.Windsor.WindsorContainer.Register(IRegistration[] registrations) +50
ダイナミックアセンブリで何かを登録することはできませんか、または私が紛失している他の問題がありますか?
Windsorを使用しない場合(つまり、デフォルトのコントローラーアクティベーターサービスを使用している場合)、アセンブリー/コントローラー/エンドポイントは正しく機能します。 Reflection.Emitの代わりにWindsorのDynamicProxy機能を使用することもできますが、私はこの難しい課題に取り組む前に、この現行のアプローチですべての可能性を尽くしたいと思います!