How to add a reference to C:\Windows\Microsoft.NET\assembly - visual-studio

How can I reference a .NET assembly deployed in c:\windows\microsoft.net\assembly from Visual Studio IDE?
If i do right click on References/Add Reference, it only shows the c:\windows\assembly content.
How do I add a reference to new GAC path (c:\windows\microsoft.net\assembly)?

Go to the location via CMD C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools
Type Gacutil -i {Path of the dll}
OR
Open visual studio commond promt and type Gacutil -i {Path of the dll}

It's working by adding a reference to:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\\
I don't know if it is the better way to do it but it seems to do the job.
For registering the DLL in another environment, I used the following sentence:
"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe" /i /f
Hope it helps.

Related

Gacutil not installed by default in VisualStudio

I am unable to add an assembly into GAC. Please assist in getting it work. I ran following command in VisualStudio13 CMD
gacutil /i “<C:\Program Files\ibm\IBM DATA SERVER DRIVER>\bin\netf40_32\IBM.Data.DB2.Entity.dll”
Error Message:
Command "gacutil" is not valid.
Also, i checked there is also no gacutil.exe file on path
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0
Tools
But when i access the path there is no gacutil file as shown:
The issue was Windows Explorer path(C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe) had no "gacutil.exe". Accessing the same path through cmd listed down "gacutil.exe" as present.
Thus, instead of just giving command gacutil-i to add an assembly in cache, i gave full path
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0Tools\gacutil.exe -i
Don't trust windows explorer. Trust command credits# Sir Conrad Frix-Comments
You can either drag-drop the .dll into c:\windows\assembly folder or check C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64 for gacutil as its part of .net framework, not your IDE. Hope it helps!

Visual studio 'xsd' command: file path

The command 'xsd' in the Visual Studio (2010) command window is not fiding my file.
Tried full path 'c:\...\etc...', tried path from project folder, tried any sub path of the full path, tried only the file name (as shown on any example in the web of the usage of the tool).
The file is inside the project inside a subfolder, like "project\schema\mySchema.xsd".
Command used
>Tools.Shell xsd <path\>myfile.xsd /classes
returns:
The operation could not be completed. System could not find specified file.
What work around can I make, how should I properly use the tool? (Am I using it wrongly?)
To find XSD.exe these days, go to:
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2
Tools\xsd.exe
Step by step:
Go to C:\Program Files (x86)\Microsoft SDKs\Windows\
Click latest version (e.g. v10.0A)
Click Bin
Select latest .NET Version e.g. NETFX 4.7.2 Tools
There is xsd.exe
When you launch the shortcut that opens the Visual Studio Command Prompt you execute a batch file that set some important string inside the PATH environment variable. These strings contain the folder names where the XSD tool is located.
The shortcuts are located in this folder on my dev PC with Visual Studio 2013
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
The shortcut that opens the Command Prompt for Visual Studio x86 Native Tools is something like this
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"" x86
So, unless your installation is damaged you should be able to find the correct command in the relative directory of your Visual Studio 2010 install.

Can’t uninstall infragistics. Can’t find gacutil

Am trying to uninstall infragistics, but i get an error at the end of the uninstall saying 'Windows cannot find gacutil. Make sure you typed the name correctly and then try again'. I navigate to this path 'C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools' and the gacutil file is there. Any idea on these? Am stuck with infragistics and i can’t uninstall them.
In order to reference gacutil as a command you need to add the location of gacutil.exe to your environmental variables.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools

gacutil postbuild event exists with code 1

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.
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
SOLUTION:
Try to run Visual Studio as ADMIN to install things in GAC... :)
Mine is usually solved by iisreset.
Looks like your post build script is incorrect....Try using "$(DevEnvDir)....\SDK\v2.0\Bin\GacUtil.exe" /i "$(TargetPath)" /f
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
I had the same problem, I was able to fix it by:
Finding and stopping any other processes that had a handle open on the dll using Process Explorer
Uninstalling the assembly with "gacutil /u AssemblyName"
Increasing the Assembly Version Number in Project Properties -> Assembly information
After these steps my post build step started working again.

visual studio post-build script error calling gacutil

I'm on vista, with VS2005 running as admin. Both vs2005 and vs2008 are installed. If I explicitly use the path to gacutil, it works, but not if I only call gacutil like this:
if NOT $(ConfigurationName) == Release gacutil /f /i "$(TargetPath)"
I would just update the post-build script, but I've been asked to leave it alone. It's a project for a sister company. The path to gacutil is in Visual Studio environment variables, so it should be able to find it. (Tools -> Options -> Projects and Solutions -> VC++ Directories)
Is there some way to tweak visual studio or windows environment variable to get the above post-build script to work? I need to it to build, because it's a dependency of a project I need to code.
TIA, -j
As you suggest, tweaking the Windows PATH environment variable should get things working.
append the directory that contains GACUTIL to the end of the PATH. For example, using the location on my computer, append (without the quotes) ";C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin" to the existing value of the PATH system environment variable.
Restart Visual Studio to pick up the new value.
Dave

Resources