技术讲解。Specflow报错:无法加载程序集文件或程序集。

7
我之前看到过这个问题,但我认为它没有得到解决。我的设置如下: VS 2015 SpecFlow版本为1.9.0 (我根据其他问题降级到此版本,但并没有帮助)
当我尝试构建项目时,会出现以下错误: #error Generation error: Could not load file or assembly 'TechTalk.SpecFlow, Version=1.9.0.77, Culture=neutral, PublicKeyToken=0778194805d6db41' or one of its dependencies. The system cannot find the file specified.

DLL文件在哪里?通常情况下,通过“添加现有项”将DLL添加到项目中。然后将DLL放入项目文件夹中。当您编译时,编译器会将DLL移动到bin/debug或bin/release文件夹中。错误消息指示DLL不在发布或调试文件夹中。请检查您的项目是否正在构建调试或发布版本。然后检查DLL是否在文件夹中。通常人们只是将DLL移动到调试或发布文件夹中,然后运行清除所有操作,这会从调试/发布文件夹中删除DLL并导致此错误。 - jdweng
在 bin 文件夹的 release 或 debug 文件夹中没有 dll。过去,这里包含了所有的 dll,所以不确定为什么现在是空的。 - Ade Bakre
1
我怀疑有人只是把dll文件放到文件夹中,而没有将其添加到引用列表中。 - jdweng
2个回答

4
请检查您的package.config文件,看看是否有TechTalk.SpecFlow的条目。如果有,请从该文件中删除该条目...以及删除与该dll相关的所有程序集。重新从NuGet安装特定版本并重新编译您的项目。
根据您的评论,它仍然针对新版本newVersion="2.1.0.0"而不是新版本Version=1.9.0.77。请将您的app.config更改为以下内容:
<assemblyIdentity name="TechTalk.SpecFlow" publicKeyToken="0778194805d6db41" culture="neutral" /> 
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="1.9.0.77" /> 

谢谢@Rahul,但我已经尝试过这个方法,仍然无法解决问题。以下是我的app.config文件中生成的内容:<assemblyIdentity name="TechTalk.SpecFlow" publicKeyToken="0778194805d6db41" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="ImpromptuInterface" publicKeyToken="0b1781c923b2975b" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-6.2.2.0" newVersion="6.2.2.0" /> </dependentAssembly> </assemblyBinding> - Ade Bakre
我又删掉了所有内容,然后替换了app.config的那一部分,现在看起来问题已经解决了。 - Ade Bakre
如果是,那么删除。 如果不是? - serge

0
只需从VS菜单的“工具”>>“扩展和更新”中卸载specflow并重新安装即可。在这样做时,它会要求您重新启动VS,并且一切都设置好了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接