Visual Studio / Expression - RemoteException

时间:2013-03-10 18:51:51

标签: exception visual-studio-2012 geolocation expression-blend

使用地理位置创建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>-->

有什么想法吗?

提前致谢!

1 个答案:

答案 0 :(得分:0)

我有同样的问题。为了解决这个问题,我刚做了类似的事情:

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

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