Azure Emulator Crash with error 0x800700b7: Cannot create a file when that file already exists


Sometimes when you are using Visual Studio and working on some Azure projects, you might hit an issue which cause your Azure emulator to crash.

When that happens, you will get the System.Runtime.InteropServices.COMException (0x800700B7): Cannot create a file when that file already exists. (Exception from HRESULT: 0x800700B7)

Error

You can try also manually to run the compute emulator instead of use Visual Studio, the command you need to run is like the next one below:

csrun /devfabric /usefullemulator

And from the command window, you can see that the compute emulator is started.

csrun1

However, using same csrun command, you can check the current status of the emulator, by running the command csrun /status, and you will see that the emulator is not running.

csrun2

You can check the DFService.log file that is generated by the emulator, those logs are located in next folder path:

C:\Users\<user>\ appdata\local\dftmp\DFServiceLogs

In the DFService log file, you can see there the same exception that is reported by Visual Studio (while trying to run the emulator) or by running the csrun command (to run manually the emulator.

 

DFService Information: 0 : [00003520:00000001, 2016/02/17 23:36:54.436]==============================================================================================================================

DFService Information: 0 : [00003520:00000001, 2016/04/17 23:36:54.436] Started: "C:\Program Files\Microsoft SDKs\Azure\Emulator\devfabric\DFService.exe" -sp "C:\Users\YYY\AppData\Local\dftmp" -enableIIS -singleInstance -elevated

DFService Information: 0 : [00003520:00000001, 2016/04/17 23:36:54.482] Exception:System.Runtime.InteropServices.COMException (0x800700B7): Cannot create a file when that file already exists. (Exception from HRESULT: 0x800700B7)

at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)

at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo)

at Microsoft.WindowsAzure.GuestAgent.EmulatorRuntime.EmulatorRuntimeImpl.Initialize(String runtimeConfigIniFile, String serviceName, String rootPath, String logFilePath)

at Microsoft.ServiceHosting.Tools.DevelopmentFabric.Fabricator.InitializeEmulatorRuntime()

at Microsoft.ServiceHosting.Tools.DevelopmentFabric.Fabricator.InitializeRuntimeAgents()

at Microsoft.ServiceHosting.Tools.DevelopmentFabric.Fabricator.Initialize()

at Microsoft.ServiceHosting.Tools.DevelopmentFabric.Program.Main(String[] args)

 

Now, the issue has been identified, how to mitigate it?

First, I suggest you to check the next great support blog:

https://blogs.technet.microsoft.com/supportingwindows/2014/08/11/wmi-missing-or-failing-wmi-providers-or-invalid-wmi-class

Then after you have checked the blog post, you need to check which one is the missing or failing WMI class, by following the next steps:

  1. Go to start-run and type in wmimgmt.msc
  2. Right click on Local WMI Control (Local) and select properties.
  3. On the general tab, if there are any failures noted on that box, that indicates a core WMI issue.
  4. Found the .MOF files for Win32_Processor namespace/class

For this case, I saw that there were some WMI invalid classes:

  • Win32_Processor
  • Win32_WMISetting

wmierror

  1. Repair the MOF file by running mofcomp.exe <MOFFilename.MOF>. The mofcomp.exe is located in the C:\Windows\System32\wbem folder.
  2. And then re-register the associated DLL by running the command regsvr32 <MOFFilename.dll>

fixIssue

  1. Verify if it is fixed or not by checking the WMI Control (wmimgmt.msc) again. This time, as you can see in the image below, there are no more WMI class erros.

wmifixed

  1. Then, re-launch the Emulator, and this time you will see the emulator to run again, with no issues/crash this time.

I want to thanks Wayne for his great and deep knowledge for Visual Studio.

You can now still enjoying Azure !!

 

Comments (2)

  1. Tyler Angell says:

    You are my new favorite person in the entire world. I have had this issue for almost a full YEAR now! Seriously, I am almost in tears I am so grateful! I have lost so much time trying to figure this out.

    1. Hello Tyler. Thank you for your feedback, I am glad that it worked for you 🙂

Skip to main content