c# - dynamic/ExpandoObject method throws 'No default member found for type 'Action' -


i can't dynamic method on expandoobject directly callable in vb.net. in c# following works:

dynamic obj = new system.dynamic.expandoobject(); var called = false;  obj.forcerefresh = new action(() => called = true);  obj.forcerefresh(); 

i'd have thought same thing in vb.net be:

 dim called = false  dim obj object = new dynamic.expandoobject   obj.forcerefresh = new action(sub() called = true)   obj.forcerefresh() 'no default member found type 'action'.  obj.forcerefresh.invoke() 'this works 

the obj.forcerefresh throws 'no default member found type 'action'

it works if put invoke, that's not option (this simplified example of moq unit test, objects being tested call functions can't change them)

is there way of setting dynamic method in vb.net can call without invoke?

there doesn't seem way around - need use "invoke" call dynamically-added methods in vb.

the following microsoft link showing c# vs vb examples confirms this: http://msdn.microsoft.com/en-ca/library/system.dynamic.expandoobject.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-4


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -