Forum Xamarin.Android

Updating Xamarin broke the build process (The process cannot access the file "appName.dll.mdb")

AsserMaanyAsserMaany EGMember ✭✭
edited February 2015 in Xamarin.Android

I'm facing this error after updating Xamarin to the latest version today (12-2-2014) and there is no solution except closing and opening VS each time I want to run the app and this is unbearable !

Error 447 The last access/last write time on file "bin\Debug\appName.dll.mdb" cannot be set. The process cannot access the file 'C:\Users\ahmedkamal\Source\appName\bin\Debug\appName.dll.mdb' because it is being used by another process

The bug was posted to bugzilla by another developer too.

What can be done to downgrade Xamarin at least if there is no fix for this bug ?



  • OlafBarteltOlafBartelt DEMember ✭✭

    Have the same problem too :-(

  • CheesebaronCheesebaron DKInsider, University mod

    Try delete the bin and obj folder and retry.

  • @Cheesebaron That's not possible. I have the same issue here. When trying to delete the bin and obj folder an alert is raised which says the folder is in use. Does anyone have a solution?

  • Thomas.4828Thomas.4828 USMember

    Have the same problem!

  • OlafBarteltOlafBartelt DEMember ✭✭

    Just got notified about a new stable update and installed it, but the problem remains. I have to completely close VS and re-open it after every build :-(

  • Thomas.4828Thomas.4828 USMember

    For some reason my build process start working again.
    The following are the steps I did:
    1. After installing the notified update (which is for Xamarin.iOS so it should be unrelated to this issue).
    2. I opened visual studio and run my android app. App runs at this point, then stop debugging.
    3. Then I decided to run Xamarin Studio and open my solution.
    4. I run the android app from XS and I got the "The process cannot..." error, because my visual studio still running.
    5. I closed VS.
    6. Run the android app again in XS and at this time the app runs.
    7. Stopped debugging and run again and the app still runs plus I don't get the "The process cannot..." error anymore.
    8. So I opened again VS and run my android app couple of times, since then I don't get the "The process cannot..." error anymore.

    I don't know what's going on but at least I can debug now in VS.

  • PetrAntosPetrAntos CZMember

    I am confirming that latest Tomas recipe solved me this issue too. Many thanks!
    Additionally, I compared the files after opening solution in XamarinStudio - most important thing is probably that XS removed my AndroidUseSharedRuntime="true" tag from "*.Droid.csproj", but it also replaced VS2013 to VS2012 in SLN as default (I have both now; when you change here back to "# Visual Studio 2013" it stays here then). By adding *.userprefs to git/svn ignore, it seems we have fully two-way solution for VS2013 and XS, which also changes in some *.csproj "Project ToolsVersion="12.0" to "4.0" but VS doesnt complain - consequences??
    ( Truth is, that bin\debug*.dll.mdb is still present after "Clean" in XS or VS )

  • OlafBarteltOlafBartelt DEMember ✭✭

    Doesn't work for me. App builds and runs fine in Xamarin Studio, then once again in Visual Studio, but then the file is locked again :-(

  • OlafBarteltOlafBartelt DEMember ✭✭

    I've taken a look with Process Explorer, and the mdb file is indeed still open in devenv.exe. If I close the handle in Process Explorer, I can build just fine (one time). Since I didn't install any updates to Visual Studio, the problem must be in Xamarin.Android.

  • ThomasWeidmanThomasWeidman USMember, Beta

    I was able to work around this by using handle.exe and removing the lock from the console.

    Handle can be obtained from:

    Then use "handle " to get the hex number and pid so you can then execute "handle -c -p ".

    So far after I do this once the lock is removed for subsequent builds.

  • OlafBarteltOlafBartelt DEMember ✭✭

    That'd be the same as I did with Process Explorer, just done by command line. Great it works for you, but for me, I have to do this over and over again after every build :-(

  • AsserMaanyAsserMaany EGMember ✭✭

    I only removed the updated and returned back to the latest stable version. This was enough for me. I will try your solutions if I faced it again. Thanks a lot.

  • FlorianoLFlorianoL USMember ✭✭

    Same error here and it is VERY VERY annoying.
    I am wasting a lot of time restarting every time VS and this is not acceptable for all those people that are actually paying a lot of money. We need at least a workaround as soon as possible because the business does not wait.

    Thank you

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    Same problem (Android AND iOS-Emulator) and a lot more...

    See also here:

  • FlorianoLFlorianoL USMember ✭✭

    Any update ? this issue is getting really frustrating. Neither the downgrade was useful.

  • DanieleDaviDanieleDavi USMember

    Thanks to falken clarity this "removed my AndroidUseSharedRuntime="true" tag from "*.Droid.csproj" " worked for me.

  • PhilipGruebelePhilipGruebele USMember ✭✭

    Same problem here. At first I thought it was some other VS extension causing it, but after removing all extensions the problem still persists.

  • KakeKake USMember ✭✭

    +1 Same issue. It's annoying to restart VS before each debug deploy..

  • hobeauhobeau USMember

    I am having the same problem. Any workarounds?

  • KertzKertz USMember

    make sure to clean the project first anytime you need to build it. that worked for me.

  • rmevans9rmevans9 USMember
    edited April 2015

    Here is a small console application I wrote that I then added to my pre-build events for my android application that calls handle to "cleanup" the issue anytime I try and debug. You just need to pass the name of the mdb as a argument AND have the handle.exe in the same directory as this executable. NOTE: I wrote this in about 5 minutes so I do not guarantee the results... run at your own risk.

    class Program
            public static string AssemblyDirectory
                    string codeBase = Assembly.GetExecutingAssembly().CodeBase;
                    UriBuilder uri = new UriBuilder(codeBase);
                    string path = Uri.UnescapeDataString(uri.Path);
                    return Path.GetDirectoryName(path);
            static void Main(string[] args)
                    var filePath = args[0];
                    Process handleProcess = new Process();
                    handleProcess.StartInfo.WorkingDirectory = AssemblyDirectory;
                    handleProcess.StartInfo.FileName = "Handle.exe";
                    handleProcess.StartInfo.Arguments = filePath;
                    handleProcess.StartInfo.UseShellExecute = false;
                    handleProcess.StartInfo.RedirectStandardOutput = true;
                    var output = handleProcess.StandardOutput.ReadToEnd();
                    var pidIdx = output.IndexOf("pid: ", StringComparison.Ordinal) + 5;
                    var handleIdx = output.IndexOf("type: File", StringComparison.Ordinal) + 10;
                    var pid = output.Substring(pidIdx, output.IndexOf(" ", pidIdx, StringComparison.Ordinal) - pidIdx);
                    var handle = output.Substring(handleIdx,
                        output.IndexOf(":", handleIdx, StringComparison.Ordinal) - handleIdx);
                    handleProcess.StartInfo.Arguments = string.Format("-c {0} -y -p {1}", handle, pid);
                    // Do nothing... We are likely in here because we couldn't find the handle!
                        "Something went wrong... run handle manually to make sure everything is as you expect it.");
  • Right click on your project --> Properties

    Under "Android Options" uncheck the box "Use Shared Runtime"

  • BobPfingstenBobPfingsten USMember, University

    I also have the same issue. Xamarin all these solutions are hacks to fix an issue you should be fixing. Any progress on getting this identified and fixed. Its very annoying!

  • ScottSmith.8058ScottSmith.8058 USMember, University

    Has anyone heard from Xamarin regarding a "REAL" fix for this issue? It has come and gone for me for months now. And it is back. I am running 3.11.590. It is locking the .dlll for my PCL in a Xamarin.Forms project. I have to shut VS down and re-open every time. This is unacceptable for a product which costs as much as Xamarin does.

  • rogiheerogihee NLMember ✭✭✭
    edited June 2015

    Experiencing this again in the stable and alpha channell too..

    If I restart Visual Studio and try again it hangs VS indefenitely at "Packaging Application".

  • TimothyLeeRussellTimothyLeeRussell USMember ✭✭

    Me too.

    This is happening again with the latest from the Alpha channel as of 6/13/2015.

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    @ScottSmith, @rogihee, @TimothyLeeRussell:

    I work with 3.11.586 and don't have this problem (but still various other and one more "evergreen" -> VS hangs, when a resource is added in Android -> therefore a workaround is described in my thread).

    You can find my findings here:

    So.. I suggest you to downgrade, if possible and you can live with problems to .586 (see my thread).

    I think, the most of us have gave up to post the problems to the "official threads" (as it - unfortunately - seems to do not help).
    Nevertheless you should post a short message to the "official thread" to your version (if only to prevent other users, to do the update :smirk:)


  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    @BobPfingsten, @ScottSmith.8058, @rogihee, @TimothyLeeRussell:

    As I wrote in my posting, I don't had this problem with 3.11.586.
    Before a while, I had to update to 3.11.836.0 (to prepare - hopefully :smirk: - my iOS app for the iOS 9 Update).
    The new version for the iOS-App is uploaded for Apple review already.
    Now, I want to update also my Android app and... yes.. the evergreen is back! :angry:
    If I try to Publish the Android app (Release configuration), I can't as some DLL's (I can see Json.dll) are "in use by another process"...
    Close VS and restart don't help...

    Just annnoyinggg!

    Have you found a workaround in the meantime...?

    Or can somebody say, that he don't have the problem in the latest 3.11.894 ?
    => I can't see that it should be re-solved in the release notes...

    Thanks for a short feedback :sunglasses:

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    @BobPfingsten, @ScottSmith.8058, @rogihee, @TimothyLeeRussell:
    I have found a (bad) workaround myself.
    Close VS
    delete all files in the folder ...(AppName).Android\bin\Release\
    Start VS
    Deploy (seems to work one time)

    I further have posted am message in the "How to make Forms stable" thread:

    But it seems, as the thread don't pop's anymore, if a message is added...
    This is also a (really bad) way, to keep the criticism of the customer's under the blanket

  • JohnHardmanJohnHardman GBUniversity admin
    edited September 2015

    I have just upgraded, and have hit this same problem.

    Unable to copy file
    to "bin\Debug\Xamarin.Forms.Core.dll".
    The process cannot access the file
    because it is being used by another process.

    Yet another day completed wasted by Xamarin not testing their stuff properly before putting on the stable channel. I'd far rather they sorted out their quality and release processes rather than make the big fanfare about 0 day support for new stuff. I REALLY don't care about 0 day support. I want a predictable, reliable system to work on.

    I am just hoping that iOS is working, because right now, everything else is completely stuffed. Keeping fingers crossed for iOS, but as I was doing the upgrade in the hope of fixing an existing Xamarin iOS problem that prevented me working on iOS, I really don't hold out much hope.

    [Note added later: It didn't matter how many times I cleaned the solution/project, this kept on happening. Re-starting VS and re-starting the box didn't resolve it either. However, going in manually and deleting the bin directory seems to have worked. I have re-built a few times since without issue. Still not happy though at having to waste time on stuff like this]

  • JohnHardmanJohnHardman GBUniversity admin
    edited September 2015


  • giangnamtrangiangnamtran USMember
    edited October 2015

    NEW RELEASE XAMARIN FOR STUDIO 4.0(Alpha version) ==> Happy or Unhappy Notification???

    I have just found and tested this version for fix big bug "Could not copy .DLLs".
    Considering by link:

    I tested again on my project with:
    Microsoft Visual Studio Community 2015
    Xamarin (5abb0de)
    iOS SDK 8.4.
    => Result:
    The bug "Bug 31423 - [XVS] Locked .dll files: Could not copy "... PortableClassLibrary1.dll" to "bin\Debug\PortableClassLibrary1.dll". Exceeded retry count of 10. Failed." was fixed( on XVS alpha version

    => But, it's occurred other bugs:

    • You cannot "Clean Solution" your solution. If you clean your solution, it will occur the bug before "Bug 31423"(Because the .DLLs do not clean and Visual Studio will lock some your .DLLs).

    Good luck!. :cold_sweat:

  • DeanPodgornikDeanPodgornik USMember ✭✭

    Solved the problem as Thomas.4828 said:

    • Open the solution in XamarinStudion and deploy it to the Android phone
    • Close the XamarinStudio
    • Open the solution in VisualStudio and deploy it to Android Phone
      From now on, it should work.
  • DirkSDirkS DEMember

    I encountered this problem today on the iOS project of a xamarin.forms

    The file myProject/myProject.iOS/bin/iPhone/Debug/somePcl.dll was not released,
    so subsequent builds failed because the file couldn't be copied there.

    After shutting down VS and deleting the file I was only able build one time.

    A longer-lasting solution for me was to MOVE the file to a different Folder.
    The moved file remained unreleased, but copying to the original folder worked
    now, so building succeeded - and more than once.

  • PhilipOGormanPhilipOGorman USMember ✭✭✭

    Came across this this morning - built the solution in XS first, then it worked in VS

  • I used to get this message quite alot, I have since set my concurrent build number to 1 and the problem has not yet recurred.

    This option is in Tools > Options > Projects and Solutions > Build and Run

    Set the option "Maximum Number of Parallel projects to build" to 1 and see if it works. If not, you can always set it back

  • Happened to me too, just building a stupid C# console app to aid in testing. (Did I mention it's about impossible to debug unittests?) Couldn't even delete the executable after a reboot. Required a program called Unlocker to be able break the little mofo's deathgrip on the system, and it still requires a reboot to finish the job. Not cool. v5.10.1, Windows 10

  • Try cleaning all the projects, solution and build it again. It worked for me.

  • UdaraAlwisUdaraAlwis LKMember ✭✭✭

    I have been having this same messed up issue where my DLL were locked. What I did was,

    1. Close Visual Studio
    2. deleting all the files in the bin\Debug folder
    3. delete the .suo file
    4. open Visual Studio in Administrator mode

    Well that worked for me after wasting almost two hours... /(-_-)\

  • DeanPodgornikDeanPodgornik USMember ✭✭
    edited January 2016

    Udara Alwis-s solution is also working. Tnx.> @UdaraAlwis said:

    I have been having this same messed up issue where my DLL were locked. What I did was,

    1. Close Visual Studio
    2. deleting all the files in the bin\Debug folder
    3. delete the .suo file
    4. open Visual Studio in Administrator mode

    Well that worked for me after wasting almost two hours... /(-_-)\

Sign In or Register to comment.