Bug 36116

Summary: Mono 4.2 generates incorrect "Reference.map", causing "Could not find file '/TempConvert.wsdl'" when adding or updating a Web Reference in Xamarin Studio
Product: [Mono] Class Libraries Reporter: Kent Green [MSFT] <Kent.Green>
Component: System.Web.ServicesAssignee: marcos.henrich
Severity: normal CC: brendan.zagaeski, chrisntr, david.britch, david.hathaway, dominic, earchambault, jeremyginn, joe, john.miller, larry, luis.aguilera, maico2007, marcos.henrich, matt.ward, mono-bugs+monodevelop, mono-bugs+mono, oleg.demchenko, peter.collins, shrutis, sunilk
Priority: Highest    
Version: 4.2.0 (C6)   
Target Milestone: C6SR2   
Hardware: All   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Xamarin Studio Logs & Testcase

Description Kent Green [MSFT] 2015-11-20 17:36:47 UTC
Created attachment 13924 [details]
Xamarin Studio Logs & Testcase

## Overview
From this enterprise desk case:

## Description
Customer reports that Xamarin Studio throws an error that it can't find their web service. I was able to reproduce this issue in the Xamarin sample app from this guide: https://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/.

## Steps to reproduce
1. Open "Logs & Sample -> WebServices.RxNorm -> src -> WebServicesSample.sln"
2. Right click the Web References folder and select "Update Web References" 
3. A file called RxNormDBServices.wsdl is listed in the solution now, but in red text indicating it's missing or broken.
4. If you select "Update Web References" again, the following error is thrown:
> Failed to update Web Reference 'rxnav.nlm.nih.gov'
> Could not find file "/RxNormDBService.wsdl".

Removing the broken file doesn't help, the error still appears consistently when trying to do subsequent updates.

## Build information
=== Xamarin Studio ===

Version 5.10 (build 871)
Installation UUID: 8ef63a7c-1b18-40de-a334-7f78777fcb55
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

=== Xamarin.Profiler ===

Location: /Applications/XamarinProfiler.Mac.app/Contents/MacOS/XamarinProfiler.Mac

=== Apple Developer Tools ===

Xcode 7.1.1 (9081)
Build 7B1005

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 3c0ec35
Branch: master
Build date: 2015-11-12 13:05:39-0500

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/kentgreen/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.2
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 510000871
Git revision: 4e9c5abb5ffdae12ba02ac49da83f8b2011dbb88
Build date: 2015-11-12 06:02:54-05
Xamarin addins: 55007ed0e56436f385d8e26394a45be563abc7e8
Build lane: monodevelop-lion-cycle6

=== Operating System ===

Mac OS X 10.10.5
Darwin Kents-Macbook-Pro.local 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 5 Matt Ward 2015-11-21 07:22:36 UTC
*** Bug 34941 has been marked as a duplicate of this bug. ***
Comment 6 earchambault 2015-11-23 21:58:21 UTC
Is there an update on this bug.  I believe I am running into this same issue as well as missing functions for the method async.
Comment 11 Brendan Zagaeski (Xamarin Support) 2015-11-30 19:17:34 UTC
## Regression status: regression in Mono 4.2

BAD:  Mono 4.2.1 (explicit/6dd2d0d)
GOOD: Mono 4.0.5 (detached/1d8d582)

## Bad actual behavior (Mono 4.2)

1. The call to `DiscoveryClientProtocol.WriteAll()` in the test case from private Comment 9 creates a `Reference.map` [1] file that contains `filename` attributes _with_ a leading slash '/'.

> [1] test-web-service-discovery/WebServiceDiscoveryTest/bin/Debug/Reference.map

2. The incorrect `filename` attributes in 1 lead to an exception during `DiscoveryClientProtocol.ReadAll()`:
> Could not find file "/TempConvert.disco"

## Good expected behavior (Mono 4.0, .NET on Windows)

1. The call to `DiscoveryClientProtocol.WriteAll()` in the test case from private Comment 9 creates a `Reference.map` [1] file that contains `filename` attributes withOUT a leading slash '/'.

> [1] test-web-service-discovery/WebServiceDiscoveryTest/bin/Debug/Reference.map

2. The program hits NO exceptions, so it runs to completion and prints the desired output:
> TempConvert.disco
> TempConvert.wsdl

## Additional explanation

Xamarin Studio relies on Mono's implementation of `DiscoveryClientProtocol.WriteAll()` to generate the `Reference.map` file whenever adding or updating a Web Reference. The breakage observed in Xamarin Studio is caused by an underlying problem in Mono 4.2.
Comment 12 Matt Ward 2015-12-01 20:29:07 UTC
*** Bug 36440 has been marked as a duplicate of this bug. ***
Comment 15 Brendan Zagaeski (Xamarin Support) 2016-01-08 21:23:21 UTC
## Most direct workaround at the moment

To slightly extend Comment 11, the most direct workaround for this bug at the moment is to downgrade back to the Xamarin 3 versions of the Mono MDK and Xamarin Studio [1], and use those versions to add the Web Reference.

[1] https://store.xamarin.com/account/my/subscription/downloads#xamarin3

(Another possible workaround is to use Visual Studio on Windows to add the reference.)
Comment 16 Matt Ward 2016-01-28 09:47:31 UTC
*** Bug 38108 has been marked as a duplicate of this bug. ***
Comment 17 marcos.henrich 2016-01-30 12:40:56 UTC
Matt thanks for the neat use case.

The issue was caused by a method in reference sources that was hardcoded to windows directory separators.

It should be fixed by the following pull requests.
https://github.com/mono/mono/pull/2548 (master)
https://github.com/mono/mono/pull/2549 (cycle6)
Comment 18 Lluis Sanchez 2016-02-02 13:54:46 UTC
Please make sure the fix is included in the 4.3 branch.
Comment 19 Joseph Hanna 2016-02-10 12:55:37 UTC
This is still happening in Mono 4.3.0 (mono-4.3.1-branch/37d269c) (64-bit).
Comment 20 Joseph Hanna 2016-02-10 13:49:36 UTC
The Reference.map adds a preceding slash before the wsdl filename.  
e.g.  filename="/iscala.wsdl"

This should simply be:  filename="iscala.wsdl".

If I manually edit the map file to remove the preceding slash, I get these results when I choose "Update Web Reference" from Xamarin Studio:-

XS 5.10.1 (build 6):  The web reference updates without error, however, the preceding slash returns and a file *reference* is added to the project root folder for the wsdl, yet the file does not exist there and it must be manually removed.  Here is the Web Reference section of the csproj file.  Note the incorrect path to the wsdl:

    <None Include="Info.plist" />
    <None Include="Entitlements.plist" />
    <None Include="packages.config" />
    <None Include="Web References\iScalaWebService\Reference.map">
    <None Include="..\..\..\..\..\..\..\iscala.wsdl" />

XS 6 (build 3668): Nothing is updated and I get a dialog error:  "Failed to update Web Reference 'iScalaWebService'" : "Operation not supported in the background thread"
Comment 21 marcos.henrich 2016-02-15 13:04:11 UTC
The fix is in mono/referencesource, so it requires a bump in mono submodule external/referencesource.

Fixed in mono/master 7ecd89abdbacd5c7ace69f63ca73a6bee6a10ca6.

Fixed in mono-4.3.2-branch 1eb169d3f6fce321b25a0ce142d35bc4903ba01b.

Not fixed in mono 4.2.0, pending approval of https://github.com/mono/referencesource/pull/24
Comment 22 Matt Ward 2016-02-19 20:29:33 UTC
*** Bug 38923 has been marked as a duplicate of this bug. ***
Comment 23 Shruti 2016-03-04 09:05:19 UTC
Reproduce Status:
I am able to reproduce this issue by following steps mentioned in comment(0). Getting  "Failed to update Web Reference 'rxnav.nlm.nih.gov' > Could not find file "/RxNormDBService.wsdl". " after updating web references.

Screencast : http://www.screencast.com/t/wKbK7gPz

Verified Status:

This issue is fixed with MonoFramework-MDK- I again unzip the attached project and followed steps  as mentioned in comment(0). Now, I did not get any error after updating web References.

Screencast: http://www.screencast.com/t/SYMA0OpNyKQR
Environment Info: https://gist.github.com/shrutis360/927866045d0cdccadc44

Note: This issue is in "IN_Progress" status whether it is working fine on Mono 

Please update the "Status" so that I can change the status as verified.
Comment 24 marcos.henrich 2016-03-04 11:05:00 UTC
Fixed in mono-4.2.0-branch 59eac64fcf277acada9cd7f30cb15a55ee064e05

The fix is now also included in C6 branch, thus I am marking this as fixed.
Comment 25 Adrian Salazar 2016-03-09 14:21:28 UTC
Now works correctly with the latest update.
Thank you.