简体   繁体   English

在ASP.NET MVC核心应用程序中更新引用的.NET 4.5.2项目时出现编译错误

[英]Compilation errors when updating a referenced .net 4.5.2 project in asp.net mvc core app

I currently have a regular 4.5.2 project, which has a class (let's say MyClass with a method) 我目前有一个常规的4.5.2项目,该项目具有一个类(比方说MyClass和一个方法)

public static void Do(string name, List<Operation> operations)
        {
            //do some stuff
        }

In my ASP.NET Core MVC app I have 在我的ASP.NET Core MVC应用程序中

MyClass.Do(User.Identity.Name, operations);

When I try and build this project, I get an error CS1501, No overload for Do takes 2 arguments. 尝试构建该项目时,出现错误CS1501,Do的无重载需要2个参数。

I recently updated Do to add the string name argument. 我最近更新了Do以添加字符串名称参数。 In fact, any changes I make to the .net 4.5.2 assembly are reflected in Visual Studio, are built into the assembly, but when I build (or clean/build, or delete the bin folder), these changes cause compilation errors. 实际上,我对.net 4.5.2程序集所做的任何更改都将反映在Visual Studio中,并已内置到程序集中,但是当我进行构建(或清理/构建或删除bin文件夹)时,这些更改会导致编译错误。

I've also tried removing the project as a reference from the asp.net core project. 我还尝试从asp.net核心项目中删除该项目作为参考。

What could be causing asp.net mvc to be stuck on the old definition? 是什么导致asp.net mvc停留在旧定义上?

UPDATE After some closing/reopening, I've noticed that the paths of my dlls (my referenced projects) are incorrect project.fragment.lock.json. 更新一些关闭/重新打开后,我注意到我的dll(我引用的项目)的路径是不正确的project.fragment.lock.json。

I don't know what this file is, but it's pointing to bin/Debug/my.dll instead of bin/x64/Debug/my.dll. 我不知道这个文件是什么,但是它指向的是bin / Debug / my.dll,而不是bin / x64 / Debug / my.dll。

If I try to change it manually, it's updated during the next build to the incorrect values. 如果我尝试手动更改它,它将在下一次构建中更新为不正确的值。

I've had some odd issues in ASP.NET Core as well. 我在ASP.NET Core中也遇到了一些奇怪的问题。 In some cases, the build appears to run without generating any errors, but it never actually builds the project. 在某些情况下,该构建似乎在运行时没有产生任何错误,但从未真正构建过该项目。 So you may be actually running the old code even though it acts like you rebuilt it. 因此,即使它的行为就像您在重建它一样,您实际上也可能在运行旧代码。

When I have had this problem, it has usually been traced down to a problem with references in the project.json. 当我遇到这个问题时,通常可以追溯到project.json中有引用的问题。 Look to see if there are any "squigglies" in there. 查看其中是否有任何“弯曲”。 Sometimes they wouldn't show up for me until I closed Visual Studio and re-opened the project. 有时,直到我关闭Visual Studio并重新打开该项目,它们才对我显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM