Pdb2Mdb.Converter throws error saying .dll.mdb file does not exist when building

When I attempt to build my android in Visual Studio, I'm getting a build error saying "The file "....dll.mdb" does not exist. The output windows contains the below trace. Note that I've tried deleting my .suo file, cleaning and rebuilding, but none of this has helped. Any ideas what the root cause is and how to fix it?

2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1552,2): warning : Unknown custom metadata item kind: 7
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1552,2): warning : at Microsoft.Cci.Pdb.PdbFunction.ReadCustomMetadata(BitAccess bits)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1552,2): warning : at Microsoft.Cci.Pdb.PdbFunction..ctor(String module, ManProcSym proc, BitAccess bits)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1552,2): warning : at Microsoft.Cci.Pdb.PdbFunction.LoadManagedFunctions(String module, BitAccess bits, UInt32 limit, Boolean readStrings)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1552,2): warning : at Microsoft.Cci.Pdb.PdbFile.LoadFuncsFromDbiModule(BitAccess bits, DbiModuleInfo info, IntHashTable names, ArrayList funcList, Boolean readStrings, MsfDirectory dir, Dictionary`2 nameIndex, PdbReader reader)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1552,2): warning : at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, BitAccess bits, Boolean readAllStrings)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1552,2): warning : at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, Boolean readAllStrings)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1552,2): warning : at Pdb2Mdb.Converter.Convert(String filename)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1552,2): warning : at Xamarin.Android.Tasks.ConvertDebuggingFiles.Execute()

Tagged:

Posts

  • BrendanZagaeskiBrendanZagaeski Xamurai USForum Administrator, Xamarin Team Xamurai

    I was working on this same error with another user via email support, so I will update this forum thread with what I found.

    It turns out this is related to VS 2015 & C# 6 features. The version of pdb2mdb that is currently shipped in the stable version of XamarinVS has not yet been updated for final compatibility with these versions of VS and C#.

    A few possibilities to get VS 2015 & C# 6 working:

    1. The XamarinVS team has an updated version of pdb2mdb prepared for preview release in the near future (roughly 1-2 weeks or sooner). If you have a way to proceed for a little while without a fix, then waiting for that fix would be one simple option.

    2. As a temporary partial workaround, you could skip the ConvertPdbToMdb task completely. This will unfortunately limit you to Console.WriteLine() debugging (no breakpoints, single-stepping, etc.), but it might be good enough as a temporary solution until the updated XamarinVS version is available.

      To disable the ConvertPdbToMdb task completely, delete the following line from C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.After.targets:

      <ConvertPdbToMdb Assemblies="@(_Assemblies)" />
      
    3. In theory I think it would be possible to replace the ConvertPdbToMdb task with a custom Task (or probably even just a custom Target that uses the Exec Task). The idea would be to use the newer pdb2mdb.exe that's included in the Mono for Mac installer [1] instead of the built-in Pdb2Mdb in XamarinVS.iOS. This would allow you to generate the MDB files as needed, but it would require a fair bit of familiarity with MSBuild Targets and Tasks.

      [1] You'd need to copy the following 3 files from the Mono 4.0 Mac installation to a folder on Windows:

      • /Library/Frameworks/Mono.framework/Versions/4.0.0/lib/mono/gac/Mono.CompilerServices.SymbolWriter/4.0.0.0__0738eb9f132ed756/Mono.CompilerServices.SymbolWriter.dll

      • /Library/Frameworks/Mono.framework/Versions/4.0.0/lib/mono/gac/Mono.Cecil/0.9.5.0__0738eb9f132ed756/Mono.Cecil.dll

      • /Library/Frameworks/Mono.framework/Versions/4.0.0/lib/mono/4.5/pdb2mdb.exe

  • DennisRocheDennisRoche USMember, University
    edited May 2015

    @BrendanZagaeski

    I took option #3 and implemented a replacement task, using the mono/4.5/pdb2mdb.exe copied from the Mac.

    The .target file is:

    <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
        <Target Name="_ConvertDebuggingFiles" DependsOnTargets="_CollectAssemblies"
                        Inputs="@(_Assemblies)"
                        Outputs="@(_Assemblies -> '%(FullPath).mdb')"
                        BeforeTargets="_CompileToNative">
    
          <ItemGroup>
              <_ConvertAssemblies Include="@(_Assemblies)"/>
          </ItemGroup>
    
          <Warning Text="Using workaround for pdb2mdb conversion. See: https://forums.xamarin.com/discussion/37739/pdb2mdb-converter-throws-error-saying-dll-mdb-file-does-not-exist-when-building for details."/>
          <Exec Command="$(MSBuildThisFileDirectory)pdb2mdb.exe '%(_ConvertAssemblies.Identity)'" IgnoreExitCode="true" />
    
        </Target>
    </Project>
    

    To use, add this target to your App.iOS.csproj after the Xamarin targets (i.e. so that it overrides the target).

    <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
    <Import Project="..\..\Xamarin.Pdb2Mdb\Xamarin.iOS.Common.After_Pdb2Mdb.targets" />
    

    Unfortunately, I still wasn't able to get it working. The pdb2mdb.exe always exits with exit code 1. Reflecting the executable, it isn't clear where it is failing.

    UPDATE Further reflecting, I found that the Xamarin task is skipping several of the assemblies if it is a FrameWorkItem (Xamarin.VisualStudio.Build.dll). I don't know how to identify these assemblies in MSBuild without invoking an external library, so for now I've added IgnoreExitCode="true" to the Exec task.

  • BrendanZagaeskiBrendanZagaeski Xamurai USForum Administrator, Xamarin Team Xamurai
    edited May 2015

    Many thanks for that first draft of the .targets file! After a bit of experimentation, I found that the exit code 1 was in fact because pdb2mdb doesn't like single quotes around the name of the assembly. I switched to double quotes, added some of the "Framework" filtering as you mentioned, and added the Copy Task workaround for Bug 29628. With these changes in place it now seems to work correctly. Fun :)

    <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
      <Target Name="_ConvertDebuggingFiles" DependsOnTargets="_CollectAssemblies"
                      Inputs="@(_Assemblies)"
                      Outputs="@(_Assemblies -> '%(FullPath).mdb')"
                      BeforeTargets="_CompileToNative">
    
        <ItemGroup>
          <_ConvertAssemblies Include="@(_Assemblies)"
                              Condition="'%(_Assemblies.ResolvedFrom)' != '{TargetFrameworkDirectory}' And '%(_Assemblies.ResolvedFrom)' != 'ImplicitlyExpandDesignTimeFacades' And '%(_Assemblies.FrameworkFile)' != 'true'" />
        </ItemGroup>
    
        <Warning Text="Using workaround for pdb2mdb conversion. See: https://forums.xamarin.com/discussion/37739/pdb2mdb-converter-throws-error-saying-dll-mdb-file-does-not-exist-when-building for details."/>
        <Exec Command='$(MSBuildThisFileDirectory)pdb2mdb.exe "%(_ConvertAssemblies.Identity)"' IgnoreExitCode="true" />
    
        <Copy SourceFiles="@(_ConvertAssemblies -> '%(FullPath).mdb')"
              SkipUnchangedFiles="true"
              DestinationFolder="$(OutDir)"
              Condition="Exists('%(_ConvertAssemblies.FullPath).mdb')" />
    
      </Target>
    </Project>
    

    EDIT May 03: Add Exists() condition to the Bug 29628 part of the workaround to allow non-Debug builds to succeed.

  • DennisRocheDennisRoche USMember, University

    @BrendanJanssen nice work! Thanks for the help.

  • MichaelRumplerMichaelRumpler ✭✭✭✭✭ ATMember ✭✭✭✭✭

    @BrendanZagaeski @DennisRoche

    I installed VS 2015 RC and have the same problem now.
    I copied Mono.Cecil.dll, Mono.CompilerServices.SymbolWriter.dll and pdb2mdb.exe from Dennis' zip file and https://bugzilla.xamarin.com/attachment.cgi?id=11037 all to the folder C:\Program Files (x86)\MSBuild\Xamarin\iOS.
    I also had to add references to System.Runtime and System.Threading.Tasks from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\Facades to my iOS and Android projects (I'm using Xamarin.Forms) before I could compile.

    But still I get the same error - even with line numbers:

    Error   60  The "ConvertPdbToMdb" task failed unexpectedly.
    Microsoft.Cci.Pdb.PdbDebugException: Unknown custom metadata item kind: 7
       at Microsoft.Cci.Pdb.PdbFunction.ReadCustomMetadata(BitAccess bits) in c:\w\5061f921\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\PdbFunction.cs:line 329
       at Microsoft.Cci.Pdb.PdbFunction..ctor(String module, ManProcSym proc, BitAccess bits) in c:\w\5061f921\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\PdbFunction.cs:line 251
       at Microsoft.Cci.Pdb.PdbFunction.LoadManagedFunctions(String module, BitAccess bits, UInt32 limit, Boolean readStrings) in c:\w\5061f921\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\PdbFunction.cs:line 125
       at Microsoft.Cci.Pdb.PdbFile.LoadFuncsFromDbiModule(BitAccess bits, DbiModuleInfo info, IntHashTable names, ArrayList funcList, Boolean readStrings, MsfDirectory dir, Dictionary`2 nameIndex, PdbReader reader) in c:\w\5061f921\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\PdbFile.cs:line 300
       at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, BitAccess bits, Boolean readAllStrings) in c:\w\5061f921\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\PdbFile.cs:line 398
       at Pdb2Mdb.Converter.Convert(String filename) in c:\w\5061f921\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\Driver.cs:line 37
       at Xamarin.iOS.Tasks.ConvertPdbToMdb.Execute() in c:\w\5061f921\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() RoyalMobileApps.XF.iOS
    

    The problem is, that I get this error now even in VS2013. So I cannot step back and use the old VS anymore.

    Do I have to do anything else? Unfortunately I don't know anything about MSBuild.

  • BrendanZagaeskiBrendanZagaeski Xamurai USForum Administrator, Xamarin Team Xamurai

    @MichaelRumpler, if you haven't already, you must add an <Import Project= ... line to the app project (see the earlier comment in the thread).

    The problem is, that I get this error now even in VS2013. So I cannot step back and use the old VS anymore.

    That sounds like one of the libraries has a cached build from VS 2015 still being used. If Cleaning the solution doesn't stop the problem, you can also try manually deleting the bin and obj folders in all the sub-projects, and see if that stops it.

  • OrenNovotnyOrenNovotny ✭✭ USMember, Insider, Beta, University ✭✭
    edited May 2015

    @BrendanZagaeski, any chance of getting the fix for into the alpha/beta channel very soon?

  • BrendanZagaeskiBrendanZagaeski Xamurai USForum Administrator, Xamarin Team Xamurai
    edited May 2015

    Indeed. It's on the way to the Alpha channel. It will be included in the upcoming service release, which is due out this week.

    Also, apparently if you now uninstall Xamarin and then reinstall it using the checkbox within the VS 2015 installer (rather than the Xamarin installer), that will install a special patched version of XamarinVS (3.11.450.0 (2ab5145)) that includes the fix for this particular issue. I tried this approach today using the "Change" context menu item on the VS 2015 installation in the "Programs and Features" control panel, and it seemed to do the trick.

    EDIT: Note that 3.11.450 does not yet include the fix for Bug 29628, so it's probably easiest to wait for the Alpha version of the upcoming service release.

  • MichaelRumplerMichaelRumpler ✭✭✭✭✭ ATMember ✭✭✭✭✭

    Thanks @BrendanZagaeski

    I can open, compile and deploy the solution in VS2013 after deleting all bin and obj directories.

    But VS2015 still throws the same exception.

    I added the second of those lines after the first to all iOS projects after adding it only in the startup project didn't help.

    <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
    <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.Common.After.targets" />
    

    The file Xamarin.iOS.Common.After.targets was the one you attached to bug 29628.

  • StevenTsangStevenTsang GBMember
    edited May 2015

    Latest xamarin alpha 3.11.507 seems to of fixed this bug for me but still getting bug 29628. For now I have used the workaround .target file within the bug report and everything seems to be working fine.

  • TimBurgessTimBurgess USMember, University

    I am using VS2015 RC

    when I put
    PhoneNumberText.ShouldReturn += delegate
    {
    PhoneNumberText.ResignFirstResponder();
    return true;
    };
    into

    public override void ViewDidLoad()
    {
    base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            CallButton.Enabled = false;
    
        }
    

    i get The "ConvertPdbToMdb" task failed unexpectedly, when i take it out the project builds and runs fine.

  • AndreaGiuntaAndreaGiunta ITMember

    Hi everyone.
    I get this issue with lambda expression. There is some way to solve it?

  • BrendanZagaeskiBrendanZagaeski Xamurai USForum Administrator, Xamarin Team Xamurai

    TimBurgess, AndreaGiunta, are you using 3.11.507 or higher? Note that the current Stable channel build 3.11.458 does not include the fix, so you'll want to switch to the Beta updater channel to get the fix for this issue.

  • RobSchoenakerRobSchoenaker ✭✭ NLMember ✭✭

    I just updated my Xamarin iOS for VS2013 and now I keep getting a similar error:

    Error 13 The "ConvertPdbToMdb" task failed unexpectedly.
    System.IO.IOException: The process cannot access the file 'C:\Sources\webfeud-apps\Webfeud.iOS\bin\iPhone\Debug\WebfeudiOS.exe.mdb' because it is being used by another process.
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
    at Mono.CompilerServices.SymbolWriter.MonoSymbolWriter.WriteSymbolFile(Guid guid)
    at Pdb2Mdb.Converter.Convert(AssemblyDefinition assembly, IEnumerable`1 functions, MonoSymbolWriter mdb) in c:\w\a91e30d4\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\Driver.cs:line 51
    at Pdb2Mdb.Converter.Convert(String filename) in c:\w\a91e30d4\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\Driver.cs:line 38
    at Xamarin.iOS.Tasks.ConvertPdbToMdb.Execute() in c:\w\a91e30d4\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.d__20.MoveNext() Webfeud.iOS

    This is with version 3.11.586.
    I get this error every time I try a second debugging session. Both in the simulator and on an actual device.
    The only way around it is to kill VS and restart it. This 'works' but is quite annoying... Any ideas?

  • VictorGarciaAprea.9996VictorGarciaAprea.9996 Xamurai USXamarin Team Xamurai

    Hi Rob,

    We just fixed this locking issue today.

    @BrendanZagaeski should know better than me when these bits will go public :smile:

    thanks,
    -Victor.

  • MilenPavlov.0879MilenPavlov.0879 USUniversity
    edited June 2015

    I have the same issue like @RobSchoenaker using VS 2015 + Xamarin iOS 3.11.59
    Is there a fix for this in alpha/beta channels ?

    Error       The "ConvertPdbToMdb" task failed unexpectedly.
    System.IO.IOException: The process cannot access the file 'C:\Users\milenpavlov\Documents\Appname.exe.mdb' because it is being used by another process.
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
       at Mono.CompilerServices.SymbolWriter.MonoSymbolWriter.WriteSymbolFile(Guid guid)
       at Pdb2Mdb.Converter.Convert(AssemblyDefinition assembly, IEnumerable`1 functions, MonoSymbolWriter mdb) in c:\w\5160db74\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\Driver.cs:line 51
       at Pdb2Mdb.Converter.Convert(String filename) in c:\w\5160db74\XamarinVS\msbuild\Xamarin.iOS.Tasks\Pdb2mdb\Driver.cs:line 38
       at Xamarin.iOS.Tasks.ConvertPdbToMdb.Execute() in c:\w\5160db74\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__1.MoveNext()  eTech.Mobile.iOS        
    

    The file in the specified path is locked and if you try to clean the solution it will stay (cannot be manually deleted either). You have to close Visual Studio first..

  • MilenPavlov.0879MilenPavlov.0879 USUniversity

    Update: After restarting my machine the issue is gone :)

  • MichaelRumplerMichaelRumpler ✭✭✭✭✭ ATMember ✭✭✭✭✭

    I switched to the alpha channel again when the new Xamarin.Forms came out. But now I also have the problem Rob described that the .mdb file is locked.

    The "ConvertPdbToMdb" task failed unexpectedly.
    System.IO.IOException: The process cannot access the file '...\bin\iPhone\Debug\RoyalMobileApps.XF.dll.mdb' because it is being used by another process.
    

    But for me a reboot did not fix it. I have to close VS, delete all bin+obj folders and open it again. If I'm lucky, then it will work 2-3 times before that error comes back.

    I'm using VS2013 and Xamarin 3.11.658.

    @BrendanZagaeski do you know, when the fix @VGA spoke about will go out?

Sign In or Register to comment.