1

使用地理位置创建 WP7 项目时,VS2012 UI 设计器会抛出此错误:

Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteException
Could not load file or assembly 'LocationService.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e' or one of its dependencies. System could not find the specified file.
   in System.Device.Location.GeoCoordinateWatcher.Dispose(Boolean disposing)
   in System.Device.Location.GeoCoordinateWatcher.Finalize()

我在 Google 和 StackOverflow 上进行了搜索,没有发现任何有用的东西。如果我重新加载设计器,它会在 Visual Studio 2012 中工作一两分钟。但是,如果我尝试打开项目,Expression Blend 会立即崩溃。

这是我的一个页面的内容(但无论内容如何,​​它都会在每个页面中崩溃):

<phone:PhoneApplicationPage 
x:Class="Dropi.MapView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
shell:SystemTray.IsVisible="True" xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps" Loaded="onLoaded" Unloaded="onViewUnloaded">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"></StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <my:Map Height="717" HorizontalAlignment="Left" Name="myMap" VerticalAlignment="Top" Width="450" CredentialsProvider="ApxwcCwErohOLVMieO3OPc0MrdT379URDUphvhbyR10udU9QmiYBK2urEPZZ1pl-" Mode="Road" ZoomBarVisibility="Visible" ZoomLevel="12"/>
    </Grid>
</Grid>

<!--Sample code showing usage of ApplicationBar-->
<!--<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
        <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
        <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
        <shell:ApplicationBar.MenuItems>
            <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
            <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
        </shell:ApplicationBar.MenuItems>
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>-->

任何想法?

提前致谢!

4

1 回答 1

0

我遇到过同样的问题。为了解决它,我只是做了这样的事情:

 if (!ViewModelBase.IsInDesignModeStatic)
 {
     _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) { MovementThreshold = 5 };
 }

[更新] 这是 MVVM Light 解决方案。您可以通过检查 System.ComponentModel.DesignerProperties.IsInDesignTool 来检查您是否处于设计模式

于 2013-03-22T13:26:59.483 回答