-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not load file or assembly 'Microsoft.VisualStudio.ArchitectureTools.PEReader - 16.0.2-preview #2008
Comments
@tim-arheit |
I have found the offending code which is suppose to load a list of types that implement a particular interface:
It works in production, but when running unit tests on 16.0.2 or 16.1.0 it is failing when calling GetTypes on 'Microsoft.VisualStudio.ArchitectureTools.PEReader'. throwing the error: I don't know what changed with the test runner to cause this, but the simple fix is to filter out the assemblies we are calling GetTypes on first. Thanks |
@tim-arheit I cannot think of anything that seems related to this, with respect to changes in the test platform. From your comment I am inferring that this was something in your code that you have fixed now. Is that correct? |
@singhsarab, today I got the same error. My tests were working in the past, but today after I updated my Visual Studio to the latest version (I have VS 2019 and updated it today to Version 16.1, and after that update, my tests started failing with the same error. In my code I also have the line of code, which I used to tell AutoMapper to scan all asemblies (in the past it worked):
As can be seen below, error is same as posted by @tim-arheit above:
Thanks,
|
I've also just updated Visuals Studio 2019 and also got this exception when running my unit tests. Most of them ran fine, but I have some integration tests where I query the assemblies in the AppDomain for adding them to my IServiceCollection. For some reason, when running the unit tests from within Visual Studio, my code tries to get the types within the namespace My broken code:
My working code:
|
Based on all the above, it seems that the quick fix in all 3 cases seems to be additional filtering of assemblies to prevent scanning the assemblies that are referencing Microsoft.VisualStudio.ArchitectureTools.PEReader, Version=16.0.0.0 The interesting question is why it's searching for Microsoft.VisualStudio.ArchitectureTools.PEReader Version=16.0.0.0.... Perhaps that's why the tests work with VS 16.0 and tests fail with VS 16.1... |
I also got the same exception,AutoMapper's dependency injection test can work in VS16.0, but there is a problem in VS16.1. |
Just wanted to add that I'm now getting this exception as well. Same scenario where I am scanning all assemblies and their types in a unit test. |
the same issue for me, the unit-test used to pass before moving to visual studio 2019 16.1.1 my code: getting this exception: |
We have the same problem. It was mentioned in the release notes for 16.1.1 but is persisting. Rollback to visual studio 2017 works for now. |
the new vs2019 (16.2.0) test explorer has an issue with GetAssemblies when it tries to load internal test assemblies microsoft/vstest#2008 with this fix the Microsoft assemblies are not loaded when an integration test runs (FunctionMonkey.Testing.AbstractAcceptanceTest)
@EskilSaatvedt - I'm not seeing it anywhere in the release notes for 16.1.1. I am hoping that a fix makes it into 16.1.2 or 16.2 though. |
Just ran into the same error after update of Visual Studio to the latest version. After some search I found, that all the failing tests are doing a scan on the loaded assemblies of the application domain. After digging a little deeper, the following code produces the error:
Be aware that this error really only occurs if you run the test within Visual Studio 16.1.1 through the Test Explorer. |
And just for the people searching for an easy to use solution for their tests. Replace
with
Maybe you get an error, cause the return value of this call is changed to |
Bypass the problem that the test runner cannot load types from assembly 'Microsoft.VisualStuduo.TraceDataCollector'. microsoft/vstest#2008
- Change logo in dark and light mode. - (Sadly) stupid bug fix to fix the integration unit tests. See microsoft/vstest#2008 - Description for all API endpoints for Swagger file.
Bypass the problem that the test runner cannot load types from assembly 'Microsoft.VisualStuduo.TraceDataCollector'. microsoft/vstest#2008
I am also getting this error when running tests after updating to Visual Studio 16.1.1 The code under test is using mediatr and that is scanning assemblies looking for classes that implement specific interfaces an that is where the error gets thrown. The tests run fine from the command line. |
@xygon When initializing MediatR in asp core you use the extension method |
Just updated to 16.1.2 and tried again. Unfortunately the error is NOT fixed. So hoping for the next version. |
I agree, this issue persists! |
@olivermue Can you please check if the issue still persists with 16.2.0-preview-20190606-02? |
Took my unit test from above and created a new xUnit test project with VS Community 16.2.0 Preview 1.0. The error is still:
|
@olivermue The fix will be available in VS 16.2.0 Preview 3. |
Yes @olivermue ! |
Getting the same exception when Debugging NUnit tests that utilize TestCaseSource attribute. |
Tested with VS Community 16.2.0 Preview 3.0 and the error is FIXED. |
@olivermue Thanks for confirming. |
The issue still seems to exist, even when using the Visual Studio Test Platform Installer. |
Why is this closed? I get this error in latest visual studio 2019 when running unit tests, calling assembly.GetTypes()... No such issue in VS 2017. Should not be closed until a non-preview release is out that fixes the issue. |
/// <summary>
/// Get all types from all assemblies
/// </summary>
/// <returns>List of all types</returns>
public static List<Type> GetAllTypes()
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
List<Type> allTypes = new List<Type>();
foreach (Assembly assembly in assemblies)
{
try
{
// some assemblys throw in unit tests in VS 2019, bug in MSFT...
allTypes.AddRange(assembly.GetTypes());
}
catch
{
}
}
return allTypes;
} |
I ran into this issue with the following code
Explicitly adding the assembly fixed it for me:
VS 16.1.5 |
I still get this problem - it prevents my unit tests from running. Microsoft Visual Studio Enterprise 2019 |
Yes, in Enterprise this error still exists (just tested it again, also with 16.1.6). Due to the fact, that it is solved in VS Community 16.2.0 Preview 3.0 I would guess we have to wait till the Enterprise Version 16.2.x arrives. And in case you use Azure DevOps, you have to wait till Microsoft releases a new hosted agent image. Depending on how Microsoft names this agent, you then have also to configure your build pipeline to use this new version, but after taking a look at the Microsoft docs, changes are high, that they make an in-place update but you never know (and especially you don't know when). So my current advice would be to implement my suggested workaround above and re-try it at the end of the year to check if the error still persists. If not revert the workaround and if yes make the next try two month later. |
I am also not clear on what version fixes this and agree this should not have been closed under a preview release. Is there any confirmation that Visual Studio Professional 2019 version 16.2.2 fixes this issue? |
This isn't fixed on any of my versions of VS...not sure why this isn't a trivial fix?!? |
I have Visual Studio Professional 16.2.2 and the issue is fixed. |
Just installed Visual Studio Enterprise 2019 Version 16.2.3 and I can confirm the error is fixed. So the only bogus version is within Azure DevOps the agent pool image Hosted Windows 2019 with VS2019 image, cause it contains VisualStudio/16.1.6+29102.190 |
Description
When running the unit tests in an Azure devops build pipeline "(https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/vstest?view=azure-devops) using 16.0.2-preview
Many of the unit tests throw the error:
System.AggregateException : One or more errors occurred. (The type initializer for 'Velocity.Common.Processors.Base.Common.ProcessorBaseFactory' threw an exception.)
----> System.TypeInitializationException : The type initializer for 'Velocity.Common.Processors.Base.Common.ProcessorBaseFactory' threw an exception.
----> System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.VisualStudio.ArchitectureTools.PEReader, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.VisualStudio.ArchitectureTools.PEReader, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Reverting back to 16.0.1 solves the issue.
Steps to reproduce
Run unit tests in Azure Devops (Visual Studio Test), after running 'Visual Studio Test Platform Installer' set to Latest (Includes-Pre-release) which installs and causes tests to run on 16.0.2-preview
Expected behavior
No error
Actual behavior
Could not load file or assembly 'Microsoft.VisualStudio.ArchitectureTools.PEReader
Environment
Azure DevOps, Visual Studio 2017 Pro, Windows Server 2016
The text was updated successfully, but these errors were encountered: