【发布时间】:2015-07-21 17:38:53
【问题描述】:
我有一个适用于 WP8.0 的有效解决方案。但我需要升级才能访问 WNS。我已成功将 WNS 添加到主菜单工程中的升级解决方案中。但是在升级到 wp8.1(silverlight) 之后,我遇到了一些奇怪的错误,这些错误只发生在运行时。例如,它发生在以下用户控件中:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"
xmlns:View="clr-namespace:ShieldGenerator.View"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
x:Class="ShieldGenerator.View.MoveableShieldGear"
mc:Ignorable="d"
Canvas.Left="{Binding Gear.x}" Canvas.Top="{Binding Gear.y}" Canvas.ZIndex="{Binding Gear.z}" >
<Path Data="{Binding Gear.Path}" Fill="{Binding Gear.Color}" Stretch="Fill" UseLayoutRounding="False" Height="{Binding Gear.Height}" Width="{Binding Gear.Width}" Opacity="{Binding Gear.Opacity}">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="{Binding Gear.Scale}" ScaleY="{Binding Gear.Scale}" CenterX="{Binding Gear.CenterX}" CenterY="{Binding Gear.CenterY}"/>
<RotateTransform Angle="{Binding Gear.Rotate}" CenterX="{Binding Gear.CenterX}" CenterY="{Binding Gear.CenterY}" />
<SkewTransform AngleX="{Binding Gear.SkewX}" AngleY="{Binding Gear.SkewY}" CenterX="{Binding Gear.CenterX}" CenterY="{Binding Gear.CenterY}" />
</TransformGroup>
</Path.RenderTransform>
<i:Interaction.Triggers>
<i:EventTrigger EventName="ManipulationStarted">
<cmd:EventToCommand Command="{Binding MouseDownGearCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
<i:EventTrigger EventName="ManipulationDelta">
<cmd:EventToCommand Command="{Binding MouseGearMoveCommand, Mode=OneWay}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
<i:EventTrigger EventName="ManipulationCompleted">
<cmd:EventToCommand Command="{Binding MouseUpGearCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
<i:EventTrigger EventName="DoubleTap">
<cmd:EventToCommand Command="{Binding DoubleTapCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Path>
</UserControl>
在事件绑定到我的 VM 的地方,VM 中的命令定义为RelayCommand。如前所述,这是一个没有错误的工作解决方案。我更新了,编译时仍然没有错误。
我在视图后面没有代码,但错误发生在下面标有 ERROR 的行中(在 *.g.cs 文件中)
namespace ShieldGenerator.View {
public partial class MoveableShieldGear : System.Windows.Controls.UserControl {
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Windows.Application.LoadComponent(this, new System.Uri("/ShieldGenerator;component/View/MoveableShieldGear.xaml", System.UriKind.Relative)); //ERROR
}
}
}
错误是指上述xaml代码中<i:Interaction.Triggers>中的行。
我已尝试卸载和安装多个软件包,但均未成功。
我试图四处搜索,并找到了包含 Mode=Oneway 的想法,以及 xaml 解析器中的一些说明错误。我完全不知所措。
希望有人能帮忙!
错误
在我使用i:interaction 的任何地方都会显示此错误。我一直在寻找一种方法来找到System.Windows.Interactivity 的 wp8.1 版本,但一直没能做到。因此,我确保更新了 MVVMLight 工具:
基于评论的信息
新app.config 的不同之处
是新增的。
新WMAppManifest.xml 的不同之处
NotificationService="WNS" 因为我已经设置了它并且它可以工作
新
<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
</Capabilities>
旧
<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
<Capability Name="ID_CAP_PUSH_NOTIFICATION" />
<Capability Name="ID_CAP_IDENTITY_USER" />
</Capabilities>
我已删除不再使用的功能。并为 WP8.1 添加了新的Package.appxmanifest
<Capabilities>
<Capability Name="internetClientServer" />
<Capability Name="musicLibrary" />
<Capability Name="picturesLibrary" />
根据另一个问题,AGHost.exe 也有问题,但我没有尝试删除它,因为我认为以下内容是强制性的。
<Applications>
<Application Id="xd82c080dy903dy47f4yba02y5a36d745c72bx" Executable="AGHost.exe" EntryPoint="StartUp/FirstPage.xaml">
<m3:VisualElements DisplayName="XXXXX" Square150x150Logo="Assets\SquareTile150x150.png" Square44x44Logo="Assets\Logo.png" Description="XXXX" ForegroundText="light" BackgroundColor="#464646" ToastCapable="true">
<m3:DefaultTile Square71x71Logo="Assets\SquareTile71x71.png">
</m3:DefaultTile>
<m3:SplashScreen Image="Assets\Splashscreen.png" />
</m3:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
<Capability Name="musicLibrary" />
<Capability Name="picturesLibrary" />
</Capabilities>
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>AgHostSvcs.dll</Path>
<ActivatableClass ActivatableClassId="AgHost.BackgroundTask" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
在此文件中找不到任何其他问题。
AssemblyInfo.cs 和 AppManifest.xml 是一样的。查看参考文件夹,参考资料似乎还可以,并且已针对 wp8.1 进行了更新(那些可以)
额外
如果我将 xaml 代码(即具有交互的路径)复制到另一个有效的页面中。然后它在对没有 sn-p 的页面进行 xaml 解析期间失败并出现相同的错误。
新更新 似乎在我升级时,解决方案和项目中的某些东西被损坏了。我发现以下是我可以获取代码并在新项目中工作。 如果我运行和部署项目,代码就可以工作。
另一方面,如果我使用相同的项目,在部署时工作,现在从另一个项目导航到它"/BC_Creator;component/MainPage.xaml" 然后再次出现上述错误。我现在唯一的想法是尝试创建全新的项目并将代码复制粘贴到新文件中。由于导入它们似乎仍然不起作用。
WTF 发生了 :S
【问题讨论】:
-
实际错误是什么?
-
@ChrisW。添加了错误描述,位置 24 是
<i:Interaction.Triggers>行中的.。由于升级后的另一个问题,我无法使用调试器提取错误消息。参考问题stackoverflow.com/questions/31432007/… -
嗯,好的...所以根据您的行数和异常中提到的 System.Windows.ni.dll,我想说这可能与这些触发器无关,或者他们的交互/命名空间等。不过我会问,您是否可能丢失了一些需要手动添加的 WMAppManifest.xaml 中的项目引用?
-
奇怪的是,当我评论他们时,它会起作用。但是我提到的问题中仍然反应缓慢。目前这里已经很晚了。明天我会尝试比较。非常感谢您的提议!
-
@ChrisW。我现在已经能够找到任何错误,所以我添加了很多信息:/因为我很茫然。运行旧代码,即在升级之前,一切正常,我可以运行带有调试器的解决方案。 :/ :S 但我需要新的 WNS 通知,这就是我升级的原因。 . .
标签: c# xaml silverlight windows-phone-8.1 mvvm-light