从 ArcGIS 桌面加载项按钮运行 WPF/PRISM 应用程序时出错,无法加载模块
当我尝试从 ArcMap
中的按钮加载项运行使用 PRISM 的 WPF 应用程序时,OnClick
事件会初始化并显示 Shell.xaml
但是当它尝试加载区域中的模块和控件时,我收到此错误:
无法将透明代理转换为类型“InnerModuleInfoLoader”
按钮加载项针对 onclick
事件处理程序提供了此功能:
protected override void OnClick()
{
App app = new App();
app.InitializeComponent();
app.Run();
}
在 App.xaml.cs
中,然后运行引导程序 OnStartUp
:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Bootstrapper bootstrapper = new Bootstrapper();
bootstrapper.Run();
}
模块被复制到加载项的 bin\Modules
文件夹:
protected override IModuleCatalog CreateModuleCatalog()
{
var moduleCatalog = new DirectoryModuleCatalog();
moduleCatalog.ModulePath = @".\Modules";
return moduleCatalog;
}
引导程序的 Run()
方法最多执行初始化并显示 Shell:
protected override void InitializeShell()
{
base.InitializeShell();
App.Current.MainWindow = (Window)this.Shell;
App.Current.MainWindow.Show();
}
但在尝试将模块和控件加载到区域的部分,我收到该错误。 WPF 应用程序本身运行良好,但当按钮运行它时,它无法完成。
我不是棱镜专家,只是尝试将其作为下一个版本的原型,因此任何帮助将不胜感激。
When I tried running a WPF app that uses PRISM from a button add-in in ArcMap
, the OnClick
event goes as far as initializing and showing the Shell.xaml
but when it tries to load the modules and the controls in the regions, I get this error:
Unable to cast transparent proxy to type 'InnerModuleInfoLoader'
The button add-in has this for the onclick
eventhandler:
protected override void OnClick()
{
App app = new App();
app.InitializeComponent();
app.Run();
}
In the App.xaml.cs
then runs the bootstrapper OnStartUp
:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Bootstrapper bootstrapper = new Bootstrapper();
bootstrapper.Run();
}
The modules are copied to the Add-In's bin\Modules
folder:
protected override IModuleCatalog CreateModuleCatalog()
{
var moduleCatalog = new DirectoryModuleCatalog();
moduleCatalog.ModulePath = @".\Modules";
return moduleCatalog;
}
The bootstrapper's Run()
method goes as far as initializing and showing the Shell:
protected override void InitializeShell()
{
base.InitializeShell();
App.Current.MainWindow = (Window)this.Shell;
App.Current.MainWindow.Show();
}
But on the part where it tries to load the modules and the controls into the regions, I get that error. The WPF app by itself runs fine, but when the button runs it, it doesn't finish.
I'm not a prism expert, just trying this as a prototype for a next version, so any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于解决了这个问题。错误消息基本上告诉我它不知道“InnerModuleInfoLoader”是什么,所以我尝试将 prism DLL 放入调用应用程序(第 3 方按钮加载项)的 bin 文件夹中,瞧,它通过了错误信息。我们希望不必将 DLL 放入 GAC 或第 3 方应用程序/bin 文件夹中,但我想我们必须将它们放入 GAC 中,或者可能将第 3 方应用程序的环境变量中的路径设置为找到他们。
Finally resolved this issue. The error message was basically telling me that it doesn't know what "InnerModuleInfoLoader" was, so I tried placing the prism DLLs in the bin folder of the calling app (3rd party button add-in) and voila, it got past through the error message. We were hoping we did not have to put the DLLs in the GAC or in the 3rd party app/bin folder but I guess we would have to either place them in the GAC or maybe set the path in the EnvironmentVariable for the 3rd party app to find them.