.Net framework mscorpe.dll error
.net, c#, dll, windows-7, winforms
Solution
First, verify that the file is corrupt and that it cannot be repaired automatically.
Run:
sfc /scanfile=C:\Windows\Microsoft.Net\Framework64\v2.0.50727\mscorepe.dll
If you see the message:
Windows Resource Protection found corrupt files but was unable to fix some of them.
It means that both the file and the backup file that Windows uses to perform the repair are damaged.
Windows cannot automatically repair the file and this particular file is not replaced when you reinstall the .Net 3.5 framework.
To restore the file manually:
- Install 7-Zip (the 32-bit x86 version).
- Open an administrative command prompt.
- Insert a copy of Windows 7 Professional into the DVD drive or mount the ISO image.
- Run the following commands from the administrative command prompt.
Take ownership of the file:
takeown /f C:\Windows\Microsoft.Net\Framework64\v2.0.50727\mscorpe.dll
Grant the necessary permissions to overwrite the file:
icacls C:\Windows\Microsoft.Net\Framework64\v2.0.50727\mscorpe.dll /GRANT ADMINISTRATORS:F
Replace the file with the original from the installation DVD. Note, that this assumes that the DVD is available on the D: drive. Change the drive letter, if necessary, to suit your setup.
"C:\Program Files (x86)\7-Zip\7z.exe" e D:\sources\install.wim -oC:\Windows\Microsoft.Net\Framework64\v2.0.50727\ 4\windows\Microsoft.Net\Framework64\v2.0.50727\mscorpe.dll
Enter `Y` when prompted to overwrite the file.
- Ensure that the .Net 3.5 Windows feature is enabled and retest your application.
Note: If you don't have access to the Windows installation DVD or ISO you can run the first two commands and then copy `mscorpe.dll` from another machine running Windows 7 Professional x64. Make sure that you copy it from the `C:\Windows\Microsoft.Net\Framework64\v2.0.50727\` folder.
Problem
I have a client machine with Windows 7 Professional installed on it. In order to run my latest application, I installed .Net Framework version 4.0 Full, download from here. My application works fine. However, there is another application developed in .Net framework 3.5. When I try to execute that application, I get an error: C:\Windows\Microsoft.Net\Framework64\v2.0.50727\mscorepe.dll is either not designed to run on Windows or it contains an error ... I have tried removing .Net framework 4.0 and reinstalling it again and I tried repairing it, but nothing seems to work. The error remains. I have tried installing .Net framework 3.5 separately, but I can't install it since a newer version (4.0) is already installed on the machine. The application with version 3.5 works fine on other client machines, so I guess the issue is isolated to .Net framework installation on that particular machine. Is there any way to repair `mscorpe.dll` or re-install .Net framework 3.5 ?