Bug 10693 - Can not build release after adding a web service mscorlib error
Summary: Can not build release after adding a web service mscorlib error
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.3.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
: 12708 ()
Depends on:
Reported: 2013-02-26 12:55 UTC by Tracy
Modified: 2013-06-21 14:15 UTC (History)
7 users (show)

Is this bug a regression?: ---
Last known good build:

Xamarin Error Message (275.72 KB, image/jpeg)
2013-06-21 12:01 UTC, Tracy
Visual Studio setting (255.67 KB, image/jpeg)
2013-06-21 12:02 UTC, Tracy

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description Tracy 2013-02-26 12:55:27 UTC
Could not load file or assembly 'mscorlib, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)

This happens on any new project once I add a reference to a web service and try to build in release mode.

After a few searches this appears to be an old issue that had at one point been taken care of.
It now appears to be back.

From what I was able to find out you have to turn off "Generate serialization assembly".
The problem is that there does not appear to be a way to do this in Xamarin Studio.
I had to open my project in VS and do it, then open it back up in Xamarin Studio.

I dont know how I would have done this if I didn't have VS installed.
Comment 1 Tracy 2013-03-12 11:37:39 UTC
Any progress on this?
It has been two weeks with out any notice on here.
With the new licensing and the Indie developers not having access to the Visual Studio this makes it impossible to compile into release.

Comment 2 Mikayla Hutchinson [MSFT] 2013-03-12 18:31:50 UTC
The Xamarin.Android build targets should suppress this build feature if it won't work with XA mscorlib.
Comment 3 Tracy 2013-03-13 10:47:58 UTC
Should and do are two totally different things.
I need some kind of resolution on this.
I can not build to release after adding a web service if I do not first pull it into VS and change the "Generate Serialization Assembly" and do a build there.

Once I do that, then I can open it back up in Xamarin Studio and build the release with no problems.

While this is only a inconvienince at work, I only have the Indie license at home and will need to be able to build release products there.

Comment 4 Tracy 2013-03-28 10:02:15 UTC
Any progress on this.
I just updated to 4.0.3 and made a new project.
And when it comes time to build the release I get this lovely error.
Now I have to open it up in Visual Studio and disable the Generate Serialization Assembly.
This is more than just an annoyance.
Can we get some kind of response on this?

Comment 5 Tracy 2013-04-03 16:26:11 UTC
This has been up here for 5 weeks and has no progress has been recorded.
Can someone please give me an update.
This bug makes Xamarin Studio unusable as a stand alone IDE.
Comment 6 Alan McGovern 2013-04-16 16:49:34 UTC
Is this something to do with the strongnaming of our binaries.
Comment 8 Atsushi Eno 2013-04-16 17:15:10 UTC
Actually no... And since Generate Serialization Assemblies is only about VS's desktop target profiles and NOT applicable to Xamarin products, it should rather be explicitly denied as mhutch said. I have no idea if it's doable in VS though. People should have never tried such web references in Silverlight, so the same principle should apply Xamarin mobile profile.

Resolution to this should be: any serialization should be done by NOT using generated serializer as DLL. Or with Mono's sgen --keep it is able to generate sources for generated serializer but not as precompiled state (you have to copy sources from some temporary directory).
Comment 9 Tracy 2013-04-16 17:23:13 UTC
So will I not be able to add .net 2.0 Web services?
Is it not as simple of just turning off that build feature like I do when I open it up in VS?
I know I should probably switch to JSON, but I have several Soap services that are already running that our other apps are using.
I don't want to rewrite all of those...
Comment 10 Atsushi Eno 2013-04-16 17:34:39 UTC
What I wrote (sgen) is how to use Sys.Web.Services code. http://msdn.microsoft.com/en-us/library/bk3w6240%28v=vs.80%29.aspx
Comment 11 Jonathan Pryor 2013-04-24 11:36:15 UTC
After some followup, here's the issue + reproduction steps:

0. Run Windows. This doesn't happen on OSX.
1. Launch Xamarin Studio 4.0.3.
2. File > New > Solution...
3. Create an Android Application project.
4. In the Solution panel, right-click the Project > Add > Add Web Reference.
5. In the Add Web Reference dialog, keep the default Web Service Url
5.b. Set the Framework to .NET 2.0 Web Service
6. In the Add Web Reference dialog, Click OK.
7. Build. Build should succeed.
8. Set the Configuration to Release (Project > Active Configuration > Release)
9. Build

Expected results: It builds!

Actual results: 

> SGEN: Error: Could not load file or assembly 'mscorlib, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'
> or one of its dependencies. Strong name validation failed.
> (Exception from HRESULT: 0x8013141A) (Bxc10693.DefWebService)

Workaround 1:

1. Open the .csproj within Visual Studio
2. Click Project > ProjectName Properties...
3. In the Build tab, set the Generate serialization assembly drop-down to Off.
4. Save all.

The Project will now build within Xamarin Studio.

Workaround 2:

1. Manually edit the .csproj.
1.b. This can be done within Xamarin Studio by right-clicking the Solution name in the solution panel > Display Options > Show All Files, then double-clicking the .csproj in the Solution panel.

2. Add the following XML fragment to the first <PropertyGroup/> section:


3. Close and re-open the solution.
Comment 12 Jonathan Pryor 2013-04-24 12:04:37 UTC
Fixed in monodroid/3dc81e91 by updating Xamarin.Android.Common.targets to specify:


This should implicitly fix things for all Xamarin Studio versions, though the fix won't be included until the n ext Xamarin.Android 4.7.x beta.
Comment 13 Jonathan Pryor 2013-06-16 19:01:42 UTC
*** Bug 12708 has been marked as a duplicate of this bug. ***
Comment 14 Tracy 2013-06-17 11:15:50 UTC
I hate to say, but this is not fixed yet.
I just went to build a new project and got the same issue.
I opened the project up in VS to do the work around and found that it already said no in the generate serialization assemblies.
I tried to build in VS with no luck. So I changed it back to auto and tried a build, it failed, then I switched it back to no again and this time it built.
I was then able to open and build in Xamarin studio again.

So it appears that there is more that just that single flag involved.
I had to change it away from then back to no to get it to build.

Please help!

Comment 15 Jonathan Pryor 2013-06-17 14:15:14 UTC
> I just went to build a new project and got the same issue.

A new project using which Xamarin.Android version? It wasn't fixed until 4.7.5 and 4.6.7.

Comment 16 Tracy 2013-06-21 12:01:06 UTC
I just updated to 4.7.9 and the problem still exists.
1. Open a brand new android project
2. Add .Net 2.0 Web Reference
3. Build as debug. Everything is Fine
4. Build as release. Get the error.
This is what you will see in screen shot 1.

What is different now is that if you open it up in VS it shows that the generate serialization assemblies is set to off, but it will not build their either. (screen shot 2).

If I change it to auto, try to build, then change it back to NO, it will then build and I can open it back up in Xamarin and continue.
Comment 17 Tracy 2013-06-21 12:01:39 UTC
Created attachment 4174 [details]
Xamarin Error Message
Comment 18 Tracy 2013-06-21 12:02:09 UTC
Created attachment 4175 [details]
Visual Studio setting
Comment 19 Jonathan Pryor 2013-06-21 14:15:33 UTC
I had the include order wrong; <GenerateSerializationAssemblies/> needs to be specified within Xamarin.Android.CSharp.targets, as Xamarin.Android.Common.targets is too late.

Fixed in master/f6ed53bb for 4.7.11 and bs1/f8ee257d for 4.6.10.