-
Notifications
You must be signed in to change notification settings - Fork 331
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
Dotnet Core test executed in Visual Studio 2017 - Assembly.Load() is incorrectly able to load assemblies from Visual Studio Extensions #632
Comments
Is this issue not clearly worded? Just wondering since it doesn't seem to have been triaged. To try and simplify I've attached a simpler test that doesn't use the ravendb client.
This test project has no reference to log4net, so this test should pass. But if the 'PowerShell Tools' extension is installed in Visual Studio, the log4net assembly is found in the extension directory mentioned above, and the assembly is loaded (though it's not even a dotnet core/standard assembly, so any usage of that library fails). A test passing or failing should not depend on an unrelated Visual Studio extension being installed or not. During test execution, assemblies should not be loaded from extension directories. |
Interesting. I guess this is happening because of the powershell tools test adapter that the test platforms assembly resolution is automatically pointing to. Since this is .Net core there isn't a separate appdomain where tests are loaded and run from. It looks like the test adapter assembly resolver is creeping into the test run. We need to turn it off after the adapter is loaded. |
I am facing a similar issue. What is the resolution here? |
I had same issue, and to move on, I installed dependency of log4net and that fixed the issue. |
That will work, but what if I dont want to use log4net?moreover the version of log4net being used in incompatible with netcore, should that reference even be loaded? Also is there a way we can prevent test adapter assembly resolver from kicking in? @AbhitejJohn ? |
Thanks @jonstelly @spati2 for reporting this. We'll investigate. @Faizan2304 is this issue same as the desktop adapters nuget? We shouldn't be passing the powershell adapter to netcore test runs. |
Thanks @codito for responding. So can I expect a fix from you guys on this? Customers on AWS SDK dot net toolkit are encountering this very issue and I am afraid any fix that we add to our sdk would not be a foolproof solution |
Yes, we will fix this. |
@codito : This is not adapter nuget issue. I need to debug more to find the root cause. |
Fixed will come in next preview of visual studio. |
) * Clear cache after discover/execution complete. * Sort usings * Fix for issue: 1) microsoft#632 2) microsoft#844 * nitpick: Spelling * Addressed PR comment * spelling correction * nitpick: function name * Removed unused usings (cherry picked from commit 0eef86b)
* Clear extensions cache after discover/execution complete. (#853) * Clear cache after discover/execution complete. * Sort usings * Fix for issue: 1) #632 2) #844 * nitpick: Spelling * Addressed PR comment * spelling correction * nitpick: function name * Removed unused usings (cherry picked from commit 0eef86b) * Add portable pdb support for net46. (#856) (cherry picked from commit c70c0c8) * Install shared farmework compatible with particular version of CLI (#857) (cherry picked from commit 322bf71)
…se/2.0.0-to-master-20170620-070043 * dotnet/release/2.0.0: (34 commits) Simple clean up to the store tests Updating xlf files for the Configurer. Removing NuGetConfig from the first run experience and replacing the sentinel with the FirstUseNoticeSentinel when needed. Moving the expanding fallback folder to the dotnet folder hive. The folder will be expanded at sdk/NuGetFallbackFolder. Fixing CRLF issue. Updating xlf and fixing line ending problems with one file. Add rhel and Debian download link Fix race in telemetry msbuild arg tests Avoid repeating the first-run message if lzma archive is missing Use fluent helper for line-end normalization Update CoreSetup to preview3-25419-01 Updating Roslyn to 2.3.0-beta3-61816-04 Update CoreSetup to preview3-25418-01 insert new tpv2 which fixes following issue microsoft/vstest#632 microsoft/vstest#844 microsoft/vstest#847 microsoft/vstest#840 microsoft/vstest#843 Windows installer refresh Update SDK to 1.1.0-alpha-20170615-3 Updating NuGet to 4.3.0-preview3-4168 MSBuild 15.3.388 Make dotnet-sln-add.Tests pass on localized setup Make dotnet-sln-list.Tests pass on localized setup ...
…se/2.0.0-to-master-20170621-070039 * dotnet/release/2.0.0: (35 commits) Fixing an issue in the RepoDirectoriesProvider where it assumed that the only directory under SDK was the SDK directories. This is no longer true now that we moved the NuGet fallback folder there. Simple clean up to the store tests Updating xlf files for the Configurer. Removing NuGetConfig from the first run experience and replacing the sentinel with the FirstUseNoticeSentinel when needed. Moving the expanding fallback folder to the dotnet folder hive. The folder will be expanded at sdk/NuGetFallbackFolder. Fixing CRLF issue. Updating xlf and fixing line ending problems with one file. Add rhel and Debian download link Fix race in telemetry msbuild arg tests Avoid repeating the first-run message if lzma archive is missing Use fluent helper for line-end normalization Update CoreSetup to preview3-25419-01 Updating Roslyn to 2.3.0-beta3-61816-04 Update CoreSetup to preview3-25418-01 insert new tpv2 which fixes following issue microsoft/vstest#632 microsoft/vstest#844 microsoft/vstest#847 microsoft/vstest#840 microsoft/vstest#843 Windows installer refresh Update SDK to 1.1.0-alpha-20170615-3 Updating NuGet to 4.3.0-preview3-4168 MSBuild 15.3.388 Make dotnet-sln-add.Tests pass on localized setup ...
Hello I am getting below mentioned errors when implementing Log4Net in Xamarine Visual Studio 2017 project. System.TypeInitializationException occurred |
When will the preview be available? |
Description
Attempting to execute dotnet core unit/integration tests that use RavenDB 3.5.3 client. These tests execute and pass using the dotnet CLI, or the ReSharper Test Runner in Visual Studio, but using the Test Explorer, they fail with an error about log4net and AppDomain.add_ProcessExit:
From debugging, I found that the ravendb client attempts to load log4net using Assembly.Load(...). If it's able to load then it uses that library for logging. The issue is that it's finding log4net from the directory of an installed Visual Studio extension. When debugging, I can see that the CodeBase for the log4net assembly loaded by my test is:
I don't believe test code should be able to load assemblies from extensions loaded into Visual Studio, and I bet in this case, this log4net assembly is built against the full runtime, and not dotnet core or one of the netstandard targets. I believe that explains the message I included above.
This extension directory is the powershell tools for Visual Studio. When I removed that component for Visual Studio, the tests started passing.
Steps to reproduce
ProcessExitException.zip
Expected behavior
The test should pass
Actual behavior
It fails as noted above
Environment
Windows 10 15025+
Visual Studio 2017 (with the PowerShell component installed)
Workaround
Remove the PowerShell component (and probably also Xamarin/Mobile tools, I see log4net.dll in that extension also)
The text was updated successfully, but these errors were encountered: