-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NSURLsessionDelegate issues #6493
Comments
From the warnings/errors it looks like your delegate code is incorrect. Please attach a self-contained test case so we can have a look at the implementation. It's likely easier to use https://github.com/xamarin/xamarin-macios/blob/master/src/Foundation/NSUrlSessionHandler.cs with |
@spouliot |
Thanks for the sample. Your issue is that you cannot override (ObjC) block-based arguments without some extra glue code. E.g. this is how [Export ("URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:")]
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
public unsafe virtual void WillPerformHttpRedirection (NSUrlSession session, NSUrlSessionTask task, NSHttpUrlResponse response, NSUrlRequest newRequest, [BlockProxy (typeof (ObjCRuntime.Trampolines.NIDActionArity1V1))]global::System.Action<NSUrlRequest> completionHandler) The This glue code is provided automatically if you use (or override) existing bindings - but if you declare the This is not trivial so you can try to copy/paste existing code (it's largely internal) from However I would suggest you to use |
@spouliot , thanks for looking into this. My requirement is to handle all the challenges (NTLM/Basic/ClientCertificate/ServerTrust) from my code , so I was doing this, which used to work till sometime back. Can you point me where I can get the code for this from Xamarin.iOS.dll? |
Upon re-examination (by @rolfbjarne ) it's actually a supported scenario (i.e. it should work) but there's an issue in the static registrar for inherited interfaces. Re-opening |
@Maddy79 the workaround would be add the Sadly the |
@spouliot , yea when I tried using the BlockProxy , I did get the accessibility error for trampolines. |
yes, it will be fixed in a future release - but I cannot say when it will be released (even in a preview). Still it will be available (as an untested package, directly from our build bots) soon after this bug is closed (and you'll get a notification when that happens) |
…otnet#6493. When we're searching for metadata for marshalling blocks, we must search the entire interface hierarchy for protocols that implement optional members. Fixes dotnet#6493.
…otnet#6493. When we're searching for metadata for marshalling blocks, we must search the entire interface hierarchy for protocols that implement optional members. Fixes dotnet#6493.
…otnet#6493. When we're searching for metadata for marshalling blocks, we must search the entire interface hierarchy for protocols that implement optional members. Fixes dotnet#6493.
@spouliot , is the fix available in the Preview builds of VS (Mac)? |
Want to check on this to see if this fix is available now since the thread was closed 16 days ago as of the post. Thanks! |
The fix is currently available in our Xcode 11 preview channel. It will also be included in an upcoming update to the existing preview release in our Alpha/Beta channels. |
Steps to Reproduce
Create a class that derives from NSURLProtocol and NSURLSession delegate interfaces:
Ex: public partial class TestUrlProtocol : NSUrlProtocol, INSUrlSessionDelegate, INSUrlSessionTaskDelegate, INSUrlSessionDataDelegate
In StartLoading, create the URLSessionTask and resume the task
Add delegate methods to handle challenge and redirection
Expected Behavior
This needs to build / run and handle NTLM /certificate challenges
Actual Behavior
First issue:
Gives a warning for the below delegate:
**Warning MT4174: Unable to locate the block to delegate conversion method for the method TestSampleApp.TestUrlProtocol.WillPerformHttpRedirection's parameter #5. (MT4174) Warning
MT4174: Unable to locate the block to delegate conversion method for the method TestSampleApp.TestUrlProtocol.DidReceiveChallenge's parameter #4. (MT4174)**
**And when running this will crash with below error:
Unhandled managed exception: The runtime function get_block_wrapper_creator has been linked away. (ObjCRuntime.RuntimeException)
Crash is pointing at DidReceiveChallenge call.**
Environment
=== Visual Studio Enterprise 2019 for Mac ===
Version 8.1.3 (build 19)
Installation UUID: 5bba6d13-ac9c-4c7c-b27c-1f9467a37562
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.6.0.25 (d16-0 / 50f7527)
=== Mono Framework MDK ===
Runtime:
Mono 5.18.1.28 (2018-08/223ea7ef92e) (64-bit)
Package version: 518010028
=== NuGet ===
Version: 5.0.2.5988
=== .NET Core ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.11
2.1.9
2.1.8
2.1.2
2.1.1
SDK: /usr/local/share/dotnet/sdk/2.1.700/Sdks
SDK Versions:
2.1.700
2.1.505
2.1.504
2.1.302
2.1.301
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.18.1/lib/mono/msbuild/Current/bin/Sdks
=== Xamarin.Profiler ===
Version: 1.6.10
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Updater ===
Version: 11
=== Apple Developer Tools ===
Xcode 10.2.1 (14490.122)
Build 10E1001
=== Xamarin.Mac ===
Version: 5.10.0.157 (Visual Studio Enterprise)
Hash: 6bd9475
Branch: d16-1
Build date: 2019-06-12 17:28:48-0400
=== Xamarin.iOS ===
Version: 12.10.0.157 (Visual Studio Enterprise)
Hash: 6bd9475
Branch: d16-1
Build date: 2019-06-12 17:28:47-0400
=== Xamarin.Android ===
Version: 9.3.0.23 (Visual Studio Enterprise)
Commit: HEAD/d0b48056f
Android SDK: /Users/mbhattathiri/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.1
SDK Build Tools Version: 27.0.3
Build Information:
Mono: mono/mono@3a07bd426d3
Java.Interop: xamarin/java.interop/d16-1@5ddc3e3
LibZipSharp: grendello/LibZipSharp/d16-1@44de300
LibZip: nih-at/libzip@b95cf3f
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-1@acabd26
=== Microsoft Mobile OpenJDK ===
Java SDK: /Users/mbhattathiri/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
=== Android Device Manager ===
Version: 1.2.0.44
Hash: aac645b
Branch: remotes/origin/d16-1
Build date: 2019-05-29 19:55:24 UTC
=== Xamarin Designer ===
Version: 16.1.0.467
Hash: f1657e133
Branch: remotes/origin/d16-1-new-document-model
Build date: 2019-06-18 21:57:42 UTC
=== Xamarin Inspector ===
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1
=== Build Information ===
Release ID: 801030019
Git revision: 2d04b0145da8aa946d2cc9898fe2a59484e4f3f4
Build date: 2019-06-26 15:34:25+00
Build branch: release-8.1
Xamarin extensions: de240bddd6d1f96bfb1e7d11ce7ac5398956fe1d
=== Operating System ===
Mac OS X 10.14.5
Darwin 18.6.0 Darwin Kernel Version 18.6.0
Thu Apr 25 23:16:27 PDT 2019
root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
Build Logs
Example Project (If Possible)
The text was updated successfully, but these errors were encountered: