3

My project uses a library which in turn uses Microsoft.Practices.Unity to dynamically create a class and run some of its methods. This class is throwing an error after it is created.

Is it possible for me to use the Visual Studio debugger to step into and debug this dynamic class? I have Reflector Pro which has enabled me to dig down as far as I have.

Note: I already tried contacting the developer of the library I am using and they do not seem willing to address this issue at this time. Therefore, I am trying to dig down into it myself.


UPDATE

I don't mean the dynamic keyword. The top line of the stack trace is

DynamicModule.ns.Wrapped_OpenAccessMetaDataProvider_bf5ed2b8ccd24dacab4923be24786366.Initialize(String providerName, NameValueCollection config, Type managerType) +506

Googling the DynamicModule.ns.Wrapped_ leads to Unity's InterfaceInterceptorClassGenerator class. This class would seem to make sense given that it is "used to generate proxy classes...". I am having trouble finding a suitable code sample because it looks like there is a significant OO framework around the construction of this class.


UPDATE 2

The unity class is throwing an exception:

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

The exception didn't have a LoaderExceptions property so that doesn't help. I didn't want to bog down the question with details but in short it is this: my CMS (which will remain nameless) uses an outdated version of the Facebook C# SDK. Upon updating the Facebook SDK assemblies, this error is thrown. That makes sense because the SDK changed. I am trying to gain insight onto the connection between the OpenAccessMetaDataProvider class and the Facebook SDK.

Community
  • 1
  • 1
Jeff
  • 13,943
  • 11
  • 55
  • 103
  • Can you show us any source code that shows how you are creating a class and calling its methods? – JGWeissman Oct 04 '11 at 17:33
  • Do you mean an object that is `dynamic` (keyword), or an anonymous class? – GalacticCowboy Oct 04 '11 at 17:33
  • @GalacticCowboy No, not the dynamic keyword. Please see my edit for clarification. – Jeff Oct 04 '11 at 19:39
  • @JGWeissman The construction of this object and the population of its members are spread out over many classes that I am currently wading through. It does look like Unity's InterfaceInterceptorClassGenerator is the class that is doing the actual construction though. Hopefully that helps. – Jeff Oct 04 '11 at 19:41
  • What exeception is begin thrown by the unity created class ? – user957902 Oct 04 '11 at 20:39
  • Just a thought, you could set Visual Studio to throw the exception via the Debug > Exceptions menu **and** turn off the 'Just My Code' Debugging option (under Tools > Options) so that it will actually break within the generated class. – Dennis Oct 04 '11 at 20:56
  • @DennisRoche thanks for the tip, but I tried that already. It breaks one position up the stack from the generated class. – Jeff Oct 04 '11 at 21:03
  • Does the exception have an `InnerException` or something similar? What is its type? – svick Oct 04 '11 at 22:47

1 Answers1

1

I'm no expert on dynamic classes, but try System.Diagnostics.Debugger.Break() ...

Matt
  • 6,787
  • 11
  • 65
  • 112