0

My question is a follow up on: How can I calculate progress with HttpClient PostAsync?

This solution works perfectly. Just remember, if you are using Xamarin, to include the Microsoft.Net.Http nuget package in the .iOS project otherwise you'll get a TypeLoadException when initialising this class – Davide Vosti Oct 27 '15 at 6:47

I'm working with a Xamarin PCL project. This works perfectly on iOS.

I run into problems on droid. I'm targeting 4.4, however, the MSFT HTTP.Net droid package targets 7.1 and I get the expected TypeLoadException. Any workarounds (that keep me at 4.4)?

Thanks, D

  • Why are you adding this package? Mondern PCL profiles and .NET Standard has System.Net.Http baked in. Hence, no need to add that package. – Cheesebaron Aug 22 '17 at 07:10
  • Without the package the virtual table for overloads is messed up. Thus, the reason adding the package solves the problem in iOS and Android (assuming I wanted to sacrifice ~87% of the android userbase). – user7338313 Aug 25 '17 at 14:40
  • You are doing something really strange if you get those vtable errors.... – Cheesebaron Aug 25 '17 at 18:48

1 Answers1

0

Not an answer to the question, but I've hit the same problem here today trying to add upload progress support by extending HttpContent, using Xamarin with a core PCL project and Xamarin Android (there's also an iOS project using the core). I'm adding some extra detail in this post rather than creating a duplicate SO post.

When I'd tried any of the proposed solutions on StackOverflow (including the one the original poster had linked to) that extend from HttpContent, I'm getting an exception of:

System.TypeLoadException: Type Test.Project.FileService+CustomStream has invalid vtable method slot 6 with method none

Which I'm guessing is the same problem they're seeing. I'm not including Microsoft.Net.Http in the PCL/Android project, but we are using System.Net etc.

When I'd tried deriving from StreamContent instead, while that didn't crash, breakpoints were only hit for the contructor and TryComputeLength, but not SerializeToStreamAsync, though the data was successfully uploaded to the server without that being hit.

This is a legacy app I'm working on targetting Android 4.4 too. While I've managed to have this kind of thing working on platform specific (Xamarin.Android) in the past, that would be a much bigger change to this app so ideally would like to be able to get this working in the PCL

SteveC
  • 1,594
  • 2
  • 14
  • 14
  • Yes, that's the exact same error I get. After reading your post, I gave overriding the other child classes a go. They don't create a link error, however, I think the vtable is still messed up since it isn't tied back into the core executable (I don't see why this should be, but oh well), and thus the parent rather than our override is called. – user7338313 Aug 25 '17 at 14:42