“调用的目标已引发异常” 错误(mscorlib)

发布于 2024-07-15 06:52:26 字数 376 浏览 8 评论 0原文

抛出错误

"Exception has been thrown by the target of an invocation" 

我有一个用 ASP.Net 2.0 开发的网站,在生产环境中 。 它并没有在开发中抛出这个错误。

源是“mscorlib”,堆栈跟踪显示错误,

System.RuntimeMethodHandle._InvokeMethodFast.

自上次上传到生产以来我唯一改变的是我已经开始使用会员控件(登录、LoginView),并添加了更多存储的控件程序和表格等。成员资格取决于我编写的自定义提供程序。

有人知道为什么会发生这种情况吗?

I have a website developed in ASP.Net 2.0 that is throwing the error

"Exception has been thrown by the target of an invocation" 

in the production environment. It was not throwing this error in development.

The source is 'mscorlib', and the stack trace says the error at

System.RuntimeMethodHandle._InvokeMethodFast.

The only thing I've changed since my last upload to production is that I've started using Membership controls (Login, LoginView), and have added a few more stored procedures and tables, etc. The membership depends upon a custom provider I've written.

Anybody have a clue why this could be happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(19

七颜 2024-07-22 06:52:26

我建议检查内部异常。 如果没有,请检查日志中是否有在此之前发生的异常。

这不是特定于网络的异常,我在桌面应用程序开发中也遇到过。 简而言之,发生的情况是接收此异常的线程正在运行一些异步代码(例如通过 Invoke()),并且异步运行的代码会因异常而爆炸。 此目标调用异常是该失败的后果。

如果您还没有这样做,请在触发此错误时调用的异步回调周围放置某种异常日志记录包装器。 例如,事件处理程序。 这应该可以帮助您找出问题所在。

祝你好运!

I'd suggest checking for an inner exception. If there isn't one, check your logs for the exception that occurred immediately prior to this one.

This isn't a web-specific exception, I've also encountered it in desktop-app development. In short, what's happening is that the thread receiving this exception is running some asynchronous code (via Invoke(), e.g.) and that code that's being run asynchronously is exploding with an exception. This target invocation exception is the aftermath of that failure.

If you haven't already, place some sort of exception logging wrapper around the asynchronous callbacks that are being invoked when you trigger this error. Event handlers, for instance. That ought to help you track down the problem.

Good luck!

蓝海似她心 2024-07-22 06:52:26

当调用不存在的方法时可能会发生这种情况。

This can happen when invoking a method that doesn't exist.

吐个泡泡 2024-07-22 06:52:26

我知道这有点奇怪,但我在 ac# 应用程序中遇到了这个错误,最后我发现问题是表单的图标! 当我改变它时,一切都工作正常。

我应该说我只在 XP 中遇到此错误,而不是在 7 或 8 中。

I know its kind of odd but I experienced this error for a c# application and finally I found out the problem is the Icon of the form! when I changed it everything just worked fine.

I should say that I had this error just in XP not in 7 or 8 .

玩套路吗 2024-07-22 06:52:26

尝试通过 Management Studio 2014 连接到 SQLServer2017 时遇到相同的错误

在此处输入图像描述

原因是向后兼容性

所以我刚刚下载了 Management Studio 2017 并尝试连接到 SQLServer2017。

问题解决!!

Encounter the same error when tried to connect to SQLServer2017 through Management Studio 2014

enter image description here

The reason was backward compatibility

So I just downloaded the Management Studio 2017 and tried to connect to SQLServer2017.

Problem Solve!!

流星番茄 2024-07-22 06:52:26
' Get the your application's application domain.
Dim currentDomain As AppDomain = AppDomain.CurrentDomain 

' Define a handler for unhandled exceptions.
AddHandler currentDomain.UnhandledException, AddressOf MYExHandler 

' Define a handler for unhandled exceptions for threads behind forms.
AddHandler Application.ThreadException, AddressOf MYThreadHandler 

Private Sub MYExnHandler(ByVal sender As Object, _
ByVal e As UnhandledExceptionEventArgs) 
Dim EX As Exception 
EX = e.ExceptionObject 
Console.WriteLine(EX.StackTrace) 
End Sub 

Private Sub MYThreadHandler(ByVal sender As Object, _
ByVal e As Threading.ThreadExceptionEventArgs) 
Console.WriteLine(e.Exception.StackTrace) 
End Sub

' This code will throw an exception and will be caught.  
Dim X as Integer = 5
X = X / 0 'throws exception will be caught by subs below
' Get the your application's application domain.
Dim currentDomain As AppDomain = AppDomain.CurrentDomain 

' Define a handler for unhandled exceptions.
AddHandler currentDomain.UnhandledException, AddressOf MYExHandler 

' Define a handler for unhandled exceptions for threads behind forms.
AddHandler Application.ThreadException, AddressOf MYThreadHandler 

Private Sub MYExnHandler(ByVal sender As Object, _
ByVal e As UnhandledExceptionEventArgs) 
Dim EX As Exception 
EX = e.ExceptionObject 
Console.WriteLine(EX.StackTrace) 
End Sub 

Private Sub MYThreadHandler(ByVal sender As Object, _
ByVal e As Threading.ThreadExceptionEventArgs) 
Console.WriteLine(e.Exception.StackTrace) 
End Sub

' This code will throw an exception and will be caught.  
Dim X as Integer = 5
X = X / 0 'throws exception will be caught by subs below
荆棘i 2024-07-22 06:52:26

由于我没有将我的项目设置为启动项目,所以出现此错误

。当我将当前项目设置为设置为启动项目时,它就消失了。

This error occurs to me due to I have not set my Project as StartUp Project

When I set my current project to Set As Start-Up Project then it gone.

晨敛清荷 2024-07-22 06:52:26

我刚刚因为命名空间不匹配而遇到了这个问题。 我的 XAML 文件正在被移植,它的命名空间与代码隐藏文件中的命名空间不同。

I just had this issue from a namespace mismatch. My XAML file was getting ported over and it had a different namespace from that in the code behind file.

君勿笑 2024-07-22 06:52:26

这可能有 2 个原因

1.我在 web.config 文件中发现连接字符串错误
我更改了连接字符串及其工作方式。

  1. 连接字符串是否正确,然后检查控制面板>服务>
    SQL Server 浏览器> 启动与否

This is may have 2 reasons

1.I found the connection string error in my web.config file
i had changed the connection string and its working.

  1. Connection string is proper then check with the control panel>services>
    SQL Server Browser > start or not
帥小哥 2024-07-22 06:52:26

我的问题是,我没有将连接字符串放在 appsettings.json 中的正确位置,它位于 IIS Express 对象内,然后我将其移至配置文件对象内,但它不起作用,我修复了问题将其放入 appsettings.json {此处}

my problem was that i didnt put the connection string in the right place in the appsettings.json it was inside IIS Express object then i moved it inside profiles object it didnt work as well the i fixed the problem by putting it inside the appsettings.json { here }

‖放下 2024-07-22 06:52:26

遇到同样的错误,解决了将目标平台从“混合平台”更改为“任何 CPU”的问题

Got same error, solved changing target platform from "Mixed Platforms" to "Any CPU"

喜爱皱眉﹌ 2024-07-22 06:52:26

就我而言,发生这种情况是因为在 VS(.NET 5 控制台应用程序)中选择了作为单个文件发布的选项,一旦我将其更改为正常发布,异常就消失了。

In my case, this happened due to choosing the option to publish as a single file in VS (.NET 5 console app), once I changed it to publish normally the exception was gone.

倦话 2024-07-22 06:52:26

当我尝试在 Controller 文件夹中添加新控制器但连接字符串放置在 Web.config 文件中的entityFramework 标记内时,出现此错误。

I got this error after I tried to add a new controller in the Controller folder but the connection string was placed inside the entityFramework tag in Web.config file.

旧故 2024-07-22 06:52:26

对我来说,当对另一台服务器进行内部调用并且该服务器没有在逻辑时间内应答或者调用它的配置错误时,就会发生这种情况。 我修复了连接到另一台服务器的问题,然后我从该服务器收到了正确的数据,并且负责调用该服务器的函数正常工作,然后我没有收到该错误。

For me, it happens when there is an internal call to another server and that server is not answering in a logical time or the configuration to call it is wrong. I fixed the problem of connecting to another server, then I received the correct data from that server and the function that was responsible for calling that server is working properly then I do not receive that error.

偏爱自由 2024-07-22 06:52:26

我编辑了验证字段,错误已解决。

builder.Property(x => x.Name)**.UseIdentityColumn()**.HasMaxLength(200);  
builder.Property(x => x.Name)**.IsRequired()**.HasMaxLength(200);

I edited the validation field, the error was resolved.

builder.Property(x => x.Name)**.UseIdentityColumn()**.HasMaxLength(200);  
builder.Property(x => x.Name)**.IsRequired()**.HasMaxLength(200);
最丧也最甜 2024-07-22 06:52:26

就我而言,我只是将 Oracle.ManagedDataAccess.Core 包从 2.19.60 更新到 3.21.61

In my case I just update Oracle.ManagedDataAccess.Core package from 2.19.60 to 3.21.61

哥,最终变帅啦 2024-07-22 06:52:26

我有同样的问题。
我试图从 C# 创建一个报告,但它没有检查该字段是否为空或空格。

我添加异常。

I had the same problem.
I was trying to create a report from C# and it wasn't checking if the field is empty or whitespace.

I add Exception.

爱给你人给你 2024-07-22 06:52:26

当调试并且没有发现 InnerException 时,可以方便地按 F5(继续),直到遇到另一个异常。 或者,如果它完全消失,您可以检查“输出”窗口以获取更多详细信息。

When debugging and no InnerException found it can be handy to hit F5 (continue) until it hits another Exception. Or if it drops out entirely you can then check the Output window for more details.

狠疯拽 2024-07-22 06:52:26

就我而言,这有效:

dotnet ef migrations add MyMigrationName --startup-project {your .csproj} --context {your context}

In my case just this worked:

dotnet ef migrations add MyMigrationName --startup-project {your .csproj} --context {your context}
乖乖哒 2024-07-22 06:52:26

这可能有两个原因:

  1. 在选择 WithMany 方法时使用 HasForeignKey
builder.HasOne(m => m.Model).WithMany(m => m.ParentModel).HasForeignKey(m => m.Number)
  1. 为数字插入 IsRequired
builder.Property(p => p.Number).IsRequired();

您必须删除这两项

This can have two reasons

  1. Use HasForeignKey when selecting the WithMany method
builder.HasOne(m => m.Model).WithMany(m => m.ParentModel).HasForeignKey(m => m.Number)
  1. Insert IsRequired for number
builder.Property(p => p.Number).IsRequired();

You must delete these two items

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文