question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot get Last Exception

See original GitHub issue

Description

I am working on a unit test project. I have a base test file where I have the following line in my Assembly Initialize method.

AppDomain.CurrentDomain.FirstChanceException += (s, e) => LastException = e.Exception;

This line will store the last thrown exception in the Last Exception field. This can then be called by the following line and inserted into reports.

WebUtility.HtmlEncode(LastException.Message)

This worked in the old Test Framework NuGet package: VS.QualityTools.UnitTestFramework (version 15.0.27323.2)

but in the new Test Framework NuGet package: MSTest.TestFramework (version 1.4.0)

I see the following error passed to the Last Exception field. Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.resources, Version=14.0.0.0, Culture=en-GB, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Steps to reproduce

  1. Put the following line in a test class: public static Exception LastException { get; private set; }
  2. Put the following line in a test method: AppDomain.CurrentDomain.FirstChanceException += (s, e) => LastException = e.Exception;
  3. Follow that line with this line: throw new System.Exception("Test Error Message");
  4. Run the unit test in debug mode
  5. When the exception is thrown, press F10 to step to the next line
  6. When execution moves to LastException = e.Exception, hover over e.Exception

Expected behavior

Last Exception should equal System.Exception with a message of “Test Error Message”.

Actual behavior

An error is displayed: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.resources, Version=14.0.0.0, Culture=en-GB, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Environment

Windows 10 .Net Framework 4.7.2 MSTest.TestFramework (version 1.4.0) MSTest.TestAdapter (version 1.4.0)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
karanjitsinghcommented, Aug 6, 2019

Found a workaround for this issue the culture needs to be set on culture en instead of en-US.

Tried Thread.CurrentThread.CurrentUICulture = new CultureInfo("en"); and it seems to be working. By the same logic CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en"); should work as well.

1reaction
dmcdowellsqscommented, Jul 29, 2019

@karanjitsingh I have added the following as the first line of the Test Method. I get the same error. CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");

If you add the following, can you reproduce my issue? CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-GB");

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Sims 4 Last Exception Error: How To Fix
The 'last exception' error usually appears when cc (custom content) and mods are out of date. Read here to learn how to fix...
Read more >
Getting a Last Exception Notification in The Sims 4? Here's ...
Try opening either the MC_LastException or the BE-ExceptionReport and read the main line to see if any mod is named. If there is,...
Read more >
How to get the last exception object after an error is raised ...
I was able to get the last raised exception using sys.exc_info() . Usage: import sys ex_type, ex_value, traceback = sys.exc_info().
Read more >
HOW TO FIX LAST EXCEPTION ERRORS THE SIMS 4
... Sims 4 LastException Assistant ➫ https:// lastexception.com/ Better Exception Mod (Updated) ➫ https://www.patreon.com/TwistedMexi/posts ...
Read more >
Could anyone tell me what is causing this Last Exception UI in ...
The last exception shows when some mod or CC interferes with the game..Unfortunately, this also appears when it catches an error in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found