0
私は以下のようにXAPファイルからアセンブリを動的にロードしようとした:ユーザコントロールのインスタンスを動的に作成する必要はありませんか?
AssemblyPart asmPart = new AssemblyPart();
StreamResourceInfo streamInfo = Application.GetResourceStream(new StreamResourceInfo(xapFileStream, "application/binary"), new Uri(source, UriKind.Relative));
Assembly asm = asmPart.Load(streamInfo.Stream);
FrameworkElement element = asm.CreateInstance(className) as FrameworkElement;
それから私は、ユーザーコントロールのメインページをロードしようとしました。メインページはのように単純な場合:
namespace TestApp
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
}
}
場合
それは素晴らしいです。しかし、MainPageのような場合:
namespace TestApp
{
public partial class MainPage : UserControl
{
private readonly Dictionary<IWorkbenchWidget, TabControlElement> tabs;
public MainPage()
{
InitializeComponent();
base.Loaded += new RoutedEventHandler(myHandler);
}
}
}
それは失敗しました。
したがって、クラスのインスタンスを作成するためにAssembly.CreateInstanceを使用するかどうかを知りたい場合は、クラスに対する特別な要求はありますか?