SpecFlow.VS
SpecFlow.VS copied to clipboard
System.InvalidOperationException: Cannot find reference assembly 'System.Core.dll' file for package System.Core
Used Visual Studio
Visual Studio 2022
Are the latest Visual Studio updates installed?
Yes
SpecFlow Section in app.config or content of specflow.json
Using default configuration
Issue Description
I'm trying to find out why our SpecFlow based acceptance tests opening any page returns System.Net.Http.HttpRequestException: No such host is known. (localhost:51955)
on my machine. When I build (and run) our tests, I get the following exception in Visual Studio's Output window (quoted at the end). As a consequence, I cannot debug the steps of the test flow and get to the bottom of the problem.
None of my colleagues have this issue, and can run their tests normally. I strongly suspect the No such host exception is itself a result of the System.InvalidOperationException
, but cannot be sure.
The only difference I can think of between my setup and that of my colleagues', is I run Windows 11, and they still run Windows 10. VS 2022, extensions, code base and test configurations are all the same.
Any ideas what could cause this?
Info: OnActivityStarted: Starting Visual Studio Extension...
Info: CreateProjectScope: Initializing project: Tests.Acceptance
Info: OnSettingsInitialized: Project settings initialized: .NETCoreApp,Version=v6.0,SpecFlow:3.9.40,x64
Warning: AndDiscoveryProviderSucceed: Error during binding discovery.
Command executed:
C:\Users\[...]\bin\Debug> C:\Program Files\dotnet\dotnet.exe exec
C:\Users\[...]\AppData\Local\Microsoft\VisualStudio\17.0_5d585986\Extensions\y5fyggqt.xuh\Connectors\Generic-net6.0\specflow-vs.dll discovery
C:\Users\[...]\bin\Debug\Tests.Acceptance.dll ""
Exit code: 4
Message:
System.InvalidOperationException: Cannot find reference assembly 'System.Core.dll' file for package System.Core
at Microsoft.Extensions.DependencyModel.Resolution.ReferenceAssemblyPathResolver.TryResolveAssemblyPaths(CompilationLibrary library, List`1 assemblies)
at SpecFlowConnector.AssemblyLoading.RuntimeCompositeCompilationAssemblyResolver.TryResolveAssemblyPaths(CompilationLibrary library, List`1 assemblies) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\AssemblyLoading\RuntimeCompositeCompilationAssemblyResolver.cs:line 19
System.InvalidOperationException: Cannot find reference assembly 'System.Core.dll' file for package System.Core
at Microsoft.Extensions.DependencyModel.Resolution.ReferenceAssemblyPathResolver.TryResolveAssemblyPaths(CompilationLibrary library, List`1 assemblies)
at SpecFlowConnector.AssemblyLoading.RuntimeCompositeCompilationAssemblyResolver.TryResolveAssemblyPaths(CompilationLibrary library, List`1 assemblies) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\AssemblyLoading\RuntimeCompositeCompilationAssemblyResolver.cs:line 19
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.TypeLoadException: Could not load type 'System.Collections.Generic.ISet`1' from assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at System.Text.Json.JsonSerializerOptions.GetDefaultSimpleConverters()
at System.Text.Json.JsonSerializerOptions.RootBuiltInConverters()
at System.Text.Json.JsonSerializerOptions.InitializeForReflectionSerializer()
at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions options, Type runtimeType)
at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
at SpecFlowConnector.JsonSerialization.SerializeObject(Object obj) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\JsonSerialization.cs:line 15
at FunctionalExtensions.Map[TSource,TResult](TSource this, Func`2 fn) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\FunctionalExtensions.cs:line 5
at SpecFlowConnector.ReflectionExecutor.Execute(String optionsJson, Assembly testAssembly, AssemblyLoadContext assemblyLoadContext, IDictionary`2 analyticsProperties) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\ReflectionExecutor.cs:line 67
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at SpecFlowConnector.ReflectionExtensions.ReflectionCallMethod[T](Object obj, String methodName, Type[] parameterTypes, Object[] args) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\ReflectionExtensions.cs:line 26
at SpecFlowConnector.ReflectionExtensions.ReflectionCallMethod[T](Object obj, String methodName, Object[] args) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\ReflectionExtensions.cs:line 7
at SpecFlowConnector.ReflectionExecutor.<>c__DisplayClass0_0.<Execute>b__2(Object instance) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\ReflectionExecutor.cs:line 23
at Some`1.Map[TResult](Func`2 map) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\Optional\Some.cs:line 26
at SpecFlowConnector.ReflectionExecutor.Execute(DiscoveryOptions options, Func`3 testAssemblyFactory, ILogger _log, IAnalyticsContainer analytics) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\ReflectionExecutor.cs:line 21
at SpecFlowConnector.Runner.ExecuteDiscovery(DiscoveryOptions options, Func`3 testAssemblyFactory) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 44
at SpecFlowConnector.Runner.<>c__DisplayClass4_0.<Run>b__0(ConnectorOptions options) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 29
at FunctionalExtensions.Map[TSource,TResult](TSource this, Func`2 fn) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\FunctionalExtensions.cs:line 5
at SpecFlowConnector.Runner.Run(String[] args, Func`3 testAssemblyFactory) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 26
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: D. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at SpecFlow.VisualStudio.Connectors.OutProcSpecFlowConnector.Deserialize(RunProcessResult result, Func`2 formatErrorMessage)
Warning: AndDiscoveryProviderSucceed: The project bindings (e.g. step definitions) could not be discovered. Navigation, step completion and other features are disabled.
Please check the error message above and report to https://github.com/SpecFlowOSS/SpecFlow.VS/issues if you cannot fix.
Steps to Reproduce
Sorry, no idea.
Link to Repository Project
No response
Any updates on this? We still have the same issue.