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.
CodePudding user response:
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.