warning MSB3277 when building and System.TypeLoadException at runtime

IkeStarnesIkeStarnes USMember
edited May 2014 in Xamarin.Android

I'm getting this warning when I try to build my Android application. This application uses a portable class library (PCL) that is calling methods from System.Runtime.InteropServices.Marshal. At runtime, this will fail with:

System.TypeLoadException: Could not load type 'System.Runtime.InteropServices.Marshal' from assembly 'MyPCL'.

Also, in the output window, I have the following:
05-28 23:07:10.964 D/Mono ( 2689): Image addref System.Runtime.InteropServices[0x5c2a08] -> System.Runtime.InteropServices.dll[0x1fb040]: 4
05-28 23:07:10.974 D/Mono ( 2689): Assembly Ref addref MyPCL[0x1e9168] -> System.Runtime.InteropServices[0x1fbb20]: 2
05-28 23:07:10.974 W/ ( 2689): Missing method AllocHGlobal in assembly MyPCL.dll, type System.Runtime.InteropServices.Marshal
05-28 23:07:10.984 W/Mono ( 2689): The class System.Runtime.InteropServices.Marshal could not be loaded, used in MyPCL

Posts

  • IkeStarnesIkeStarnes USMember

    Also, in the output window I have the following:
    05-28 23:07:10.964 D/Mono ( 2689): Image addref System.Runtime.InteropServices[0x5c2a08] -> System.Runtime.InteropServices.dll[0x1fb040]: 4
    05-28 23:07:10.974 D/Mono ( 2689): Assembly Ref addref MyPCL[0x1e9168] -> System.Runtime.InteropServices[0x1fbb20]: 2
    05-28 23:07:10.974 W/ ( 2689): Missing method AllocHGlobal in assembly MyPCL.dll, type System.Runtime.InteropServices.Marshal
    05-28 23:07:10.984 W/Mono ( 2689): The class System.Runtime.InteropServices.Marshal could not be loaded, used in MyPCL

  • IkeStarnesIkeStarnes USMember

    I spoke to Jessica Stegar from xamarin via email and she mentioned that my PCL should target .NET 4.5.
    I checked my targets and found this:
    http://i.imgur.com/QM0rnqt.jpg

    On a whim, I changed the targets to .NET Framework 4.0, and now my Android app works.
    I'm confused. Is the Xamarin supposed to be compatible with 4.0 or 4.5?

    By the way, trying to select Android or iOS as a target will result in the following error:
    http://i.imgur.com/0m3POwV.jpg

Sign In or Register to comment.