0

I'm working on a large application in which I need a few internal packages to fetch data.

It is building fine, but while debugging the part of code I added I get the following error.

Exception thrown: 'System.AggregateException' in mscorlib.dll An exception of type 'System.AggregateException' occurred in mscorlib.dll but was not handled in user code One or more errors occurred.

Below is output from Debug

'testhost.net472.x86.exe' (CLR v4.0.30319: Domain 3): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.net472.x86.exe' (CLR v4.0.30319: TestSourceHost: Enumerating source (C:\MyProJ\ProjectTests\bin\Debug\.netframework,version=v4.7.2\ProjectTests.dll)): Loaded 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\TestPlatform\.... .dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
....
....

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.AggregateException' in mscorlib.dll
An exception of type 'System.AggregateException' occurred in mscorlib.dll but was not handled in user code
One or more errors occurred.

...
...
'testhost.net472.x86.exe' (CLR v4.0.30319: TestSourceHost: Enumerating source (C:\MyProJ\ProjectTests\bin\Debug\.netframework,version=v4.7.2\ProjectTests.dll)): Loaded 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Remote Debugger\x86\Runtime\Microsoft.VisualStudio.Debugger.Runtime.Desktop.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.net472.x86.exe' (CLR v4.0.30319: Domain 3): Unloaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'

Message from Test Explorer By running the test

System.AggregateException: One or more errors occurred. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Cannot share much detail as it is a internal library.

My project

 <TargetFramework>net472</TargetFramework>

Internal library

<TargetFrameworks>netstandard2.0; net472</TargetFrameworks>

Any suggestions what the possible cause and solution could be.

Saif Haider
  • 511
  • 1
  • 5
  • 16
  • Try to implement steps from [this question](https://stackoverflow.com/questions/38408167/could-not-load-file-or-assembly-system-net-http-version-4-0-0-0-culture-neutr) – GoodboY Jun 29 '22 at 20:24
  • Does this answer your question? [Could not load file or assembly or one of its dependencies](https://stackoverflow.com/questions/4469929/could-not-load-file-or-assembly-or-one-of-its-dependencies) – Jiale Xue - MSFT Jun 30 '22 at 02:01
  • Looks like you are missing a project reference to the package containing System.Net.Http. – sjb-sjb Jun 30 '22 at 11:36

1 Answers1

0

In my case the problem was that my application required azure authentication which it wasn't able to get while I was debugging my application directly and was throwing error when it executed that line of code. By using my application dll file in the main project and executing it from there with authentication I was able to run my code.

Still don't know why I was getting the above error message.

Saif Haider
  • 511
  • 1
  • 5
  • 16
  • Hi Saif Haider, glad to know you've found the solution to resolve this issue! Please consider accepting it as an answer to change its status to Answered. See [can I answer my own question..](https://stackoverflow.com/help/self-answer), Just a reminder :) – Jiale Xue - MSFT Jul 04 '22 at 09:58