1

如果 AxMapPoint 对象被合并到 Windows 窗体控件库中,则 MapPoint 可以在 WPF 应用程序中使用。

创建一个简单的测试应用程序,在 MainWindows.xaml 中具有以下主体

<Grid x:Name="LayoutRoot">     
    <Grid Name="mapControl" Loaded="MapPointControl_Loaded"/>
</Grid>

在创建 WPF 项目时工作。CodeBehind 函数调用如下所示。

private void MapPointControl_Loaded(object sender, RoutedEventArgs e)
    {
        try
        {
                // Create the interop host control.
                System.Windows.Forms.Integration.WindowsFormsHost host =
                    new System.Windows.Forms.Integration.WindowsFormsHost();


                //  mpControl = new 
                MapPointControl userControl = new MapPointControl();
                host.Child = userControl;

                // Add the interop host control to the Grid
                // control's collection of child controls.
                this.mapControl.Children.Add(host);

        } catch { }

这适用于 WPF 项目,

但是,创建 MVVM 项目不起作用。

此行发生故障

                MapPointControl userControl = new MapPointControl();

出现以下对话框

FileNotFoundException 被捕获

无法加载文件或程序集“Interop.MapPoint,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。该系统找不到指定的文件。

(Interop.MapPoint.dll 存在于 bin/Debug 文件夹中)

在 Visual Studio 中。

4

1 回答 1

0

启用 Fusion 日志查看器并共享结果。它应该告诉您缺少什么依赖项。

  1. 单击开始-> 输入“fusion”并右键单击Fusion Log Viewer以以管理员身份运行。

  2. 单击设置-> 将绑定失败记录到磁盘。

  3. 触发异常,然后在日志查看器中单击“刷新”。

  4. 在 Fusion 中显示的条目上单击“查看日志”。分享结果。

于 2012-05-03T17:00:43.890 回答