0

My application is running on Windows Embedded Standard 7 and launches when the OS boots up.

Sometimes on the first load, I will get an Unknown Hard Error, and after checking the Event Viewer, I see a message of

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

Needless to say, I of course have no calls to this function. I only seem to see this happen on Windows Embedded, and haven't seen this reproduced on a standard install of Windows.

I'm unsure of how to diagnose this or what 'fix' would be appropriate as I don't really know why it happens.

Edit:

The entire log in Event Viewer:

    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()
pay
  • 366
  • 3
  • 18
  • Looks like you can get a dump file if the path is configured [in the registry](http://stackoverflow.com/questions/7808541/where-is-the-application-dump-created-by-environment-failfast-located-on-the-d). Also does the event viewer post the stack? It would be helpful to see the stack trace. – Quantic Apr 15 '16 at 15:14
  • It does have the stack trace in the event log, but unfortunately there is nothing that originates from any call that I make. The entire stack trace is internal .NET calls that eventually call `FailFast`. I will try to edit in the stack trace though. – pay Apr 15 '16 at 15:36
  • I lied there are a few of my calls in there. – pay Apr 15 '16 at 15:48

1 Answers1

1

If you look at the code with a decompiler you will find

    // 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"));
    }
}

The code fails at the assert because that is the only method which calls FailFast

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

Now the question remains why you package could not be found in the PartList array. WPF fills some things out for you. Could it be that you reference from your XAML some resource via an internet addresses or a network share which could fail if the network subsystem of your Windows embedded is not yet ready?

Alois Kraus
  • 13,229
  • 1
  • 38
  • 64
  • I was thinking something along these lines actually, maybe if I add 10-30 seconds of delay before the software loads it may give the OS more time to be 'ready'. Thanks for the information though, I'll look around to see if there's possibly some resource that's pathed wrong or something weird. I was also considering that there may be a service that doesn't start in time for my software to load properly. – pay Apr 15 '16 at 18:42