0

我的应用程序正在运行Windows Embedded Standard 7并在操作系统启动时启动。

有时在第一次加载时,我会得到一个Unknown Hard Error,在检查事件查看器后,我会看到一条消息

The application requested process termination through System.Environment.FailFast(string message).
Message: Unrecoverable system error.

不用说,我当然没有调用这个函数。我似乎只在 Windows Embedded 上看到这种情况,并没有在标准安装的 Windows 上看到这种情况。

我不确定如何诊断这个或什么“修复”是合适的,因为我真的不知道它为什么会发生。

编辑:

事件查看器中的整个日志:

    Application: WinForm.exe
    Framework Version: v4.0.30319
    Description: The application requested process termination through System.Environment.FailFast(string message).
    Message: Unrecoverable system error.
    Stack:
       at System.Environment.FailFast(System.String)
       at MS.Internal.Invariant.FailFast(System.String, System.String)
       at System.IO.Packaging.Package.AddIfNoPrefixCollisionDetected(ValidatedPartUri,     
System.IO.Packaging.PackagePart) at System.IO.Packaging.Package.GetPartHelper(System.Uri)
   at System.IO.Packaging.Package.GetPart(System.Uri)
   at System.Windows.Application.GetResourceOrContentPart(System.Uri)
   at System.Windows.Application.LoadComponent(System.Object, System.Uri)
   at Pms.PmControl.InitializeComponent()
   at Pms.PmControl..ctor(Boolean)
   at Pms.PmAppControl.StartWpfThread()
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()
4

1 回答 1

1

如果你用反编译器查看代码,你会发现

    // System.IO.Packaging.Package
private void AddIfNoPrefixCollisionDetected(PackUriHelper.ValidatedPartUri partUri, PackagePart part)
{
    this._partList.Add(partUri, part);
    int num = this._partList.IndexOfKey(partUri);
    Invariant.Assert(num >= 0, "Given uri must be present in the dictionary");**
    string normalizedPartUriString = partUri.NormalizedPartUriString;
    string text = null;
    string text2 = null;
    if (num > 0)
    {
        text = this._partList.Keys[num - 1].NormalizedPartUriString;
    }
    if (num < this._partList.Count - 1)
    {
        text2 = this._partList.Keys[num + 1].NormalizedPartUriString;
    }
    if ((text != null && normalizedPartUriString.StartsWith(text, StringComparison.Ordinal) && normalizedPartUriString.Length > text.Length && normalizedPartUriString[text.Length] == PackUriHelper.ForwardSlashChar) || (text2 != null && text2.StartsWith(normalizedPartUriString, StringComparison.Ordinal) && text2.Length > normalizedPartUriString.Length && text2[normalizedPartUriString.Length] == PackUriHelper.ForwardSlashChar))
    {
        this._partList.Remove(partUri);
        throw new InvalidOperationException(SR.Get("PartNamePrefixExists"));
    }
}

代码在断言处失败,因为这是唯一调用 FailFast 的方法

internal static void Assert(bool condition, string invariantMessage)
{
    if (!condition)
    {
        Invariant.FailFast(invariantMessage, null);
    }
}

现在的问题仍然是为什么在 PartList 数组中找不到你的包。WPF 为您填写了一些内容。如果您的嵌入式 Windows 的网络子系统尚未准备好,您是否可以通过 Internet 地址或网络共享从您的 XAML 中引用某些资源?

于 2016-04-15T18:19:04.353 回答