question

AthaG avatar image
0 Votes"
AthaG asked AthaG commented

Ngen failing to install after unistall

Hi,
I am trying to ngen few microsoft dlls due to error in our application while loading. The error happened due to bad image popup in the DeviceGuard enabled environment. So I thought of uninstalling and install native image dll again. I used the following command,

ngen.exe uninstall "Microsoft.WSMan.Management" (it got succeeded)

ngen.exe install "Microsoft.WSMan.Management" This command failed to find the file with the below error,

Failed to compile Microsoft.WSMan.Management because of the following error: The system cannot find the file specified. (Exception from HRESULT: 0x80070002).
Uninstalling assembly Microsoft.WSMan.Management because of an error during compilation: Failed to compile Microsoft.WSMan.Management because of the following error: The system cannot find the file specified. (Exception from HRESULT: 0x80070002).
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

Can someone help me here?

dotnet-adonet
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

cooldadtx avatar image
1 Vote"
cooldadtx answered AthaG commented

You should never ngen binaries you don't own. This is just asking for corrupting your system. Furthermore when those binaries are updated by the third party next time then they won't be ngen automatically which could cause failures or bad performance. Specifically dependencies are impacted by ngen so doing this on binaries you don't own can cause them to fail to load for others.

At this point you'll need to repair the installation of the program(s) that installed the binaries. The particular one you mentioned is from Powershell so you might be able to repair the installation of it. If you have PS and PS Core then you might need to repair both. If that doesn't fix it then repair the .NET installation as well.

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Use the full assembly name (including version, culture, public key). The original assembly is in the GAC.

1 Vote 1 ·

Thank you!
Let me try that...

0 Votes 0 ·
AthaG avatar image AthaG cooldadtx ·

Thank you!
This worked, I can re-generate the NI files again.

0 Votes 0 ·

@cooldadtx Thank you for your response.

This is one dependency of one of binary which is already corrupt due to update in Device Guard. Which is being blocked by DG. Due to this our application is not able load and times out (as bad image popup messages appears).

Further, we have few more dlls which we own need native images to be generated. But here, without knowing the location if i mention the assembly name its failing. But if i mention path or go to the path and perform ngen install it works fine.

Is it possible do Ngen with the assemly name without the exact location or relative location?
Is there any other way to do Ngen again?

0 Votes 0 ·