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)
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.
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.
You can check the DFService.log file that is generated by the emulator, those logs are located in next folder path:
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.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:
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:
- Go to start-run and type in wmimgmt.msc
- Right click on Local WMI Control (Local) and select properties.
- On the general tab, if there are any failures noted on that box, that indicates a core WMI issue.
- Found the .MOF files for Win32_Processor namespace/class
For this case, I saw that there were some WMI invalid classes:
- Repair the MOF file by running mofcomp.exe <MOFFilename.MOF>. The mofcomp.exe is located in the C:\Windows\System32\wbem folder.
- And then re-register the associated DLL by running the command regsvr32 <MOFFilename.dll>
- 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.
- 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 !!