gacutil postbuild event exists with code 1
Asked Answered
I

6

8

I am trying to register and assembly in the GAC on a post-build event. Here's my post-build command

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64\gacutil.exe" /if "$(TargetPath)"

I am on x64/Windows 7/VS2010. I am running VS2010 as an administrator and I have UAC turned off (which is pretty much all that my google-fu is finding for this problem).

The post build is exiting with code 1 for the all 4 instances of gacutil.exe I can find on my machine.

Anyone know a way around this? Thanks in advance.

Indomitability answered 11/7, 2011 at 20:38 Comment(2)
This actually started working after a rebuild of my dev machine. So I am not sure what the issue was.Indomitability
The error that displays in the shell is "Failure adding assembly to the cache: The process cannot access the file because it is being used by another process."Ice
B
14

Copy the full post-build event command string (e.g. ""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64\gacutil.exe" /if "D:\ProjectFolder\Project.Name\bin\Debug\Project.Name.dll" to the clip board, open a command prompt as an administrator, paste the post-build event, and press enter to execute. You'll get a more descriptive explanation of the exit code.

In my case, I had my project set to build to the wrong target framework. I switched it from .Net 4 to .Net 3.5 and the error went away.

Best of luck

Bicentennial answered 27/1, 2012 at 0:48 Comment(3)
Following this suggestion, I had an access denied error. That was fixed by running Visual Studio as Administrator.Nutshell
This is a good suggestion. In my particular case the output error was that I forgot to sign the assembly.Hellenist
In my case the .dll was used by another process. ThanksBesmear
C
4

SOLUTION:

Try to run Visual Studio as ADMIN to install things in GAC... :)

Casals answered 10/4, 2016 at 19:57 Comment(0)
A
2

Mine is usually solved by iisreset.

Aesthetically answered 10/9, 2013 at 9:25 Comment(0)
U
1

Looks like your post build script is incorrect....Try using "$(DevEnvDir)....\SDK\v2.0\Bin\GacUtil.exe" /i "$(TargetPath)" /f

Uttermost answered 15/7, 2011 at 10:6 Comment(0)
O
1

OS: Windows server 2012

.Net frame work 4.5

The path needs to be: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\gacutil.exe

Orthopedic answered 13/11, 2013 at 5:34 Comment(0)
M
0

I had the same problem, I was able to fix it by:

  1. Finding and stopping any other processes that had a handle open on the dll using Process Explorer
  2. Uninstalling the assembly with "gacutil /u AssemblyName"
  3. Increasing the Assembly Version Number in Project Properties -> Assembly information

After these steps my post build step started working again.

Mimesis answered 1/3, 2012 at 6:11 Comment(1)
The only process that is showing attachment to my dll is devenv.exe (VS itself)?Concretion

© 2022 - 2024 — McMap. All rights reserved.