从动态类型燮preSS RuntimeBinderException消息 [英] Suppress RuntimeBinderException messages from dynamic types

查看:212
本文介绍了从动态类型燮preSS RuntimeBinderException消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用专用的NuGet服务器来管理我的组织的内部库。这意味着,以加强我们自己的code是在图书馆,我需要禁用启用仅我的code,在调试选项,因为我们不是直接引用的项目了。这是使用动态类型和除 ViewBag ExpandoObjects A pretty的巨额MVC项目。我得到两个 RuntimeBinderExceptions 为每一个使用动态类型......这是很多的。这似乎是正常的行为,从我读过。正常的可能,但很有用事实并非如此。

I've recently started using a private NuGet server to manage my organization's internal libraries. This means in order to step into our own code that is in a library, I need to disable "Enable Just My Code" in debugging options since we aren't referring to the projects directly any more. This is a pretty hefty MVC project that uses dynamic types and ExpandoObjects in addition to ViewBag. I get two RuntimeBinderExceptions for every single use of a dynamic type... which is a lot. This appears to be normal behavior from what I've read. Normal it may be, but useful it is not.

我的第一个念头是禁用这个特殊的exeption在调试 - >例外对话框。唯一的例外是不是在那里找到。我想不出什么办法能够加强直接引用的项目外,还没有开自己交给这些异常。 (和其他低层次的框架例外所有的方式,我不想听,但是这是最大的罪犯至今)。

My first thought was to disable this particular exeption in the Debug-> Exceptions dialog. The exception is not to be found there. I can't figure out any way to be able to step outside the projects referenced directly, without also opening myself up to these exceptions. (And all manner of other low-level framework exceptions that I don't want to hear about, but this is the biggest offender by far).

什么是解决这一问题的最佳方法是什么?

What's the best way to deal with this?

编辑:这就是问题所在。我该如何制止这种以启用仅我的code已禁用?

This is the problem. How do I stop this with "Enable Just My Code" disabled?

推荐答案

几件事情尝试:

  1. 请启用仅我的code已禁用

    使用[DebuggerStepThrough()停止调试程序评估code - 把这个你级(以继承所有的属性和方法的属性),或者只是把它放在特定的属性/方法。

    您仍然可以把一个断点在你的code,如果你需要的东西进行调试。

  1. Keep "Enable Just My Code" disabled.

    Use [DebuggerStepThrough()] to stop the debugger evaluating the code - put this on "your" class (to inherit the attribute on all your properties and methods) or just put it on specific properties/methods.

    You can still put a breakpoint in "your" code if you need to debug something.

如果你的问题是,你想躲被记录在输出窗口的例外,因为你不能看到发生了什么,那么也许你也许可以关闭特定TraceSource的跟踪(通过code或A config文件),该生成异常跟踪。

If your problem is that you want to "hide" the exceptions being logged in your Output Window, because you can't see what is going on, then maybe you could perhaps switch off the tracing of the particular TraceSource (via code or a .config file) that is generating the exception tracing.

在另一手也许你正在返回匿名类型,这是摆在首位的异常的原因....尝试把他们变成ExpandoObjects

On the other-hand maybe you are returning anonymous types, and that is the cause of your exceptions in the first place....try turning them into ExpandoObjects

如果没有3,其实是造成这个问题,另一种可能是使内部可见的NuGet服务器(见最后链接)。

If no 3 is in fact causing the issue, an alternative might be to make "internals" visible to the NuGet Server (see last link).

5。最新情况:其实我觉得这可能是这么简单。

<一href="http://msdn.microsoft.com/en-us/library/tw4t258c.aspx">http://msdn.microsoft.com/en-us/library/tw4t258c.aspx

use Add按钮下的通用语言运行时例外类型添加一个新的异常,并称之为Microsoft.CSharp.RuntimeBinder.RuntimeBinderException......然后就确保抛出用户处理的不打勾。

参考文献:

  • <一个href="http://stackoverflow.com/questions/7429957/dynamic-view-of-anonymous-type-missing-member-issue-mvc3">Dynamic鉴于匿名类型缺少的成员问题 - MVC3

<一个href="http://stackoverflow.com/questions/5678608/why-a-microsoft-csharp-runtimebinder-runtimebinderexception-if-the-invoked-metho">Why一个Microsoft.CSharp.RuntimeBinder.RuntimeBinderException如果被调用的方法有没有?

<一个href="http://mohammedezzatawad.blogspot.co.uk/2012/05/runtimebinderexception-cannot-resolver.html">http://mohammedezzatawad.blogspot.co.uk/2012/05/runtimebinderexception-cannot-resolver.html

<一个href="http://stackoverflow.com/questions/1420390/dont-stop-debugger-at-that-exception-when-its-thrown-and-caught">Don't停止调试器在该异常时,它的抛出和捕获

<一个href="http://www.professionalvisualstudio.com/blog/2008/09/09/debugging-tip-of-the-week-6-the-debuggerstepthrough-attribute/">http://www.professionalvisualstudio.com/blog/2008/09/09/debugging-tip-of-the-week-6-the-debuggerstepthrough-attribute/

<一个href="http://stackoverflow.com/questions/8751814/can-debuggerstepthrough-be-inherited-into-the-automatically-generated-ienumerabl">Can DebuggerStepThrough被继承到自动生成的IEnumerable实现?

<一个href="http://www.heartysoft.com/anonymous-types-c-sharp-4-dynamic">http://www.heartysoft.com/anonymous-types-c-sharp-4-dynamic

这篇关于从动态类型燮preSS RuntimeBinderException消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆