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

AsserMaanyAsserMaany Asser MaanyEGMember ✭✭
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.

https://bugzilla.xamarin.com/show_bug.cgi?id=26841

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

«1

Answers

  • OlafBarteltOlafBartelt Olaf Bartelt DEMember ✭✭

    Have the same problem too :-(

  • CheesebaronCheesebaron Tomasz Cielecki DKInsider, University mod

    Try delete the bin and obj folder and retry.

  • RickNederveldRickNederveld Rick Nederveld NLMember

    @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 Thomas USMember

    Have the same problem!

  • OlafBarteltOlafBartelt Olaf Bartelt 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 Thomas 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 Petr Antos 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 Olaf Bartelt 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 Olaf Bartelt 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 Thomas Weidman 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: https://technet.microsoft.com/en-us/sysinternals/bb896655.aspx

    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 Olaf Bartelt 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 Asser Maany 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 Floriano Lippolis 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 Fredy Wenger CHInsider ✭✭✭✭✭

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

    See also here: forums.xamarin.com/discussion/comment/111471#Comment_111471

  • FlorianoLFlorianoL Floriano Lippolis USMember ✭✭

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

  • DanieleDaviDanieleDavi Daniele Davi USMember

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

  • PhilipGruebelePhilipGruebele Philip Gruebele 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 Marius N USMember ✭✭

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

  • hobeauhobeau Beau Brownlee USMember

    I am having the same problem. Any workarounds?

  • KertzKertz Ahmed Kehinde USMember

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

  • rmevans9rmevans9 Richard Evans 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
            {
                get
                {
                    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)
            {
                try
                {
                    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;
                    handleProcess.Start();
    
                    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);
                    handleProcess.Start();
                }
                catch
                {
                    // Do nothing... We are likely in here because we couldn't find the handle!
                    Console.WriteLine(
                        "Something went wrong... run handle manually to make sure everything is as you expect it.");
                }
            }
    
  • SureshKumarNarayanasamySureshKumarNarayanasamy Suresh Kumar Narayanasamy USMember

    Right click on your project --> Properties

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

  • BobPfingstenBobPfingsten Bob Pfingsten 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 Scott Smith 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 Rogier van der Hee 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 Timothy Lee Russell USMember ✭✭

    Me too.

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

  • FredyWengerFredyWenger Fredy Wenger 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:
    https://forums.xamarin.com/discussion/41844/my-findings-after-test-if-the-newest-xamarin-vs-integration-software#latest

    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:)

    Here:
    https://forums.xamarin.com/discussion/43273/alpha-release-xamarinvs-3-11-658-cycle-5-service-release-2#latest
    or
    https://forums.xamarin.com/discussion/42670/stable-service-release-xamarinvs-3-11-586-bug-fixes-for-3-11-445#latest

  • FredyWengerFredyWenger Fredy Wenger 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 Fredy Wenger 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:
    http://forums.xamarin.com/discussion/comment/152557/#Comment_152557

    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 John Hardman GBUniversity ✭✭✭✭✭
    edited September 2015

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

    Unable to copy file
    "E:\MyApp\packages\Xamarin.Forms.1.5.0.6447\lib\MonoAndroid10\Xamarin.Forms.Core.dll"
    to "bin\Debug\Xamarin.Forms.Core.dll".
    The process cannot access the file
    'bin\Debug\Xamarin.Forms.Core.dll'
    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 John Hardman GBUniversity ✭✭✭✭✭
    edited September 2015

    [deleted]

  • giangnamtrangiangnamtran Tran Giang Nam 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: http://developer.xamarin.com/releases/vs/xamarin.vs_4/xamarin.vs_4.0/#Xamarin_4.0

    I tested again on my project with:
    Microsoft Visual Studio Community 2015
    Xamarin 4.0.0.1566 (5abb0de)
    iOS SDK 8.4.
    => Result: http://developer.xamarin.com/releases/vs/xamarin.vs_4/xamarin.vs_4.0/#XVS_4.0.0.1505
    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 4.0.0.1505)

    => 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 Dean Podgornik 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 Dirk Seifert DEMember

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

    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 Philip O'Gorman USMember ✭✭✭

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

  • StuartCrawshawStuartCrawshaw David Bickerdike GBMember

    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

  • kenellefsontechcomkenellefsontechcom ken@ellefsontech.com USMember

    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

  • DhanalakshmiDhanalakshmi Dhanalakshmi USMember

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

  • UdaraAlwisUdaraAlwis Udara Alwis 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 Dean Podgornik 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... /(-_-)\

«1
Sign In or Register to comment.