When code that targets the Microsoft .NET Framework 4.5.1 or the Microsoft .NET Framework 4.5.2, and the code dynamically binds to methods (for example, using a script in Windows PowerShell, IronPython, IronRuby, or another dynamic language) calls the System.Runtime.InteropServices.Marshal.SizeOf method or the System.Runtime.InteropServices.Marshal.PtrToStructure method, you may experience the following issues.
Note Code that is already compiled into a managed executable does not exhibit these issues, unless that code uses the dynamic keyword in C#.
Note Code that is already compiled into a managed executable does not exhibit these issues, unless that code uses the dynamic keyword in C#.
Issue 1
Calls to System.Runtime.InteropServices.Marshal.SizeOf throw the following MethodInvocationException exception:Type '<Type name>' cannot be marshalled as an unmanaged structure; no meaningful size or offset can be computed.
Issue 2
Calls to System.Runtime.InteropServices.Marshal.PtrToStructure throw the following MethodInvocationException exception:The specified structure must be blittable or have layout information.
Issue 3
Calls to System.Runtime.InteropServices.Marshal.PtrToStructure throw the following RuntimeBinderException exception:Cannot implicitly convert type 'void' to 'object'.