问题标签 [targetinvocationexception]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1708 浏览

debugging - 捕获登录 C++ CLI 应用程序的异常

我试图在 C++/CLI 应用程序中捕获所有异常,以便我可以记录和记录它们(包括堆栈跟踪)。到目前为止,我有一些看起来很有希望的代码:

...但是我没有显示一个包含我整理过的错误的对话框,而是得到了其他东西:

这是因为Run命令试图以某种方式处理异常吗?我需要在MainForm某个地方处理里面的东西吗?...或者是否有其他(更好的)方法来解决这个问题。

暂时忘记错误的来源(我正处于开发周期的中期,仍在调试),如果能够捕获这些错误并生成一个整洁的小堆栈跟踪,它可以保留在代码中直到部署和让用户知道什么时候出了问题。最终,我会将错误报告包装成可以通过网络报告的内容。

0 投票
3 回答
542 浏览

exception - 将站点推送到生产环境时出现异常

这可能是在黑暗中拍摄,但这里什么都没有......

我有一个正在本地开发的 Sitecore 6 站点。当我将它推送到生产服务器时,我现在在尝试访问该站点时遇到异常。我已经完成了 Sitecore 版本的升级,并添加了表单模块,以及其他一些小的编辑。因此,我将所有内容都移至生产环境,更改了连接字符串,并更改了 web.config 中的目录引用,但仍然出现此错误。

我的本地机器仍然可以正常工作,甚至我的登台服务器(通过 SVN 和 Cruise Control 连接)也可以正常工作,但我无法在生产中修复此错误。

在堆栈跟踪的底部(下图),它看起来像是在尝试实例化搜索管理器。也许这与它有关?

或者当我移动所有东西时,我错过了一个设置?环境变化时需要更改哪些设置?

这是我迄今为止尝试过的:

  1. 重新复制所有文件和数据库。
  2. 向工作进程、ASPNET 和网络服务用户授予完全控制权限。
  3. 仔细检查 web.config 中需要配置的目录路径。
  4. 仔细检查了 connectionstring.config 中的连接字符串。
  5. 回收应用程序池
  6. 停止并启动该站点
  7. 清除了我的本地浏览器缓存(正如他们在升级文档中指示你做的那样)

这是我尝试访问任何页面时引发的异常:

线程信息:线程 ID:1 线程帐户名称:180716WEB1\testcom_web 正在模拟:False 堆栈跟踪:在 System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) 在 System.RuntimeMethodHandle。 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] 参数, CultureInfo 文化, Boolean skipVisibilityChecks) 在 System.Reflection.RuntimeMethodInfo.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) System.Reflection.RuntimePropertyInfo.SetValue(Object obj,System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index) 在 Sitecore.Reflection.Reflection.ReflectionUtil.SetProperty(Object obj, PropertyInfo) 的对象值、BindingFlags invokeAttr、Binder binder、Object[] index、CultureInfoculture属性,对象值)在 Sitecore.Reflection.ReflectionUtil.SetProperty(对象 obj,字符串名称,对象值)在 Sitecore.Configuration.Factory.AssignProperties(对象 obj,对象 [] 属性)在 Sitecore.Configuration.Factory.AssignProperties(XmlNode Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) 在 Sitecore.Configuration.Factory.GetInnerObject 的 configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper) (XmlNode paramNode, String[] 参数,布尔断言)在 Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode,字符串 [] 参数,对象 obj,布尔断言,布尔延迟,IFactoryHelper 助手)在 Sitecore.Configuration.Factory.CreateObject(XmlNode configNode,字符串 [] 参数,布尔断言,IFactoryHelper 助手)在 Sitecore.Configuration.Factory.GetInnerObject(XmlNode 参数节点,字符串 [] 参数,布尔断言)在 Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode,字符串 [] 参数,对象 obj,布尔断言,布尔延迟, IFactoryHelper helper) 在 Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) 在 Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) 在 Sitecore。配置.工厂。Sitecore.Configuration.Factory.CreateObject(String configPath, String[] parameters, Boolean assert) 在 Sitecore.Search.SearchManager..cctor()

自定义活动详情:

有关详细信息,请参阅http://go.microsoft.com/fwlink/events.asp上的帮助和支持中心。

0 投票
2 回答
1596 浏览

c# - 关于 WPF 中图像更新的 TargetInvocationException

我已经构建了一个显示图像的 WPF 控件。现在我想以非常快的速度更改该图像。我已经构建了一个 ImageContainer 类,它包含图像并具有一个 ChangedEventHandler ,它在更改时更新我的​​控件中的图像。

执行的代码如下所示:

此代码引发 System.Reflection.TargetInvocationException,我做错了什么?

0 投票
2 回答
21876 浏览

c# - 为什么 TargetInvocationException 被 IDE 视为未捕获?

我有一些代码使用反射从对象中提取属性值。在某些情况下,属性可能会抛出异常,因为它们具有空引用等。

最终代码可以正常工作,但是当我在调试器下运行时:

当属性引发异常时,IDE 会像未捕获异常一样进入调试器。如果我只是点击运行,程序就会流过,异常作为 TargetInvocationException 出现,而​​真正的异常在 InnerException 属性中。

我怎样才能阻止这种情况发生?

0 投票
2 回答
1488 浏览

c# - 多个 WCF 服务调用上的 TargetInvocationException

我正在使用 SL 4 和带有 PollingDuplexHttpBinding 的 .net-4 WCF 服务。调用服务并从服务中调用客户端工作正常。但是,一旦我调用该服务,比如说 15 次而不等待异步答案,我会在获得 0、1 或 2 个成功答案后收到 TargetInvocationException。

我的服务属性是:

这是在我的 web.config 中:

像这样,我在客户端实例化服务:

因为我是 WCF 的新手:我错过了什么吗?

0 投票
2 回答
4240 浏览

entity-framework - Code-First Entity Framework - error creating SQL CE DB

I have been using Entity Framework CTP with Code-First as in this tutorial by Scott Guthrie and another by Scott Hanselman (can't post the link, but google "Simple Code First with Entity Framework 4 - Magic Unicorn Feature CTP 4"). This is working perfectly for the main MVC application, but I am now trying to add a testing project, that uses a separate SQL CE Database.

I have added the following to the App.Config file:

However when I try to run the tests it throws the following error when trying to create the database:

Test method MyProjet.Tests.Administration.ModlelTests.Business.TestGetBusinessesList threw exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlServerCe.SqlCeProviderServices' threw an exception. ---> System.Security.VerificationException: Operation could destabilize the runtime.

With the following stack trace:

System.Data.SqlServerCe.SqlCeProviderServices..ctor() System.Data.SqlServerCe.SqlCeProviderServices..cctor() System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized) System.Reflection.RtFieldInfo.InternalGetValue(Object obj, Boolean doVisibilityCheck, Boolean doCheckConsistency) System.Reflection.RtFieldInfo.InternalGetValue(Object obj, Boolean doVisibilityCheck) System.Reflection.RtFieldInfo.GetValue(Object obj) System.Data.SqlServerCe.ExtensionMethods.SystemDataSqlServerCeSqlCeProviderServices_Instance_GetValue() System.Data.SqlServerCe.ExtensionMethods.SystemDataSqlServerCeSqlCeProviderServices_Instance() System.Data.SqlServerCe.SqlCeProviderFactory.System.IServiceProvider.GetService(Type serviceType) System.Data.Common.DbProviderServices.GetProviderServices(DbProviderFactory factory) System.Data.Common.DbProviderServices.GetProviderServices(DbConnection connection) System.Data.Entity.ModelConfiguration.Internal.Configuration.CodeFirstCachedMetadataWorkspace.GetMetadataWorkspace(DbConnection storeConnection) System.Data.Entity.Infrastructure.DbModel.CreateObjectContext[TContext](DbConnection existingConnection) System.Data.Entity.Internal.LazyInternalContext.InitializeFromModel(DbModel model) System.Data.Entity.Internal.LazyInternalContext.InitializeContext() System.Data.Entity.Internal.InternalContext.Initialize() System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) System.Data.Entity.Internal.Linq.EfInternalQuery1.Initialize() System.Data.Entity.Internal.Linq.EfInternalQuery1.Include(String path) System.Data.Entity.Infrastructure.DbQuery`1.Include(String path) MyProjet.Areas.Administration.Models.BusinessModel.GetBusinesses() in D:\projects2010\MyProjet\MyProjet\Areas\Administration\Models\BusinessModel.cs: line 47 MyProjet.Tests.Administration.ModlelTests.Business.TestGetBusinessesList() in D:\projects2010\MyProjet\MyProjet.Tests\Administration\ModlelTests\Business.cs: line 45

I have tried replacing the existing MyData connection string in the MVC application, and it works fine. It only causes this problem when this is added to the Testing project. Additionally the testing project works without problem when pointed at an SQL or SQL Express Database.

Have been struggling with this for a while now, and just can't figure it out. I am sure I have overlooked something simple.

0 投票
1 回答
298 浏览

c# - 修改 MOSS Web 部件时出错

每当我尝试在 sharepoint 2007 中编辑自定义 Web 部件的共享属性时,都会收到以下错误:

我的 Web 部件中确实有一些自定义属性,用于设置表单生成的通知电子邮件的电子邮件地址。这方面的一个例子是:

但是,即使注释掉了这些属性,我在尝试修改 Web 部件时仍然会收到错误消息。

有没有其他人处理过这样的问题?如果需要,我可以提供更多信息或代码片段。

0 投票
1 回答
613 浏览

unit-testing - NUnit 的 log4Net 问题(已尝试 v2.5.7、2.5.2、2.4.8、2.4.7)

针对生产代码程序集运行 NUnit 时出现错误(请参阅帖子底部)。生产代码程序集引用了内部使用 log4net 的第三方框架(具体来说,这是 SimplyAccounting 的 SDK)。它使用的 log4net 版本是 1.2.9.0。除了我们通过 dll 文件中的公共 api 使用的第三方框架之外,log4net 不是我们生产代码的一部分。

在进行故障排除时,我从单元测试项目中消除了对生产代码程序集的引用,并添加了对 SimplyAccounting SDK 的引用。当我这样做时,NUnit 会吐出以下错误。如果第三方参考(或生产代码参考)不在测试项目中,那么 Nunit 运行良好。任何具有潜在 log4net 冲突的解决方法都会有所帮助。我正在使用 NUnit 2.5.2。

0 投票
1 回答
454 浏览

c# - 这两个调用有何不同?

我正在尝试修改 WinForms 应用程序上的组合框,但出现了一些奇怪的行为。我正在尝试两种方法:

这是我需要调用的方法:

我正在尝试两种不同的方法来从 GUI 线程调用此方法。这个有效:

这会引发 TargetInvocationException:

我更喜欢使用第二个,因为它更清晰,但我不完全确定为什么当第一个示例运行良好时它会引发错误。第一个示例调用该modifyCombo方法并正确返回IndexOf对象的。第二个例子是-1IndexOf.

编辑:这是堆栈跟踪的 pastebin 链接。 http://pastebin.com/TwfUDw4u

0 投票
3 回答
22437 浏览

c# - C# 多线程 - 'System.Reflection.TargetInvocationException'

几天前我开始在 C# (WPF) 中进行多线程编程,这是一个我无法解决的问题......我正在使用这段代码:

我认为问题来自上层代码。在我的程序运行大约一分钟后抛出异常。这是一个例外:

mscorlib.dll 中出现“System.Reflection.TargetInvocationException”类型的未处理异常

附加信息:调用的目标已引发异常。

之后我收到这条消息:

当前位置没有可用的源代码。

我知道我的源代码有点难看,等我解决了这个问题,我会改进它。你能告诉我如何解决它吗?