Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Compiling Npgsql2.0.11 on MonoTouch (with very few changes) always gives "Failed to establish connection to *"
Using MonoDroid and the exact same Npgsql source code it is working fine.
Created attachment 1845 [details]
Npgsql Test on MonoTouch NOT working
Created attachment 1846 [details]
Npgsql Test on MonoDroid IS working
It doesn't work because of this:
if I change NpgsqlClosedState.cs:123 to this (passing false for the second argument to WaitOne), it works:
if (!result.AsyncWaitHandle.WaitOne(context.ConnectionTimeout*1000, false))
Yes I can confirm that it works.
Is that a bug in Mono ?
Sebastien, it looks like you added the NotSupportedException in WaitHandle. Maybe it's better to just ignore the exitContext parameter? MSDN says: "The exitContext parameter has no effect unless the WaitOne method is called from inside a nondefault managed context."
Mikkel, right now it's a restriction in MonoTouch, but we might be able to remove that restriction.
Mikkel, that makes sense wrt --nolinkaway you used.
Rolf, we could set `emitContext` to false in every case (for MT). The exception was for people to review/fix their code - but sadly it looks like some libraries do not propagate the original exception to the application :-( Maybe an additional CWL that would show in the logs would serve better.
Yes when using Npgsql1 (Npgsql.dll) and --nolinkaway I got "exitContext == true" something.
Npgsql2 did not have that error, but failed to connect.
> Is that a bug in Mono ?
A bit. IMO the API (w/bool) should not have been exposed. The additional synchronization code has issues with MonoTouch (and that's why it's removed by the linker). Using --nolinkaway is a way to mitigate the issue, leading to larger binaries but without solving every issues.
It's also an issue with Npgsql. Unless there's a specific reason (and I'm not sure there is) Npgsql should be using `Wait(int)` which defaults to `false`. If only because it's far more heavyweight that it needs to be (when supported).
Also the overload with a boolean parameter is also not part of the Portable Class Library profiles (1-4) so it limits Npgsql availability to other profiles (e.g. xbox) but there could be many other limitations beside that one.
I'm c.c.ing Francisco Figueiredo Jr. which maintains Npgsql to see if he can (also) fix the Npgsql code so this would work on older, existing, MonoTouch releases (for other interested peoples).
Upstream bug has been filed: http://pgfoundry.org/tracker/index.php?func=detail&aid=1011200&group_id=1000140&atid=590
I'll make the change. From what I can see from this discussion and from the documentation, changing it to false won't have any impact to Npgsql and will give the added bonus of working on MonoTouch without any issues.
Thanks for bug report.
Fixed in Npgsql main repository. New Npgsql releases will work with Monotouch out of the box.
Thanks for reporting.