现在,我知道这里已经有很多这样的问题,但是翻阅它们之后,我还没有找到能够解决我的特定问题的问题.
Now I know there are a number of these questions already up here, but after flipping through them, I haven't found one that solves my specific problem.
我有一个ASP.NET MVC 4.5项目.我使用了NuGet并将Newtonsoft.Json添加到了项目中.一旦我在代码中使用了它(以驼峰方式进行一些序列化),我的项目就不再正确构建,并出现以下错误:
I have an ASP.NET MVC 4.5 project. I used NuGet and added Newtonsoft.Json to the project. As soon as I used it in my code (to do some serialization in camel-case), my project no longer builds correctly with the following error:
"C:.. \ Microsoft Visual Studio 12.0 \ Blend \ Newtonsoft.Json.dll"和"C:.. \ Visual Studio 2013 \ Projects \ myProject"中都存在类型"Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver" \ packages \ Newtonsoft.Json.6.0.1 \ lib \ net45 \ Newtonsoft.Json.dll'
The type 'Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver' exists in both 'C:..\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll" and 'C:..\Visual Studio 2013\Projects\myProject\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll'
不幸的是,每个文件都是相同的文件,直到公用密钥,所以我不能使用Web.config中的依赖程序集引用(如在其他地方建议的那样).我宁愿使用通过NuGet检索的dll,以便更轻松地升级到新版本.
Unfortunately, it's the same file down to the public key on each so I can't use the dependency assembly reference in Web.config (as suggested elsewhere). I would prefer to use the dll retrieved via NuGet so upgrades to new versions are easier.
此外,Temporary Internet文件夹中都没有该文件夹,因此我不能简单地删除它并使它工作.
Additionally, neither one is in the Temporary Internet folder, so I can't simply delete that and have it work either.
我该如何指定要使用的特定程序集文件,以便正确构建项目?谢谢!
How can I go about specifying the specific assembly file I want to use so I can build the project correctly? Thanks!
推荐答案Xaniff,手动打开项目文件并查找Newtonsoft.您很有可能会找到一个项目组,该项目组所引用的版本与您的nuget软件包不匹配.
Xaniff, open your project file manually and look for Newtonsoft. You will more than likely find an item group with a reference to a version that is not matching your nuget package.. In my case I found this:
<ItemGroup> <Reference Include="Newtonsoft.Json"> <HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> </ItemGroup>我删除了该项目组,关闭了项目文件,重新加载,一切都很好.
I deleted this item group, closed the project file, reloaded, and all was well.
更多推荐
类型< type>同时存在于"A"和"B"中
发布评论