.Net framework mscorpe.dll error - c#

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 ?

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.

Chris O'Neill's answer helped me in resolving my issue, I modified it a bit and here is what I did.
Copied a working mscorpe.dll to local computer from another machine
Open Command prompt in administrator mode
Execute the following command on command prompt
Commnad:
takeown /f C:\Windows\Microsoft.Net\Framework64\v2.0.50727\mscorpe.dll
(adjust your paths accordingly)
It returned a message like:
SUCCESS: The file (or folder):
"C:\Windows\Microsoft.Net\Framework64\v2.0.50727\mscorpe.dll" now
owned by user "loggedInUser".
After that executed the following command to grant privileges.
Command:
icacls C:\Windows\Microsoft.Net\Framework64\v2.0.50727\mscorpe.dll /GRANT ADMINISTRATORS:F
Got the following response.
processed file:
C:\Windows\Microsoft.Net\Framework64\v2.0.50727\mscorpe.dll
Successfully processed 1 files; Failed processing 0 files
Then I copied the correct file copied from another machine to that location:
xcopy c:\K2PublisherError\mscorpe.dll C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorpe.dll /y
This fixed the error.

Related

dotnet cmdlet broken and continually tries to install .NET Framework 3.5

I am trying to get my dotnet CLI working. Everytime I invoke it, no matter the command it attempts to install .NET Framework 3.5, fails, and quits. Example:
PS C:\> dotnet --version
Installing .NET Framework 3.5...
Deployment Image Servicing and Management tool
Version 10.0.19041.844
Image Version: 10.0.19044.1348
Enabling feature(s)
[===================100.0%====================]
The operation completed successfully.
.NET Framework 3.5 should be installed
No installation media found!
Insert DVD or USB flash drive and run this file once again.
Press any key to continue . . .
I have used the dotnet-core-uninstall tool to remove everything that it can. I have uninstalled Visual Studio 2019 and 2017 and deleted the /.dotnet folder. The dotnet command issue persists with the same exact output, I don't even want 3.5 because that's not what my projects use (is that what the CLI runs on???). I don't know where it is pointing to or how to check and my google-fu powers have been exhausted.
I also do not have access to edit the system environment variables directly and have to use powershell to do so
FIXED
Turns out there was a C:\windows\dotnet.bat file that was taking precedence over the executables that get installed with any sdk. Deleting it fixed my problem.
The problem turned out to be a stray dotnet.bat file situated in a directory that preceded that of the desired dotnet.exe CLI in your $env:PATH variable, C:\windows\dotnet.bat
Removing the batch file fixed the problem (calling dotnet.exe - i.e. with the filename extension - would have bypassed the problem).
The problem was discovered via the following Get-Command call, which lists all command forms / executable paths for the name dotnet, with the effective one listed first:
Get-Command dotnet -All

How remote debug C#/.Net app on Linux when the app is run under a different user?

I'm running a .Net Core microservice on Linux (Ubuntu) and am trying to remote debug with Visual Studio over SSH. But the service is run under the user svcuser and my user is mainuser. Main user is in the same group as the service user.
In visual studio, I can see the process that the service is running under, but when I try to attach I get:
One or more errors occurred. Failed to attach to process. The .Net Debugger has insufficient privileges to debug the process. To debug this process, vsdbg must be running with root permissions.
I checked in MS documentation but for Linux all they have is this: https://learn.microsoft.com/en-us/visualstudio/debugger/remote-debugging-dotnet-core-linux-with-ssh?view=vs-2019 which has no info on running the service with a different user
And the only info they have on fixing such a problem is for windows only: https://learn.microsoft.com/en-us/visualstudio/debugger/error-the-microsoft-visual-studio-remote-debugging-monitor-on-the-remote-computer-is-running-as-a-different-user?view=vs-2019
If you have sudo privileges then this is relatively easy, and can be kept secured to those users with sudo privs. Avoids needing to reconfigure users/environments, and allows you to debug any process on the machine regardless of which user account it is running as.
If you use Visual Studio to make an initial attempt to debug you will find that a ~/.vs-debugger folder has been created in the home directory of the user account you were attempting to use. This command will help you locate the vsdbg binary which was installed. You can install VsDbg manually but I find leveraging the automated process is easier. If you are using VSCode this becomes a manual process, and an exercize left for the reader, but I would still use VS2019 IDE to prep the target just to keep things consistent between tools.
find ~ | grep vsdbg
For my installation the binary is located at ~/.vs-debugger/vs2019/vsdbg and this path will most likely change over time.
First, rename the binary to something convenient:
mv ~/.vs-debugger/vs2019/vsdbg ~/.vs-debugger/vs2019/vsdbg-bin
Second, create a script to replace the binary:
touch ~/.vs-debugger/vs2019/vsdbg
chmod 770 ~/.vs-debugger/vs2019/vsdbg
nano ~/.vs-debugger/vs2019/vsdbg
The script content might look something like this, note the full path to vsdbg-bin, the use of $# ensures all command-line args passed to your script are forwarded to VsDbg.
#!/bin/bash
sudo ~/.vs-debugger/vs2019/vsdbg-bin $#
Now retry your debug session from Visual Studio, if you did things correctly you should be able to attach to any remote process on the target machine using SSH->VsDbg. "Works on my machine." ;) This was confirmed with VS2019 16.8.4, .NET 5.0, and VsDbg 16.9.20122.2 debugging an ASP.NET Core application running on Debian 5.4.8 (x64) launched by systemd under a service user account in Azure. "Sweet."
HTH!

SCCM2012 .MSI Installation

i have a problem with during application installation to client. My application is Microsoft office add-in. And then i try to deploy this application to the client i don't see this files on client side but software centre says that application was successfully installed.
Why it happen? I try to install another applications for example 7Zip.MSI, my own application .msi and anothers, all ok, but if i try to install Microsoft office add-in the files are somewhere disappeared. for script execute i used this command:
msiexec /i "WToysSetup.msi" /qb
i have already installed microsoft word on clients machine.
There are a number of possible issues here. I'm assuming you're using a Visual Studio setup project in the absence of a specific tool being mentioned.
The install requires elevation, but in a silent install Windows won't show the UAC elevation dialog, and it will run without elevation. Most installs like this would fail, but you might find that a Visual Studio generated MSI reverted to a Just me install, and installed the files to an unexpected location (often C:\ and not Program Files).
MSIs can be published or assigned with SCCM-type deployments, one is to the system the other to the user, and that's Everyone or Just me again, so it may have done a per user install because of that.
Regardless of whether it seems to have worked, if it requires elevation and fails then it may just fail silently, which would be one reason you can't find the files. You should be able to see in Programs&Features/Apps whether it is actually installed, but it was installed as a per user/Just me install you'd need to log on as that user to see it in the list of installed apps.

Unable to install .NET Framework 3.5 through SCCM on Windows 10

I recently had to uninstall/re-install .NET Framework 3.5 on my new Windows 10 work machine to troubleshoot another issue. I have to install it via SCCM due to Group Policy blocking Windows Updates (so I can't just install via Control Panel > Turn Features On/Off).
When attempting to re-install through SCCM the install just spins in the Installing state indefinitely until it times out.
Steps taken:
Uninstalled the .NET 3.5 Framework via Turn Windows Features On and Off in Control Panel and restarted machine.
Went to SCCM and attempted to install software, and it hung indefinitely.
After 2 hours I restarted machine to check if I just wasn't alerted it was finished for some reason
Install did not finish, Failed status shows with the error code for timeout in SCCM.
Other Info:
I verified no errors were generated in the SCCM log files or Event Viewer.
I can't install via Control Panel MS Update download as mentioned above due to Group Policy, I can't do an Offline install b/c these laptops don't have a disk drive (for whatever reason that was decided to be ok), and I can't do a system restore to before I removed it due to drive encryption software.
No admin accounts or similar can get different results, and I've verified it is not the SCCM install itself after getting it to install on another machine just fine.
I've ran both the .NET Framework Repair tools and Clean-up tools and I still get the issue.
Any ideas on what I can try?
If anyone encounters a situation similar, I was able to fix it by extracting the microsoft-windows-netfx3-ondemand-package.cab file from the .iso of Windows 10.
Using that file you can run the following script in an elevated (administrator) powershell and it will install the files offline for you.
Dism /online /enable-feature /featurename:NetFX3 /All /Source:<path to file>

c#.net 32 bit application Not working on 64 bit OS

I am new to .NET application.
I have developed the application on 32 bit OS with Visual Studio 2008.
The application required the Microsoft.Interop services and for PDF services to open PDF files and MS Office files.
It also required SQL Express for database operations.
The application works fine on 32bit OS.
Then I created the setup for 64 bit OS, I added a new Setup project with wizard in Visual
Studio 2010 and select the Primary output and Localized resources.
But it does not included the Resources folder to the Application folder.
I set the target machine 64x and build the project, also before building give the prerequisites to the project which is Windows Installer 3.1, and .net framework 4.0, I have used the .net framwork 3.5 in the application.
Then I ran the setup, which executed successfully.
But when I tried to run the application it gave the message "Application has stoped working. Finding for the solution from the web.." and it closed.
Then I saw that there was no resources folder so I just copied the resources folder to the application where it was installed. Then the application worked fine.
So I created the setup again but this time I also provided the Resources folder to the application folder. Built the Setup and tried to run the application but the same message is prompted to me as it was giving before "Application has stopped working...", so I looked for the resource folder and all the required files which were there.
Creating a separate 64-bit version makes no sense in your case.
You have dependencies to 32-bit components; as a consequence, all1 your assemblies must be compiled to the x86 target platform and be installed using a 32-bit MSI.
If you get an "Application has stopped working..." error, this indicates that an exception occurred that has not been handled by your process. You can get the stack trace e.g. from the event log.
1 In fact, at the least the entry assembly must have an x86 target platform, and all other assemblies must have either an x86 or AnyCPU target platform.
Check you have changed the platform target to x64 or AnyCPU in your project -> Build Properties
hey friends thanks for answering my question. Finally doing a lot of things I found that it was converting the sql database to 2008 while creating the setup. And I was setting the sql express 2005 on the client machine. Then I changed the sql server 2005 to sql express 2008 and run the setup. Then I found that at the first time the exe required all the rights to convert so I tried the setup Run as Administrator and bingo the setup works for 2 different pc..
The only thing is required that at first time I need to run the application as Administrator.
Thanks for help I

Categories

Resources