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.

Reason:Unable to find assembly

See original GitHub issue

Description

I have a solution with a mix of .Net Framework 3.5, 4.6.2 and 4.7.2 (it really needs to be updated to 4.8, but I don’t have authorization to spend time on that right now).

I updated the MSTest.TestAdapter and MSTest.TestFramework from 1.4 to 2.2.4 and now the tests are showing in the Test Explorer, but they aren’t run. I was hoping to update just enough and now I’ve lost a lot of time trying different things.

I see this [MSTest][Discovery][C:\chr\git\mySolution\Tests\bin\Debug\net472\MyTests.dll] Failed to discover tests from assembly C:\chr\git\mySolution\Tests\bin\Debug\net472\MyTests.dll. Reason:Unable to find assembly ‘MyNet462.Data, Version=0.0.1.0, Culture=neutral, PublicKeyToken=ba37446064e06eb0’. in the Output > Tests. (I’ve changed the names).

Interesting enough, the tests run in our build with

  • task: VSTest@2 displayName: ‘Run Unit Tests’ inputs: testAssemblyVer2: ‘**\MyTests.dll’ searchFolder: ‘$(Build.BinariesDirectory)’ testFiltercriteria: ‘TestCategory!=Integration’ runOnlyImpactedTests: false runInParallel: true codeCoverageEnabled: false platform: ‘$(BuildPlatform)’ configuration: ‘$(BuildConfiguration)’

Steps to reproduce

I created a new project with a mix of .Net 4.7.2 for the test project and a .Net 4.5.2 class library (MyNet452.Data.dll above it 4.6.2) but I couldn’t reproduce it there. It works great.

I deleted all but a simple test from my real project and the test ran. Once I added in the tests that had usings to the dll referenced, they stopped running.

I attempted upgrading to a .Net Core csproj and target net472, but have the same problem. This is my test project .csproj that works in my test sln, but not in my real sln.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.3" />
    <PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
    <PackageReference Include="Moq" Version="4.16.1" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.2.4" />
    <PackageReference Include="MSTest.TestFramework" Version="2.2.4" />
    <PackageReference Include="coverlet.collector" Version="3.0.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="System.Net.Http" Version="4.3.2" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\OtherWeb.csproj" /> <-- this one references the other one and is 4.5.2 -->
    <ProjectReference Include="..\AnotherClassLibrary.Common.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="System.Runtime.Caching" />
    <Reference Include="System.Web" />
  </ItemGroup>

</Project>

An experiment to upgrade all to .Net 4.6.2 failed as I couldn’t get it to build and ran out of time.

Expected behavior

I need to be able to run the tests in VS.

I know this is a hard one. Maybe the answer is to upgrade everything, but I’d appreciate any pointers or suggestions

Is there a way to get more logs out of MSTest of why it can’t find my dll? I can’t find anything searching about “Reason: Unable to find assembly”. It’s probably due to the MyNet452.Data.dll referencing another project or nuget package or system assembly.

Environment

I’m in Windows 10, trying to run the tests from VS 2019 16.11.0 Preview 1.0 and VS 2019.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
aligneddevcommented, Jun 4, 2021

you got me thinking. I went back to the original, updated to 2.0.0 and it worked. Then I updated to 2.2.4 and it doesn’t run in VS.

I went back to 2.1.0 => that works 2.2.1 brought in more libraries and only half my tests ran. I found the breaking point! image

For now, I’m going to stick with 2.1.0 until we update all of projects.

0reactions
Haploiscommented, Jul 5, 2021

Thank you @HgDorn! We’ll wait for your repro.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Deserialization exception: Unable to find assembly
I do Serialization in one assambly, and do the Deserialization in another one. And this is the excaption saying too: Unable to find...
Read more >
Solved: .NET Unable to find assembly error - NI Community
1. Rename my assembly file to tla700.dll - recompile - run - failed to initialize the assembly at the very begining. 2. Rename...
Read more >
Unable to find assembly · Issue #468 · pythonnet ...
I am trying to load a .NET assembly DLL using pythonnet. This has worked fine for other DLLs (.NET 4) but for one...
Read more >
C# - BinaryFormatter.Deserialize is "Unable to find assembly"
But i'm getting the “Unable to find assembly” error. I don't want reference that assembly that has the object type, since I know...
Read more >
What Is Unable to Load Type from Assembly Error in C ...
This error can occur due to various reasons, such as incorrect assembly references, incorrect class names, or incorrect namespaces. Causes of ...
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