SpecFlow.VS icon indicating copy to clipboard operation
SpecFlow.VS copied to clipboard

The project bindings (e.g. step definitions) could not be discovered. Navigation, step completion and other features are disabled.

Open SerhiiPolehenko opened this issue 9 months ago • 13 comments

Used Visual Studio

Visual Studio 2022

Are the latest Visual Studio updates installed?

Yes

SpecFlow Section in app.config or content of specflow.json

<PackageReference Include="SpecFlow" Version="3.9.74" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74" />

Issue Description

Info Found V3.9.74.14555 at C:\Git\SystemTests\ScanItDental.SystemTest.WorkflowProcessingTest\bin\Debug\net6.0-windows\TechTalk.SpecFlow.dll Info Chosen BindingRegistryFactoryBeforeV310000 for 309074 Error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Could not load file or assembly 'PresentationCore, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.Assembly.GetTypes() at TechTalk.SpecFlow.Bindings.Discovery.RuntimeBindingRegistryBuilder.BuildBindingsFromAssembly(Assembly assembly) at TechTalk.SpecFlow.TestRunnerManager.BuildBindingRegistry(IEnumerable1 bindingAssemblies) at TechTalk.SpecFlow.TestRunnerManager.InitializeBindingRegistry(ITestRunner testRunner) at TechTalk.SpecFlow.TestRunnerManager.CreateTestRunner(Int32 threadId) System.IO.FileNotFoundException: Could not load file or assembly 'PresentationCore, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. File name: 'PresentationCore, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Span1& 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.SpecFlowProxies.BindingRegistryFactoryBeforeV310000.InvokeCreateTestRunner(TestRunnerManager testRunnerManager) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\SpecFlowProxies\BindingRegistryFactoryBeforeV310000.cs:line 13 at SpecFlowConnector.SpecFlowProxies.BindingRegistryFactoryVLatest.CreateTestRunner(IObjectContainer globalContainer, Assembly testAssembly) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\SpecFlowProxies\BindingRegistryFactoryVLatest.cs:line 62 at SpecFlowConnector.SpecFlowProxies.BindingRegistryFactoryVLatest.CreateTestRunner(Object globalContainer, Assembly testAssembly) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\SpecFlowProxies\BindingRegistryFactoryVLatest.cs:line 55 at SpecFlowConnector.SpecFlowProxies.BindingRegistryFactory.<>c__DisplayClass2_0.<GetBindingRegistry>b__2(Object container) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\SpecFlowProxies\BindingRegistryFactory.cs:line 26 at FunctionalExtensions.Map[TSource,TResult](TSource this, Func2 fn) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\FunctionalExtensions.cs:line 5 at SpecFlowConnector.SpecFlowProxies.BindingRegistryFactory.<>c__DisplayClass2_0.<GetBindingRegistry>b__0(Object dependencyProvider) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\SpecFlowProxies\BindingRegistryFactory.cs:line 17 at FunctionalExtensions.Map[TSource,TResult](TSource this, Func2 fn) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\FunctionalExtensions.cs:line 5 at SpecFlowConnector.SpecFlowProxies.BindingRegistryFactory.GetBindingRegistry(AssemblyLoadContext assemblyLoadContext, Assembly testAssembly, Option1 configFile) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\SpecFlowProxies\BindingRegistryFactory.cs:line 16 at SpecFlowConnector.Discovery.SpecFlowDiscoverer.Discover(IBindingRegistryFactory bindingRegistryFactory, AssemblyLoadContext assemblyLoadContext, Assembly testAssembly, Option1 configFile) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Discovery\SpecFlowDiscoverer.cs:line 24 at SpecFlowConnector.Discovery.DiscoveryCommand.<>c__DisplayClass6_0.<Execute>b__0(IBindingRegistryFactory bindingRegistryFactory) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Discovery\DiscoveryCommand.cs:line 27 at FunctionalExtensions.Map[TSource,TResult](TSource this, Func2 fn) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\FunctionalExtensions.cs:line 5 at SpecFlowConnector.Discovery.DiscoveryCommand.Execute(AssemblyLoadContext assemblyLoadContext) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Discovery\DiscoveryCommand.cs:line 25 at SpecFlowConnector.ReflectionExecutor.<>c__DisplayClass3_0.<Execute>b__6(DiscoveryCommand cmd) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\ReflectionExecutor.cs:line 82 at FunctionalExtensions.Map[TSource,TResult](TSource this, Func2 fn) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\FunctionalExtensions.cs:line 5 at SpecFlowConnector.ReflectionExecutor.<>c__DisplayClass3_1.<Execute>b__2() in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\ReflectionExecutor.cs:line 80 at EitherAdapters.Try[T](Func`1 act) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\Either\EitherAdapters.cs:line 40 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

No particular STR. Just updated project with latest SpecFlow and target switched to .net6.0-windows. The issue is in that PresentationCore v6.0.0.0 can not be loaded. <UseWPF>true</UseWPF> is added to csproj.

Link to Repository Project

No response

SerhiiPolehenko avatar May 02 '24 08:05 SerhiiPolehenko

I was struggling with this problem more than one year. I will write the steps I took, and what apparently solve the problem

  • Delete extension and reinstall - fail
  • Put appsettings.json straight in the extension folder - fail
  • Configure specflow.json with some parameters - plausible
{
  "$schema": "https://specflow.org/specflow-config.json",
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning"
    }
  },
  "specflow": {
    "stepAssemblies": [
      { "assembly": "<YOUR_PROJECT_NAME>/<STEP_DEFINITION_FOLDER>" }
    ],
    "bindingCulture": {
      "language": "en"
    },
    "unitTestProvider": {
      "name": "xUnit"
    }

  }
}
  • Set absolute path for appsettings.json in dependency injection - plausible
[Binding]
public static class TestDependencies
{
    private class FunctionalTestsCredentials
    {
        public string TestActive { get; set; }
    }
    [GlobalDependencies]
    public static void RegisterServices(ContainerBuilder builder)
    {
        var services = new ServiceCollection();

        var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        var configBuilder = new ConfigurationBuilder()
            .SetBasePath(basePath)
            .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
            .AddJsonFile("local.appsettings.json", optional: true, reloadOnChange: true);

At the end, it turns to recognize the steps again. I really hope it can help some of you guys struggling with this bug.

eduardomottoni avatar May 29 '24 09:05 eduardomottoni

I got same problem, but after I updated the project to dotnet 8.

I updated Visual Studio to version 17.10.0 and specflow extension: image

After I build the project, got this error in output:

Info: CheckProjectSettings: Project settings updated: .NETCoreApp,Version=v6.0,SpecFlow:3.9.74 Warning: AndDiscoveryProviderSucceed: Error during binding discovery. . . . Message: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at System.ModuleHandle.ResolveMethod(QCallModule module, Int32 methodToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount) at System.ModuleHandle.ResolveMethodHandleInternal(RuntimeModule module, Int32 methodToken, ReadOnlySpan1 typeInstantiationContext, ReadOnlySpan1 methodInstantiationContext) at System.ModuleHandle.ResolveMethodHandle(Int32 methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.RuntimeType.GetMethodBase(RuntimeModule scope, Int32 typeMetadataToken) at System.Reflection.RuntimeCustomAttributeData..ctor(RuntimeModule scope, MetadataToken caCtorToken, ConstArray& blob) at System.Reflection.RuntimeCustomAttributeData.GetCustomAttributes(RuntimeModule module, Int32 tkTarget) at SpecFlowConnector.ReflectionExecutor.Execute(DiscoveryOptions options, Func3 testAssemblyFactory, ILogger _log, IAnalyticsContainer analytics) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\ReflectionExecutor.cs:line 15 at SpecFlowConnector.Runner.ExecuteDiscovery(DiscoveryOptions options, Func3 testAssemblyFactory) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 50 at SpecFlowConnector.Runner.<>c__DisplayClass4_0.<Run>b__0(ConnectorOptions options) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 30 at FunctionalExtensions.Map[TSource,TResult](TSource this, Func2 fn) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\FunctionalExtensions.cs:line 5 at SpecFlowConnector.Runner.Run(String[] args, Func3 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.

So, it try to find 'System.Runtime, Version=8.0.0.0' after I updated project to use it.... but the latest version of it is:

https://www.nuget.org/packages/System.Runtime/

image

I did a test and rollback the project to .NET 6.0 and it work again.....

I hope specflow developer fix this soon for us use it with .NET 8

ronaldoperes avatar May 29 '24 11:05 ronaldoperes

Please fix this!

phenixita avatar May 29 '24 13:05 phenixita

I found a root cause of an issue, that should be fixed by SpecFlow plugin owner. The problem is in that, here: C:\Users\MyUserName\AppData\Local\Microsoft\VisualStudio\17.0_c987e58d\Extensions\SomeHash\Connectors\specflow-vs.runtimeconfig.json there is a missing runtime option, that is why necessary libs was missing in dependencies.

Here is a fixed file content which solves a problem !!!AND SHOULD BE FIXED BY SPECFLOW!!!

{ "runtimeOptions": { "tfm": "net6.0", "frameworks": [ { "name": "Microsoft.NETCore.App", "version": "6.0.0" }, { "name": "Microsoft.WindowsDesktop.App", "version": "6.0.0" } ], "configProperties": { "System.Reflection.Metadata.MetadataUpdater.IsSupported": false } } }

SerhiiPolehenko avatar May 29 '24 13:05 SerhiiPolehenko

Probably your versions can vary

SerhiiPolehenko avatar May 29 '24 13:05 SerhiiPolehenko

I found a root cause of an issue, that should be fixed by SpecFlow plugin owner. The problem is in that, here: C:\Users\MyUserName\AppData\Local\Microsoft\VisualStudio\17.0_c987e58d\Extensions\SomeHash\Connectors\specflow-vs.runtimeconfig.json there is a missing runtime option, that is why necessary libs was missing in dependencies.

Here is a fixed file content which solves a problem !!!AND SHOULD BE FIXED BY SPECFLOW!!!

{ "runtimeOptions": { "tfm": "net6.0", "frameworks": [ { "name": "Microsoft.NETCore.App", "version": "6.0.0" }, { "name": "Microsoft.WindowsDesktop.App", "version": "6.0.0" } ], "configProperties": { "System.Reflection.Metadata.MetadataUpdater.IsSupported": false } } }

I tried something and update this file - "specflow-vs.runtimeconfig.json" to:

{ "runtimeOptions": { "tfm": "net8.0", "framework": { "name": "Microsoft.NETCore.App", "version": "8.0.0" }, "configProperties": { "System.Reflection.Metadata.MetadataUpdater.IsSupported": false } } }

I rebuild the specflow project and looks like it is working, doing more tests to confirm.

But anyway, specflow owner need to fix that.

ronaldoperes avatar May 29 '24 17:05 ronaldoperes

Getting the same. Tried the fixes above and would answer.

Info: OnActivityStarted: Starting Visual Studio Extension... Info: CreateProjectScope: Initializing project: End2EndTests Info: OnSettingsInitialized: Project settings initialized: .NETCoreApp,Version=v8.0,SpecFlow:3.9.74 Warning: AndDiscoveryProviderSucceed: Error during binding discovery. Command executed: D:\Dropbox\source\Malue-Ltd\malue-poc\src\End2EndTests\bin\Debug\net8.0> C:\Program Files\dotnet\dotnet.exe exec c:\users\jim\appdata\local\microsoft\visualstudio\17.0_8fdfae02\extensions\bhrv5ykv.dty\Connectors\Generic-net7.0\specflow-vs.dll discovery D:\Dropbox\source\Malue-Ltd\malue-poc\src\End2EndTests\bin\Debug\net8.0\End2EndTests.dll "" Exit code: Message: You must install or update .NET to run this application.

App: c:\users\jim\appdata\local\microsoft\visualstudio\17.0_8fdfae02\extensions\bhrv5ykv.dty\Connectors\Generic-net7.0\specflow-vs.dll Architecture: x64 Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64) .NET location: C:\Program Files\dotnet\

The following frameworks were found: 6.0.30 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 6.0.31 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 8.0.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Learn more: https://aka.ms/dotnet/app-launch-failed

To install missing framework, download: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=win-x64&os=win10 Cannot deserialize: 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. Warning: AndDiscoveryProviderSucceed: Error during binding discovery. Command executed: D:\Dropbox\source\Malue-Ltd\malue-poc\src\End2EndTests\bin\Debug\net8.0> C:\Program Files\dotnet\dotnet.exe exec c:\users\jim\appdata\local\microsoft\visualstudio\17.0_8fdfae02\extensions\bhrv5ykv.dty\Connectors\Generic-net7.0\specflow-vs.dll discovery D:\Dropbox\source\Malue-Ltd\malue-poc\src\End2EndTests\bin\Debug\net8.0\End2EndTests.dll "" Exit code: Message: You must install or update .NET to run this application.

App: c:\users\jim\appdata\local\microsoft\visualstudio\17.0_8fdfae02\extensions\bhrv5ykv.dty\Connectors\Generic-net7.0\specflow-vs.dll Architecture: x64 Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64) .NET location: C:\Program Files\dotnet\

The following frameworks were found: 6.0.30 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 6.0.31 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 8.0.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Learn more: https://aka.ms/dotnet/app-launch-failed

To install missing framework, download: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=win-x64&os=win10 Cannot deserialize: 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.

jimdeane avatar Jun 08 '24 09:06 jimdeane

Installing the extension from the releases and not from the marketplace fixed the issue for me. I also upgraded my project to .net8. https://github.com/SpecFlowOSS/SpecFlow.VS/releases/tag/v2022.1.93-net8 I installed it over the marketplace extension. First close all your Visual Studio instances.

LockTar avatar Jun 10 '24 12:06 LockTar

Installing the extension from the releases and not from the marketplace fixed the issue for me. I also upgraded my project to .net8. https://github.com/SpecFlowOSS/SpecFlow.VS/releases/tag/v2022.1.93-net8 I installed it over the marketplace extension. First close all your Visual Studio instances.

Nice, thanks for sharing!

ronaldoperes avatar Jun 12 '24 13:06 ronaldoperes

I recently came across this same error and I was going to share the same link as @LockTar. I wouldn't expect any future bug fixes or development on SpecFlow going forward, so I am looking to move my existing codebases that use SpecFlow over to Reqnroll.

PandadoxZ avatar Jun 17 '24 11:06 PandadoxZ

I migrated everything last Friday to Reqnroll. No problems at all.

LockTar avatar Jun 17 '24 11:06 LockTar

Installing the extension from the releases and not from the marketplace fixed the issue for me. I also upgraded my project to .net8. https://github.com/SpecFlowOSS/SpecFlow.VS/releases/tag/v2022.1.93-net8 I installed it over the marketplace extension. First close all your Visual Studio instances.

Yes! That really works! Thank you!

renatolombardo avatar Jul 11 '24 15:07 renatolombardo

Confirming the github release version worked for me as well

DrEsteban avatar Jul 25 '24 22:07 DrEsteban