4 Replies Latest reply on Jul 26, 2012 10:01 PM by RJKSolutions

    The type initialiser for 'MyDR' threw an exception

      Fellow vCampers...


      I have a baffling issue that I want to run by you all to see if anyone has experienced this, or has some intelligent suggestions.  For illustrative purposes I refer to MyDR as the custom Data Reference in question.


      I have a custom data reference, MyDR, that has maybe 8 or 9 supporting assemblies.  On the AF server itself the custom data reference works fine, it essentially calls some web services for data.  This makes me happy.  


      However, I want to get at this data reference from PI Web Parts so the data reference is copied on to the Sharepoint server.  Before I go near PI web Parts the data reference when loaded (via PI System Explorer on the server) is throwing the following generic error (I'm not happy anymore):


      The type initialiser for 'MyDR' threw an exception


      I log a more specific error of:


      MyDR failed.  Method:static MyDR() Exception:System.ArgumentNullException: Value cannot be null. Parameter name: method at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure) at MyDR.Piaf.Helpers.FixResolvePlugInAssemblyEventHandler.InsertPreHandler() at MyDR..cctor()


      Now I'm sad.  This error does not occur on the AF Server, only on the client (sharepoint server).


      Has anyone seen anything like this before?  All supporting assemblies are present, but PI System Explorer reports the "type initialiser" error for all Attributes using MyDR.  All security delegations are in place, to solve double hop. 


      Payment in beer awaits you.

        • Re: The type initialiser for 'MyDR' threw an exception

          Type 'MyDR' has a static constructor. This constructor will be called when the type is initialized (the type will be used, so instantiating MyDR or calling a static method on MyDR. (note: the exepction mentions ''MyDR..cctor()', and 'cctor()' is a static constructor (.ctor() is an instance constructor))


          The static constructor of MyDR calls the InsertPreHandler() method on type MyDR.Piaf.Helpers.FixResolvePluginAssemblyEventHandler to do some assembly resolving handling. It seems that this method uses Delegate.CreateDelegate, which gets a null value for the 'type' argument or the 'method' argument: which in turn causes the method to throw an ArgumentNullException.




          An 'unexpected' type was passed to a Type.GetMethod call in order to get the MethodInfo for Delegate.CreateDelegate. This will result in the MethodInfo to be null, causing the ArgumentNullException on the Delegate.CreateDelegate.


          - or -


          Some method to get a certain type from an (unkown) assembly (e.g. Assembly.GetType(string type)) returns a null value because the type is not there. This will result in the type argument for Delegate.CreateDelegate to be null, causing the ArgumentNullException on the Delegate.CreateDelegate.


          I would guess you have a versioning issue somewhere. Expecting certain types in an assembly (or namespace) that do not exist for that assembly, or expecting certain methods on a type that do not exist.