Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get an error for "__CrtGetFileInformationByHandleEx " when I try to compile

I just installed Visual Studio 2015 Community on my computer. Until now I have been using Visual Studio 2010 Professional. Now when I try to run my MVC apps in the build in web server, I get the following error message.

The procedure entry point __CrtGetFileInformationByHandleEx could not be located in \WINDOWS\SYSTEM32\msvcp120_clr0400.dll

I get the same error message if I try to execute vbc.exe (the Visual Basic compiler) on directly at the command prompt. My MVC app also shows a YSOD with

Compilation Error - Compiler Error Message: The compiler failed with error code -1073741511.

How can I fix my VS so I can run my programs again?!

Steps I've tried

  1. Uninstall VS 2015 Community
  2. Uninstall and reinstall .NET 4.6 and .NET 4.5.2
  3. DISM /Online /Cleanup-Image /RestoreHealth
  4. The .NET Repair Tool
  5. Run sfc /scannow
  6. Manually rename the msvcr120_clr0400.dll file to msvcr120_clr0400.dll.corrupt and do 1-5
  7. Uninstall and reinstall VS 2010 w/ SP1

sfc /scannow successfully replaced the msvcr120_clr0400.dll file, but it replaced it with the exact same CTP file as before!

EDIT:

The problem dll's from my system are available for download here:

  • 32 bit
  • 64 bit
  • 32 bit msvcr
  • 64 bit msvcr
like image 734
just.another.programmer Avatar asked Nov 15 '15 15:11

just.another.programmer


4 Answers

Microsoft is aware of this issue with KB3098779 and 3097997:

https://support.microsoft.com/en-us/kb/3118750

The recommendation is to uninstall these patches and then rescan for updates. Newer versions of these security patches (that do not break the VB compiler) are now available.

like image 189
Kevin Halverson Avatar answered Nov 16 '22 08:11

Kevin Halverson


Okay, I see it from the files you uploaded to the sharing service, your .NET install is corrupted. A standard DLL Hell problem, your c:\windows\syswow64\msvcr120_clr400.dll file is the wrong version. Something you can see when you use Explorer and navigate to the file. Right-click and select Properties, look at the Details tab.

enter image description here

Note the word "CTP" in the Product name, means "Community Technology Preview". A Microsoft term that means "beta version". Clearly you should not be having the VS2013 beta on your machine. Your msvcp120_clr0400.dll is correct, it is file version 12.0.52512.0. It depends on an exported function in the msvcr DLL that the CTP version did not yet have.

Exactly how this happened is always hard to reverse-engineer. You are the 3rd SO user that I know of that had this problem this week, a bit too much of a coincidence. Two basic scenarios, if you ever had the VS2013 CTP edition installed on the machine then the problem is that it didn't get updated like it should have. Otherwise a very typical problem with CTP editions, they are pretty dangerous because the uninstaller is always the last thing Microsoft gets right. And the problem was just never detected until you started using a program that required this export.

Or it was caused by a rogue installer, copying the old version onto your machine without checking the version number. Much less likely, installers never have a good reason to install this particular file since it is only ever used by the .NET Framework. My money is therefore on your machine getting corrupted by the CTP.

You need to solve this by getting your machine fixed. Not that easy, you can never be sure how many other bad DLLs are lying around from such a bad CTP uninstall. A shortcut is copying this particular DLL from a good machine. But best to get .NET 4.6 re-installed.

EDIT from OP:

This answer correctly identified the problem files but reinstalling (or any other common steps) didn't solve it. In the end I copied "good" files from another computer with the version number 12.0.20806.33440.

like image 25
Hans Passant Avatar answered Nov 16 '22 08:11

Hans Passant


KB3098779 appears to be the culprit on our server. That is the patch that installed the rogue CTP msvcr120_clr0400.dll mentioned in the above answer. Solution: we reversed out the patch set that applied KB3098779, and everything is working again. FYI: this is a .NET framework 4+ issue, not Visual Studio. Our server is a standard 2012 IIS server: Visual Studio is not installed.

like image 3
Mike Avatar answered Nov 16 '22 08:11

Mike


I had the same issue on Windows 8.1 although KB3098779 and 3097997 were not installed on my machine. Probably it happened after installation of ASP.Net 5.

The issue was that I had both mcvcr files in version 12.0.51670.34230 while mcvcp files were already in 12.00.52512.0. It was enough to copy both mcvcr files (from System32 and SysWOW64) in this version from my colleague's pc.

If you have problems with permissions set to TrustedInstaller on these file, you can run this powershell command and then change permissions as Administrator:

takeown /A /F C:\windows\syswow64\msvcr120_clr0400.dll
like image 2
kriskot Avatar answered Nov 16 '22 06:11

kriskot