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 priyankakote opened this issue 3 years ago • 22 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

No response

Issue Description

Error System.Xml.XmlException: Invalid byte encoding. at System.Runtime.Serialization.Json.JsonEncodingStreamWrapper.ReadEncoding(Byte b1, Byte b2) at System.Runtime.Serialization.Json.JsonEncodingStreamWrapper.ProcessBuffer(Byte[] buffer, Int32 offset, Int32 count, Encoding encoding) at System.Runtime.Serialization.Json.XmlJsonReader.SetInput(Byte[] buffer, Int32 offset, Int32 count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose) at System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader(Byte[] buffer, XmlDictionaryReaderQuotas quotas) at ReportPortal.Shared.Configuration.Providers.JsonFileConfigurationProvider.GetFlattenProperties(String json) at ReportPortal.Shared.Configuration.Providers.JsonFileConfigurationProvider.Load() at ReportPortal.Shared.Configuration.ConfigurationBuilder.Build() at ReportPortal.SpecFlowPlugin.Plugin.Initialize(RuntimePluginEvents runtimePluginEvents, RuntimePluginParameters runtimePluginParameters, UnitTestProviderConfiguration unitTestProviderConfiguration) at TechTalk.SpecFlow.Infrastructure.ContainerBuilder.LoadPlugin(String pluginPath, IRuntimePluginLoader pluginLoader, RuntimePluginEvents runtimePluginEvents, UnitTestProviderConfiguration unitTestProviderConfigration, ITraceListener traceListener, Boolean traceMissingPluginAttribute) at TechTalk.SpecFlow.Infrastructure.ContainerBuilder.LoadPlugins(IRuntimeConfigurationProvider configurationProvider, ObjectContainer container, RuntimePluginEvents runtimePluginEvents, SpecFlowConfiguration specFlowConfiguration, UnitTestProviderConfiguration unitTestProviderConfigration, Assembly testAssembly) at TechTalk.SpecFlow.Infrastructure.ContainerBuilder.CreateGlobalContainer(Assembly testAssembly, IRuntimeConfigurationProvider configurationProvider) at SpecFlowConnector.SpecFlowProxies.BindingRegistryFactoryVLatest.CreateObjectContainer(Assembly testAssembly, ContainerBuilder containerBuilder, IRuntimeConfigurationProvider configurationProvider, IDefaultDependencyProvider dependencyProvider) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\SpecFlowProxies\BindingRegistryFactoryVLatest.cs:line 41 at SpecFlowConnector.SpecFlowProxies.BindingRegistryFactoryVLatest.CreateObjectContainer(Assembly testAssembly, Object containerBuilder, IRuntimeConfigurationProvider configurationProvider, Object dependencyProvider) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\SpecFlowProxies\BindingRegistryFactoryVLatest.cs:line 36 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__5(DiscoveryCommand cmd) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\ReflectionExecutor.cs:line 71 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__1() in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\ReflectionExecutor.cs:line 69 at EitherAdapters.Try[T](Func1 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.

Steps to Reproduce

Created feature file Added step definition When trying to navigate to step definition Unable to navigate to step definition

Link to Repository Project

No response

priyankakote avatar Jul 12 '22 08:07 priyankakote

Hi @priyankakote did you get this issue resolved ? i am facing same error.

sitharasreedharan avatar Jul 26 '22 04:07 sitharasreedharan

Following. When I first clone a repo all things work fine and in a day or so, I get the error. I am using VS2022

ashrithpai avatar Jul 28 '22 20:07 ashrithpai

Try in csproj change specFlow version 3.9.8. It helped me

PackageReference Include="SpecFlow" Version="3.9.8" PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.8" PackageReference Include="SpecFlow.xUnit" Version="3.9.8"

Tumoyan avatar Aug 05 '22 06:08 Tumoyan

Thanks for the suggestion, but it didn't work for me. Please let me know if there are any other suggestions.

ashrithpai avatar Aug 09 '22 13:08 ashrithpai

Thanks for the suggestion, but it didn't work for me. Please let me know if there are any other suggestions.

Hi, try update specFlow version in "Manage NuGet package" in project. Go to -> Installed and first update SpecFLow.xUnit last version 3.9.74 second -> SpecFlow.Tools.MsBuild.Generation third -> SpecFlow

Tumoyan avatar Aug 10 '22 07:08 Tumoyan

I use MSTest and the only Nuget I had to get was SpecFlow.MSTest which will have all other packages in it. What's strange is, when I first work on a cloned repo, everything works just fine, but in few days, it all stops. I'm wondering if some state files go corrupt.

ashrithpai avatar Aug 10 '22 12:08 ashrithpai

I had the same issue. Delete from .csproj element UserSecretsId

trapet avatar Aug 11 '22 05:08 trapet

Hi. I do not have that element in my .csproj file.

ashrithpai avatar Aug 11 '22 12:08 ashrithpai

What .net framework are you working with? I'm using .net 6

ashrithpai avatar Aug 11 '22 14:08 ashrithpai

What .net framework are you working with? I'm using .net 6

.Net 6

trapet avatar Aug 12 '22 05:08 trapet

HI, facing similar issue. Any updates further how to resolve issue?

MrRD-TT avatar Sep 11 '22 17:09 MrRD-TT

I just started getting this error after updating my nugget packages. I noticed the following line in the log file: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=6.0.0.0 etc...'

So I manually added it via nuget package manager. After a re-build the problem seems to have gone away.

aetaylor avatar Sep 26 '22 15:09 aetaylor

I don't see the issue anymore. I did not do anything specific at all. My regular closing of all applications and machine somehow seemed to fix it.

ashrithpai avatar Sep 26 '22 15:09 ashrithpai

I am also facing the same issue

lakhmanan avatar Nov 23 '22 12:11 lakhmanan

I tried all these steps and still facing the same issue with VS 2022.

sashidhar-joganna avatar Dec 05 '22 18:12 sashidhar-joganna

I appear to be experiencing this with a new dotnet 6 project that references more than one other specflow project in the same solution with the following specflow.json config

{
  "bindingCulture": {
    "language": "en-us"
  },
  "language": {
    "feature": "en-us"
  },
  "stepAssemblies": [
    { "assembly": "Project1" },
    { "assembly": "Project2 }
  ],
  "plugins": []
}

I am not sure if others in this thread have a similar setup? Taking project 2 away fixes the issue for me... however it doesn't help solve what I am trying to do...

jholsgrove avatar Jan 27 '23 16:01 jholsgrove

I appear to be experiencing this with a new dotnet 6 project that references more than one other specflow project in the same solution with the following specflow.json config

I think something got corrupted when I added a new dot6 project, blatting my repo and re cloning it solved the issue for me.

jholsgrove avatar Jan 29 '23 13:01 jholsgrove

.NET 8, Specflow addon 2022.1.91.26832, VS 2022, same happening

darakeon avatar Dec 01 '23 03:12 darakeon

.Net 8 same issue

  • SpecFlow 3.9.74
  • SpecFlow.Tools.MsBuild.Generation 3.9.74
  • SpecFlow.xUnit 3.9.74
  • Microsoft.NET.Test.Sdk 17.8.0
  • SpecFlow for Visual Studio 2022 Version - 2022.1.91.26832

From logs I found this, its looking in .net7.0 C:\Users\User\AppData\Local\Microsoft\VisualStudio\17.0_0fca06b1\Extensions\ybsh431w.hd5\Connectors\Generic-net7.0\specflow-vs.dll discovery \tests\Web.AcceptanceTests\bin\Debug\net8.0\Web.AcceptanceTests.dll ""

This was working untill I upgraded to .Net 8.

Info: OnActivityStarted: Starting Visual Studio Extension... Info: CreateProjectScope: Initializing project: Web.AcceptanceTests Info: StartRetryInitializeTimer: Project settings not available yet, retry in 5 seconds... Info: OnSettingsInitialized: Project settings initialized: .NETCoreApp,Version=v8.0,SpecFlow:3.9.74 Warning: AndDiscoveryProviderSucceed: Error during binding discovery. Command executed: \tests\Web.AcceptanceTests\bin\Debug\net8.0> C:\Program Files\dotnet\dotnet.exe exec C:\Users\User\AppData\Local\Microsoft\VisualStudio\17.0_0fca06b1\Extensions\ybsh431w.hd5\Connectors\Generic-net7.0\specflow-vs.dll discovery \tests\Web.AcceptanceTests\bin\Debug\net8.0\Web.AcceptanceTests.dll "" Exit code: 4 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, Func2 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.`

mohamed-firoz avatar Feb 02 '24 09:02 mohamed-firoz

Visual Studio 2022 ver. 17.9.2; all projects in the solution targeted to .NET8 SpecFlow extension ver. 2022.1.91.26832 We have neither specflow.json nor SpecFlow section in the app.config Microsoft.NET.Test.Sdk 17.9.0 SpecFlow 3.9.74 SpecFlow.NUnit 3.9.74

Steps To Reproduce: Create Specflow project Add Feature Add Scenario Implement Step Try to navigate from feature file to stepdefinition using F12 key.

Warning: AndDiscoveryProviderSucceed: Error during binding discovery. Command executed: C:\Users\a\b\c\d\e\TestProject1\bin\Debug\net8.0> C:\Program Files\dotnet\dotnet.exe exec c:\users\a\appdata\local\microsoft\visualstudio\17.0_a3520539\extensions\vr0vvgbp.2av\Connectors\Generic-net7.0\specflow-vs.dll discovery C:\Users\a\b\c\d\e\TestProject1\bin\Debug\net8.0\TestProject1.dll "" Exit code: 4 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.

OleksandrKovalenko2 avatar Mar 05 '24 08:03 OleksandrKovalenko2

Okay, the issue is gone for me. This was helpful https://github.com/SpecFlowOSS/SpecFlow.VS/issues/123#issuecomment-1866041085

OleksandrKovalenko2 avatar Mar 05 '24 08:03 OleksandrKovalenko2

Thank You @OleksandrKovalenko2 for posting this! The issue is gone for me too. This was helpful #123 (comment)

harshakotian avatar Aug 21 '24 08:08 harshakotian