I have a standard class like "dynamic dictionary" in C # -
class Bucket : DynamicObject { readonly Dictionary<string, object> m_dict = new Dictionary<string, object>(); public override bool TrySetMember(SetMemberBinder binder, object value) { m_dict[binder.Name] = value; return true; } public override bool TryGetMember(GetMemberBinder binder, out object result) { return m_dict.TryGetValue(binder.Name, out result); } }
Now I call it like this:
static void Main(string[] args) { dynamic d = new Bucket(); d.Name = "Orion";
The application does what you expect from it, but the debug output is as follows:
A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Microsoft.CSharp.dll
A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Microsoft.CSharp.dll
'ScratchConsoleApplication.vshost.exe' (Managed (v4.0.30319)): Loaded 'Anonymously Hosted DynamicMethods Assembly'
A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Microsoft.CSharp.dll
A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Microsoft.CSharp.dll
Any attempt to access a dynamic member seems to RuntimeBinderException in the debug logs. Although I know that exceptions from the first chance are not a problem in themselves, this causes some problems for me:
I often have a debugger set to "break on exceptions" because I write WPF applications, otherwise all exceptions end up being converted to DispatcherUnhandledException , and all the actual information you want to lose, WPF sucks.
As soon as I click on any code that uses dynamic , the debug output log becomes useless. All useful trace lines that interest me are hidden among all useless RuntimeBinderException s
Is it possible to disable this, or RuntimeBinder , unfortunately, just built?
Thanks, Orion
c # dynamic exception
Orion Edwards Jun 02 '10 at 1:55
source share