Bug 34262 - System.BadImageFormatException on build during "ConvertPdbToMdb" task when source code is hosted on a Mac
Summary: System.BadImageFormatException on build during "ConvertPdbToMdb" task when so...
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: General ()
Version: 3.11 (C5)
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-09-24 20:29 UTC by Jon Goldberger [MSFT]
Modified: 2016-05-18 19:20 UTC (History)
3 users (show)

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


Attachments
Logs (51.08 KB, application/zip)
2015-09-24 20:29 UTC, Jon Goldberger [MSFT]
Details


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 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:
Status:
RESOLVED NOT_ON_ROADMAP

Description Jon Goldberger [MSFT] 2015-09-24 20:29:00 UTC
Created attachment 13066 [details]
Logs

## Description

This issue only occurs when the source code is on the Mac build host and accessed from VS over the network. This occurs both in a Windows VM hosted on the Mac or with a separate physical Windows PC. I have not been able to reproduce the issue myself reproducing the customer's environment as best as possible. Customer's basic environment is Windows 10 using Visual Studio 2013 Update 5. Normally they use a Windows 10 VM hosted on the Mac build host, but have tested with a separate PC as well, with same basic environment. Issue occurred under all circumstances when source was on the Mac build host. But not if the same source was on the PC itself, whether VM or physical. Also no issues building with XS on Mac. 


## Reported steps to reproduce:

Note: You will need to have a folder on the Mac that is shared to Windows and mapped to a drive letter or accessed through the Network share section of File explorer. 

1. Create a simple single app project (iOS) within VS2013 - ensuring that project/solution resides
on your HOME folder within your MAC machine.

2. I have used this location :

Y:\Xamarin Projects

Which maps to (HOME on MAC)

Macintosh HD:Users:[USERNAMEHERE]:Xamarin Projects
i.e
\Users\[USER NAME HERE]\Xamarin Projects


3. When you create this project, if we examine the log file created in :

C:\Users\YOUR NAME HERE\AppData\Local\Xamarin\Log\YOUR VS VERSION

We will see an error in the log file :

Xamarin.VisualStudio.TastyFlavoredProject Error: 0 : [2015-09-16 15:55:41.0] Could not add project to the startup list
System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at EnvDTE.Project.get_UniqueName()
at Clide.Solution.Adapters.DteToSolutionAdapter.Adapt(Project from)
at lambda_method(Closure , IAdapter , Object )
at Clide.Patterns.Adapter.AdapterService.Adapt[TSource,TTarget](TSource source)
at Clide.Patterns.Adapter.AdapterService.Adaptable`1.As[T]()
at Xamarin.VisualStudio.TastyFlavoredProject.AddToStartupList()
Xamarin.VisualStudio.TastyFlavoredProject Error: 0 : [2015-09-16 15:55:41.5] Could not add project to the startup list
System.NullReferenceException: Object reference not set to an instance of an object.
at Clide.Solution.Implementation.VsSolutionHierarchyNode.<.ctor>b__2()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at Clide.Solution.Implementation.VsSolutionHierarchyNode.get_Parent()
at Clide.Solution.Implementation.SolutionExplorerNodeFactory.<>c__DisplayClass8.<CreateNode>b__6(IVsSolutionHierarchyNode hierarchy)
at Clide.Solution.Implementation.SolutionExplorerNodeFactory.<>c__DisplayClass8.<CreateNode>b__5(IVsSolutionHierarchyNode hierarchy)
at Clide.Solution.Implementation.SolutionExplorerNodeFactory.CreateNode(IVsSolutionHierarchyNode hierarchyNode)
at Clide.Solution.Implementation.SolutionExplorerNodeFactory.<>c__DisplayClass3.<Create>b__2(Tuple`2 _)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Clide.Solution.Implementation.SolutionExplorerNodeFactory.Create(IVsSolutionHierarchyNode hierarchyNode)
at Clide.Solution.Adapters.DteToSolutionAdapter.Adapt(Project from)
at lambda_method(Closure , IAdapter , Object )
at Clide.Patterns.Adapter.AdapterService.Adapt[TSource,TTarget](TSource source)
at Clide.Patterns.Adapter.AdapterService.Adaptable`1.As[T]()
at Xamarin.VisualStudio.TastyFlavoredProject.AddToStartupList()



4. Now Try and build the application, following error is displayed within VS (Nothing is shown in the Log file regarding this error):


>Error 1 The "ConvertPdbToMdb" task failed unexpectedly.
>System.BadImageFormatException: Y:\Xamarin Projects\App1\App1\bin\iPhoneSimulator\Debug\App1.exe ---> System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
>at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
>at System.IO.BinaryReader.ReadUInt16()
>at Mono.Cecil.PE.ImageReader.ReadImage() in c:\w\f10676fe\XamarinVS\External\cecil\Mono.Cecil.PE\ImageReader.cs:line 75
>at Mono.Cecil.PE.ImageReader.ReadImageFrom(Stream stream) in c:\w\f10676fe\XamarinVS\External\cecil\Mono.Cecil.PE\ImageReader.cs:line 674
>at Mono.Cecil.PE.ImageReader.ReadImageFrom(Stream stream) in c:\w\f10676fe\XamarinVS\External\cecil\Mono.Cecil.PE\ImageReader.cs:line 677
>at Mono.Cecil.ModuleDefinition.ReadModule(Stream stream, ReaderParameters parameters) in c:\w\f10676fe\XamarinVS\External\cecil\Mono.Cecil\ModuleDefinition.cs:line 919
>at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) in c:\w\f10676fe\XamarinVS\External\cecil\Mono.Cecil\ModuleDefinition.cs:line 903
>at Pdb2Mdb.Converter.Convert(String filename) in c:\w\f10676fe\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\Driver.cs:line 31
>at Xamarin.iOS.Tasks.ConvertPdbToMdb.Execute() in c:\w\f10676fe\XamarinVS\msbuild\Xamarin.iOS.Tasks\Tasks\ConvertPdbToMdbTask.cs:line 32
>at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
>at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() App1

## Their Environment (Last I checked)

Microsoft Visual Studio Ultimate 2013
Version 12.0.40629.00 Update 5
Microsoft .NET Framework
Version 4.6.00079

Installed Version: Ultimate

Architecture and Modeling Tools   06181-004-0451047-02371
Microsoft Architecture and Modeling Tools
    
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

LightSwitch for Visual Studio 2013   06181-004-0451047-02371
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06181-004-0451047-02371
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06181-004-0451047-02371
Microsoft Visual Basic 2013

Visual C# 2013   06181-004-0451047-02371
Microsoft Visual C# 2013

Visual F# 2013   06181-004-0451047-02371
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06181-004-0451047-02371
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06181-004-0451047-02371
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.5.60612.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Web Apps
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.30612.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.4
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone
Build 

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

NuGet Package Manager   2.8.60610.756
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SyncfusionItemTemplates   1.0
Information about my package

Xamarin   3.11.837.0 (f10676f)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.5.3 (f98871a95a479f6d71b3067b7e5834d41fcb2118)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS   8.10.4.0 (6db87c53c073f4af2f5247fb738a27ea08c094fd)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 1 Daniel Cazzulino 2016-05-18 19:20:29 UTC
This is an unsupported configuration, just like it is for the reverse (XS compiling source living on a network share).