简体   繁体   English

System.MissingMethodException:找不到方法?

[英]System.MissingMethodException: Method not found?

Previous working asp.net webforms app now throws this error:以前工作的 asp.net webforms 应用程序现在抛出此错误:

System.MissingMethodException: Method not found System.MissingMethodException:找不到方法

The DoThis method is on the same class and it should work. DoThis方法在同一个类上,它应该可以工作。

I have a generic handler as such:我有一个这样的通用处理程序:

public class MyHandler: IHttpHandler
{
    public void Processrequest(HttpContext context)
    {
      // throws error now System.MissingMethodException: 
      // Method not found.
      this.DoThis(); 
    }

    public void DoThis(){ ... }
}

This is a problem which can occur when there is an old version of a DLL still lingering somewhere around.当旧版本的 DLL 仍然存在于某处时,可能会出现此问题。 Make sure that the latest assemblies are deployed and no duplicated older assemblies are hiding in certain folders.确保部署了最新的程序集,并且某些文件夹中没有隐藏重复的旧程序集。 Your best bet would be to delete every built item and rebuild/redeploy the entire solution.您最好的选择是删除每个已构建的项目并重建/重新部署整个解决方案。

⚠️ Wrong Nuget Package Version ⚠️ ⚠️ Nuget 包版本错误⚠️

I had a unit test project which was pulling in our companies internal EF Nuget data access package and that code pulled in an external package whose version was way behind the current version.我有一个单元测试项目,它正在拉入我们公司内部的 EF Nuget 数据访问包,并且该代码拉入了一个版本远远落后于当前版本的外部包。

The issue was that the Nuget settings for the top level package was set to the least version ;问题是顶级包的 Nuget 设置被设置为least version and the lower level /older version won, and that was used during the operations....并且较低级别/旧版本获胜,并且在操作期间使用....

Hence it silently got the wrong version for a common assembly used by both the package and the app.因此,它默默地为包和应用程序使用的通用程序集获取了错误的版本


💡 Solution 💡 💡解决方案💡

By Setting/updating the package in Nuget to use and [get] the latest , fixed the issue.通过在 Nuget 中设置/更新包以使用和[get] the latest ,解决了这个问题。

I resolved this issue by installing the correct .NET Framework version on the server.我通过在服务器上安装正确的 .NET Framework 版本解决了这个问题。 The website was running under version 4.0 and the assembly it was calling to was compiled for 4.5.该网站在 4.0 版本下运行,它调用的程序集是为 4.5 编译的。 After installation of .NET Framework 4.5 and upgrading the website to 4.5, all works fine.安装 .NET Framework 4.5 并将网站升级到 4.5 后,一切正常。

Restarting Visual Studio actually fixed it for me.重新启动 Visual Studio 实际上为我修复了它。 I'm thinking it was caused by old assembly files still in use, and performing a "Clean Build" or restarting VS should fix it.我认为这是由仍在使用的旧程序集文件引起的,执行“干净构建”或重新启动 VS 应该可以修复它。

Check your References!检查您的参考资料!

Be sure that you are consistently pointing to the same 3rd party libraries (don't just trust versions, look at the path) across your solutions projects.确保您在您的解决方案项目中始终指向相同的第 3 方库(不要只信任版本,查看路径)。

For example, If you use iTextSharp v.1.00.101 in one project and you NuGet or reference iTextSharp v1.00.102 somewhere else you will get these types of runtime errors that somehow trickle up into your code.例如,如果您在一个项目中使用 iTextSharp v.1.00.101,并且在其他地方使用 NuGet 或引用 iTextSharp v1.00.102,您将获得这些类型的运行时错误,这些错误会以某种方式渗入您的代码。

I changed my reference to iTextSharp in all 3 projects to point to the same DLL and everything worked.我在所有 3 个项目中更改了对 iTextSharp 的引用,以指向同一个 DLL,一切正常。

I had this happen to me with a file referenced in the same assembly, not a separate dll.我在同一个程序集中引用了一个文件,而不是一个单独的 dll。 Once I excluded the file from the project and then included it again, everything worked fine.一旦我从项目中排除了该文件,然后再次包含它,一切正常。

I just ran into this on a .NET MVC project.我刚刚在 .NET MVC 项目中遇到了这个问题。 The root cause was conflicting versions of NuGet packages.根本原因是 NuGet 包的版本冲突。 I had a solution with several projects.我有几个项目的解决方案。 Each of the projects had some NuGet packages.每个项目都有一些 NuGet 包。 In one project I had a version of the Enterprise Library Semantic Logging package, and in two other projects (that reference the first) I had older versions of the same package.在一个项目中,我有一个版本的 Enterprise Library Semantic Logging 包,而在另外两个项目(引用第一个)中,我有同一个包的旧版本。 It all compiles without error, but it gave a mysterious "Method not found" error when I tried to use the package.它全部编译没有错误,但是当我尝试使用该包时,它给出了一个神秘的“找不到方法”错误。

The fix was to remove the old NuGet packages from the two projects, so that it was only included in the one project that actually needed it.解决方法是从两个项目中删除旧的 NuGet 包,使其仅包含在实际需要它的一个项目中。 (Also I did a clean rebuild of the whole solution.) (我还对整个解决方案进行了干净的重建。)

If developing with your own NuGet server, make sure the assembly versions are all the same:如果使用您自己的 NuGet 服务器进行开发,请确保程序集版本都相同:

[assembly: AssemblyVersion("0.2.6")]
[assembly: AssemblyFileVersion("0.2.6")]
[assembly: AssemblyInformationalVersion("0.2.6")]

也..尝试“清理”您的项目或解决方案并再次重建!

Have you tried turning if off and on again?您是否尝试过关闭并再次打开? Jokes aside, restarting my computer was what actually did the trick for me and isn't mentioned in any of the other answers.撇开笑话不谈,重新启动我的计算机实际上对我有用,并且在任何其他答案中都没有提到。

I've just had this issue and it turned out that it was because I was referencing a previous version of the DLL from my UI project.我刚刚遇到了这个问题,结果证明这是因为我从我的 UI 项目中引用了以前版本的 DLL。 Therefore, when compiling it was happy.因此,编译时很高兴。 But when running it was using the previous version of the DLL.但是在运行它时使用的是以前版本的 DLL。

Check references on all other projects before assuming you need to rebuild/clean/redeploy your solutions.在假设您需要重建/清理/重新部署您的解决方案之前,请检查所有其他项目的参考资料。

It's also possible the problem is with a parameter or return type of the method that's reported missing, and the "missing" method per se is fine.问题也可能在于报告丢失的方法的参数或返回类型,并且“丢失”方法本身很好。

That's what was happening in my case, and the misleading message made it take much longer to figure out the issue.这就是在我的案例中发生的事情,误导性的信息使得解决问题需要更长的时间。 It turns out the assembly for a parameter's type had an older version in the GAC, but the older version actually had a higher version number due to a change in version numbering schemes used.事实证明,参数类型的程序集在 GAC 中有一个旧版本,但由于使用的版本编号方案发生了变化,旧版本实际上具有更高的版本号。 Removing that older/higher version from the GAC fixed the problem.从 GAC 中删除旧/更高版本解决了该问题。

In my case it was a copy/paste problem.就我而言,这是一个复制/粘贴问题。 I somehow ended up with a PRIVATE constructor for my mapping profile:我不知何故为我的映射配置文件创建了一个 PRIVATE 构造函数:

using AutoMapper;

namespace Your.Namespace
{
    public class MappingProfile : Profile
    {
        MappingProfile()
        {
            CreateMap<Animal, AnimalDto>();
        }
    }
}

(take note of the missing "public" in front of the ctor) (注意ctor前面缺少的“public”)

which compiled perfectly fine, but when AutoMapper tries to instantiate the profile it can't (of course!) find the constructor!编译得非常好,但是当 AutoMapper 尝试实例化配置文件时,它(当然!)找不到构造函数!

Using Costura.Fody 1.6 & 2.0:使用 Costura.Fody 1.6 和 2.0:
After wasting a bunch of time looking into this same kind of error with all other potential solutions not working, I found that an older version of the DLL I was embedding was in the same directory I was running my newly compiled .exe from.在浪费了很多时间来研究所有其他潜在解决方案都不起作用的同类错误之后,我发现我嵌入的旧版本的 DLL 位于我运行新编译的 .exe 的同一目录中。 Apparently it looks for a local file in the same directory first, then looks inward to its embedded library.显然它首先在同一目录中查找本地文件,然后向内查找其嵌入式库。 Deleting the old DLL worked.删除旧的 DLL 有效。

To be clear, it wasn't that my reference was pointing to an old DLL, it was that a copy of an old DLL was in the directory I was testing my application from on a separate system from that which it was compiled on.需要明确的是,我的引用并不是指向旧 DLL,而是旧 DLL 的副本位于我正在测试我的应用程序的目录中,该目录与编译应用程序的系统不同。

I had a similar scenario where I was getting this same exception being thrown.我有一个类似的场景,我得到了同样的异常被抛出。 I had two projects in my web application solution, named, for sake of example, DAL and DAL.CustSpec.我的 Web 应用程序解决方案中有两个项目,例如,命名为 DAL 和 DAL.CustSpec。 The DAL project had a method named Method1, but DAL.CustSpec did not. DAL 项目有一个名为 Method1 的方法,但 DAL.CustSpec 没有。 My main project had a reference to the DAL project and also a reference to another project named AnotherProj.我的主项目引用了 DAL 项目,也引用了另一个名为 AnotherProj 的项目。 My main project made a call to Method1.我的主要项目调用了 Method1。 The AnotherProj project had a reference to the DAL.CustSpec project, and not the DAL project. AnotherProj 项目引用了 DAL.CustSpec 项目,而不是 DAL 项目。 The Build configuration had both the DAL and DAL.CustSpec projects configured to be built. Build 配置将 DAL 和 DAL.CustSpec 项目都配置为要构建。 After everything was built, my web application project had the AnotherProj and DAL assemblies in its Bin folder.构建完所有内容后,我的 Web 应用程序项目的 Bin 文件夹中有 AnotherProj 和 DAL 程序集。 However, when I ran the website, the Temporary ASP.NET folder for the website had the DAL.CustSpec assembly in its files and not the DAL assembly, for some reason.但是,当我运行该网站时,出于某种原因,该网站的 Temporary ASP.NET 文件夹在其文件中包含 DAL.CustSpec 程序集,而不是 DAL 程序集。 Of course, when I ran the part that called Method1, I received a "Method not found" error.当然,当我运行调用 Method1 的部分时,我收到了“未找到方法”错误。

What I had to do to fix this error was to change the reference in the AnotherProj project from DAL.CustSpec to just DAL, deleted all the files in the Temporary ASP.NET Files folder, and then reran the website.为了解决这个错误,我必须做的是将 AnotherProj 项目中的引用从 DAL.CustSpec 更改为 DAL,删除 Temporary ASP.NET Files 文件夹中的所有文件,然后重新运行网站。 After that, everything started working.在那之后,一切都开始工作了。 I also made sure that the DAL.CustSpec project was not being built by unchecking it in the Build Configuration.我还通过在构建配置中取消选中它来确保没有构建 DAL.CustSpec 项目。

I thought I would share this in case it helps someone else in the future.我想我会分享这个,以防它在未来帮助别人。

I came across the same situation in my ASP.NET website.我在我的 ASP.NET 网站上遇到了同样的情况。 I deleted the published files, restarted VS, cleaned and rebuild the project again.我删除了已发布的文件,重新启动了 VS,再次清理并重建了项目。 After the next publish, the error was gone...下一次发布后,错误消失了...

I solved this problem by making a shelveset with my changes and running TFS Power Tools 'scorch' in my workspace ( https://visualstudiogallery.msdn.microsoft.com/f017b10c-02b4-4d6d-9845-58a06545627f ).我通过使用我的更改制作一个搁置集并在我的工作区中运行 TFS Power Tools 'scorch' 解决了这个问题( https://visualstudiogallery.msdn.microsoft.com/f017b10c-02b4-4d6d-9845-58a06545627f )。 Then I unshelved the changes and recompiled the project.然后我取消了更改并重新编译了项目。 This way you will cleanup any 'hanging-parties' that may be around in your workspace and will startup with a fresh one.这样,您将清理工作区中可能存在的任何“悬挂派对”,并以新的方式启动。 This requires, of course, that you are using TFS.当然,这需要您使用 TFS。

In my case, my project was referencing Microsoft.Net.Compilers.2.10.0 .就我而言,我的项目引用了Microsoft.Net.Compilers.2.10.0 When I switched it to Microsoft.Net.Compilers.2.7.0 , the error went away.当我将它切换到Microsoft.Net.Compilers.2.7.0时,错误就消失了。 What a mysterious error with such a variety of causes.多么神秘的错误,原因多种多样。

在我的情况下,它是一个文件夹,其中包含我的 .csproj 文件中引用的那些同名的旧 DLL,尽管明确给出了路径,但它们以某种方式包含在内,因此相同 DLL 的多个版本存在冲突。

In case the problem is caused by an old version of the assembly in the GAC .如果问题是由GAC中的旧版本程序集引起的。
This can help: How to: Remove an Assembly from the Global Assembly Cache .这可以提供帮助: 如何:从全局程序集缓存中删除程序集

In my case, the MissingMethodException was for a method that was in the same file!就我而言, MissingMethodException 是针对同一文件中的方法的!

However, I had just added a NuGet package that uses .Net Standard2 to my 4.7.1-targeting project, which caused a version conflict for System.Net.Http (4.7.1: version 4.0.0.0, the NuGet package using .NET Standard 2 wants 4.2.0.0).但是,我刚刚在我的 4.7.1 目标项目中添加了一个使用 .Net Standard2 的 NuGet 包,这导致 System.Net.Http 的版本冲突(4.7.1:版本 4.0.0.0,使用 .NET 的 NuGet 包标准 2 需要 4.2.0.0)。 This seem to be known issues that should be better in 4.7.2 (see note 2) .这似乎是4.7.2 中应该更好的已知问题(见注 2)

I had used a binding redirect like this in all other my projects, because there were exceptions as soon as it tried to load the 4.2.0.0 which I didn't have:我在所有其他项目中都使用了这样的绑定重定向,因为一旦它尝试加载我没有的 4.2.0.0 就会出现异常:

  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>

Except in this one project, where it seems it tries to load System.Net.Http only while calling a local function that uses a System.Net.Http.HttpResponseMessage as it's parameter or return type (parameter during debugging, return type when I run the tests without the debugger, also a bit strange).除了在这个项目中,它似乎仅调用使用 System.Net.Http.HttpResponseMessage 作为参数或返回类型的本地函数时才尝试加载 System.Net.Http(调试期间的参数,运行时的返回类型没有调试器的测试,也有点奇怪)。 And instead of showing a message that it could not load the 4.2.0.0 version of System.Net.Http, it returns this exception.而不是显示无法加载 System.Net.Http 的 4.2.0.0 版本的消息,而是返回此异常。

This may have been mentioned already, but for me the problem was that the project was referencing 2 nuget packages, and each of those nuget packages referenced a different version of another nuget package.这可能已经提到过,但对我来说,问题是该项目引用了 2 个 nuget 包,并且每个 nuget 包都引用了另一个 nuget 包的不同版本。

So:所以:

Project -> Nuget A -> Nuget X 1.1项目 -> Nuget A -> Nuget X 1.1

Project -> Nuget B -> Nuget X 1.2项目 -> Nuget B -> Nuget X 1.2

Both versions of Nuget X had the same extension method that was being called from Project. Nuget X 的两个版本都具有从 Project 调用的相同扩展方法。

When I updated both Nuget A & B to versions that referenced the same version of Nuget X, the error went away.当我将 Nuget A 和 B 都更新到引用相同版本的 Nuget X 的版本时,错误消失了。

Possible case could be可能的情况可能是

Mismatched nuget assembles versions不匹配的 nuget 组装版本

Problem In Detail问题详解

We had more then one nuget packages being generated by a solution.我们有多个由解决方案生成的 nuget 包。

Class A in packageA 1.0 packageA 1.0 中的 A 类

Class B in packageB 1.0包 B 1.0 中的 B 类

A is referring B A指的是B

so when A and B both have update we have to update packageA and packageB, but issue was one of my team member did not update packageB所以当 A 和 B 都有更新时,我们必须更新 packageA 和 packageB,但问题是我的团队成员之一没有更新 packageB

now PackageA 1.1 still has dependency on PackageB 1.0 But PackageB don't have updated version of Class B现在 PackageA 1.1 仍然依赖于 PackageB 1.0 但是 PackageB 没有更新版本的 Class B

and hence it was not been able to find the method因此无法找到该方法

Solution解决方案

Move both packages to +1 Version in this case I moved在这种情况下,我移动了两个包到 +1 版本

PackageA 1.1 -> PackageA 1.2包 A 1.1 -> 包 A 1.2

PackageB 1.0 -> PackageB 1.1包 B 1.0 -> 包 B 1.1

but to make matters more symmetrical to can move both to same Version但为了使事情更加对称,可以将两者移至相同的版本

PackageA 1.1 -> PackageA 1.2包 A 1.1 -> 包 A 1.2

PackageB 1.0 -> PackageB 1.2包 B 1.0 -> 包 B 1.2

This happened to me using MVC4, and I decided after reading this thread to rename the object that was throwing the error.这发生在我使用 MVC4 时,我在阅读了这个线程后决定重命名引发错误的对象。

I did a clean and rebuild and noted that it was skipping two projects.我进行了清理和重建,并注意到它正在跳过两个项目。 When I rebuilt one of them, there was an error where I'd started a function and not finished it.当我重建其中一个时,出现了一个错误,我启动了一个函数但没有完成它。

So VS was referencing a model that I had rewritten without asking me if I wanted to do that.所以 VS 引用了一个我重写的模型,而没有问我是否想这样做。

Just in case it helps anyone, although it's an old issue, my problem was a bit odd.以防万一它可以帮助任何人,虽然这是一个老问题,但我的问题有点奇怪。

I had this error while using Jenkins.我在使用 Jenkins 时遇到了这个错误。

Eventually found out that the system date was manually set to a future date, which caused dll to be compiled with that future date.最终发现系统日期被手动设置为将来的日期,导致 dll 编译为该将来的日期。 When the date was set back to normal, MSBuild interpreted that the file was newer and didn't require recompile of the project.当日期恢复正常时,MSBuild 解释该文件较新并且不需要重新编译项目。

I ran into this issue, and what it was for me was one project was using a List which was in Example.Sensors namespace and and another type implemented the ISensorInfo interface.我遇到了这个问题,对我来说,一个项目使用的是 Example.Sensors 命名空间中的 List,而另一种类型实现了 ISensorInfo 接口。 Class Type1SensorInfo, but this class was one layer deeper in the namespace at Example.Sensors.Type1.类 Type1SensorInfo,但该类在 Example.Sensors.Type1 的命名空间中更深一层。 When trying to deserialize Type1SensorInfo into the list, it threw the exception.当尝试将 Type1SensorInfo 反序列化到列表中时,它抛出了异常。 When I added using Example.Sensors.Type1 into the ISensorInfo interface, no more exception!当我使用 Example.Sensors.Type1 添加到 ISensorInfo 接口时,没有更多例外!

namespace Example
{
    public class ConfigFile
    {
        public ConfigFile()
        {
            Sensors = new List<ISensorInfo<Int32>>();
        }
        public List<ISensorInfo<Int32>> Sensors { get; set; }
     }
   }
}

**using Example.Sensors.Type1; // Added this to not throw the exception**
using System;

namespace Example.Sensors
{
    public interface ISensorInfo<T>
    {
        String SensorName { get; }
    }
}

using Example.Sensors;

namespace Example.Sensors.Type1
{
    public class Type1SensorInfo<T> : ISensorInfo<T>
    {
        public Type1SensorInfo() 
    }
}

I've had the same thing happen when I had a number of MSBuild processes running in the background which had effectively crashed (they had references to old versions of code).当我有许多在后台运行的 MSBuild 进程实际上已经崩溃(它们引用了旧版本的代码)时,我也发生了同样的事情。 I closed VS and killed all the MSBuild processes in process explorer and then recompiled.我关闭了 VS 并杀死了进程资源管理器中的所有 MSBuild 进程,然后重新编译。

I had a test project that references 2 other projects that each referenced different versions (in different locations) of the same dll.我有一个测试项目,它引用了两个其他项目,每个项目都引用了同一个 dll 的不同版本(在不同位置)。 This confused the compiler.这使编译器感到困惑。

In my case spotify.exe was using the same port which my web api project wanted to use on a development machine.在我的例子中,spotify.exe 使用的是我的 web api 项目想要在开发机器上使用的相同端口。 The port number was 4381.端口号是 4381。

I quit Spotify and everything worked well again :)我退出了 Spotify,一切都恢复正常了 :)

当方法需要一个我没有指定的参数时,我遇到了这个问题

In my case, there was no code change at all and suddenly one of the servers started getting this and only this exception (all servers have the same code, but only one started having issues):就我而言,根本没有代码更改,突然其中一台服务器开始出现此异常,只有这个异常(所有服务器都有相同的代码,但只有一个开始出现问题):

System.MissingMethodException: Method not found: '?'.

Stack:堆:

Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at myAccountSearch.AccountSearch.searchtPhone(searchtPhoneRequest request)
   at myAccountSearch.AccountSearchClient.myAccountSearch.AccountSearch.searchtPhone(searchtPhoneRequest request)
   at myAccountSearch.AccountSearchClient.searchtPhone(String ID, String HashID, searchtPhone Phone1)
   at WS.MyValidation(String AccountNumber, String PhoneNumber)

The issue I believe was corrupted AppPool - we have automated AppPool recycling going on every day at 3 am and the issue started at 3 am and then ended on its own at 3 am the next day.我认为问题是 AppPool 损坏 - 我们每天凌晨 3 点进行自动 AppPool 回收,问题从凌晨 3 点开始,然后在第二天凌晨 3 点自行结束。

Must be a reference bug from Microsoft.必须是来自 Microsoft 的参考错误。

I cleaned, rebuild on all my libraries and still got the same problem and couldnt resolve this.我清理,重建了我所有的库,但仍然遇到同样的问题,无法解决。

All i did was close the Visual Studio Application and opened it again.我所做的只是关闭 Visual Studio 应用程序并再次打开它。 That did the trick.那成功了。

Its very frustrating that such a simple issue can take that long to fix because you wouldnt think that it will be something like that.非常令人沮丧的是,这样一个简单的问题可能需要很长时间才能解决,因为您不会认为它会是那样的事情。

For posterity, I ran into this with an azure function, using the azure durable function / durable tasks framework.对于后代,我使用 azure 持久函数/持久任务框架使用 azure 函数遇到了这个问题。 It turns out I had an outdated version of the azure functions runtime installed locally.事实证明,我在本地安装了一个过时的 azure 函数运行时版本。 updating it fixed it.更新它修复了它。

Ran into this error after updating a variety of Nuget packages.更新各种 Nuget 包后遇到此错误。 Check your Visual Studio Error List (or build output) for a warning similar to the following:检查您的 Visual Studio 错误列表(或生成输出)是否有类似于以下内容的警告:

Found conflicts between different versions of the same dependent assembly.发现同一依赖程序集的不同版本之间存在冲突。 In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts;在 Visual Studio 中,双击此警告(或选择它并按 Enter)以修复冲突; otherwise, add the following binding redirects to the "runtime" node in the application configuration file:否则,将以下绑定重定向添加到应用程序配置文件中的“运行时”节点:
... ...

Double-clicking this warning in Visual Studio automatically adjusted a variety of bindingRedirect package versions in my web.config and resolved the error.在Visual Studio中双击这个警告会自动调整我web.config中的各种bindingRedirect包版本,并解决了错误。

I solved this problem using an approach not mentioned in replies above.我使用上述回复中未提及的方法解决了这个问题。

In my case, the target project framework of my project that called the class method was set incorrectly.就我而言,调用类方法的项目的目标项目框架设置不正确。

(The target framework of the calling project was incorrect. The target framework of the called class/method was correct and I kept it the same). (调用项目的目标框架不正确。被调用的类/方法的目标框架是正确的,我保持不变)。

I got this exception while testing out some code a coworker had written.我在测试同事编写的一些代码时遇到了这个异常。 Here is a summary of the exception info.:以下是异常信息的摘要:

Method not found: "System.Threading.Tasks.Task 1<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry 1<System_Canon>> Microsoft.EntityFrameworkCore.DbSet`1.AddAsync...找不到方法:“System.Threading.Tasks.Task 1<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry 1<System_Canon>> Microsoft.EntityFrameworkCore.DbSet`1.AddAsync ...

This was in Visual Studio 2019 in a class library targeting .NET Core 3.1.这是在面向 .NET Core 3.1 的类库中的 Visual Studio 2019 中。 The fix was to use the Add method instead of AddAsync on the DbSet.修复方法是在 DbSet 上使用 Add 方法而不是 AddAsync。

暂无
暂无

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

相关问题 System.MissingMethodException:找不到 Bigquery 的方法 - System.MissingMethodException: Method not found for Bigquery 运行到System.MissingMethodException:使用PrivateObject找不到方法 - Running into System.MissingMethodException: Method Not Found with PrivateObject 找不到System.MissingMethodException方法Crystal报表 - System.MissingMethodException Method Not Found Crystal Reports dll 中的方法抛出 System.MissingMethodException:找不到方法 - Method in dll throwing System.MissingMethodException: Method not found System.MissingMethodException: &#39;找不到 XmlRpcProxyGen.Create 的方法 - System.MissingMethodException: 'Method not found for XmlRpcProxyGen.Create 找不到类型 xxx 的 System.MissingMethodException 构造函数 - System.MissingMethodException Constructor on type xxx not found System.MissingMethodException:找不到方法:&#39;System.String .get_DayName()&#39; - System.MissingMethodException: Method not found: 'System.String .get_DayName()' Rebus - System.MissingMethodException:找不到方法:'System.Threading.Tasks.Task Rebus.Bus.IBus.Send' - Rebus - System.MissingMethodException : Method not found: 'System.Threading.Tasks.Task Rebus.Bus.IBus.Send' System.MissingMethodException:找不到方法&#39;System.Collections.Generic.Dictionary`2.GetValueOrDefault&#39; - System.MissingMethodException: Method 'System.Collections.Generic.Dictionary`2.GetValueOrDefault' not found System.MissingMethodException:找不到方法:“?” 尝试使用委托方法构建自定义动态类型时 - System.MissingMethodException: Method not found: '?' when trying to build a custom dynamic type with a delegate method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM