I'm getting an unexpected RuntimeBinderInternalCompilerException when passing an object as a dynamic argument.
I'll try to explain the scenario, as it's too involved to paste code easily. I'm doing some really weird hackery with Roslyn, so it's going to sound odd.
This dynamic passing should work, because the type is compatible: i.e., in my case I can guarantee it has functionally matching methods/types.
But when I go to execute the changed+reloaded method, and it receives an object of type dynamic, I'm getting this exception.
RuntimeBinderInternalCompilerException was unhandled. An unexpected exception occurred while binding a dynamic operation
Per MSDN:
Exceptions of this kind differ from RuntimeBinderException in that RuntimeBinderException represents a failure to bind in the sense of a usual compiler error, whereas RuntimeBinderInternalCompilerException represents a malfunctioning of the runtime binder itself.
Google has absolutely no results for this. I don't know how to debug further into it either. Any suggestions?
( I did do some sandbox testing to assure myself that I could load different assemblies at runtime into a test application and pass instanced types from different assemblies to a single method accepting a dynamic parameter. So it does work in that scenario. )
It's difficult to answer the question without more details, but reading what you've said, there are a few things to note:
Internally, all type names are fully qualified. This means that the compiler will reject your code if you try to treat two types as the same unless they are from the same assembly, with the same namespace and name. Getting slightly different types to mesh in .Net is tricky.
dynamic
doesn't always work as you might intuitively think. If you're playing with the compiler, it's very much worth learning how IL works, and looking at both your code and the base-class-library code to see how they interact.
A very useful tool for low-level .Net work is ILSpy: http://ilspy.net/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With