I have seen the examples of adding references to assemblies from GAC to visual studio 2010 project or item templates. Is it possible to add references to non-GAC assemblies in my custom project or item templates?
I have all our common assemblies stored in local folder (in dev environment) that I want to reference in my custom project and item templates. How can I do it?
<Reference>
<Assembly>MyWebUtils, Version=8.3.842.0, Culture=neutral, PublicKeyToken=</Assembly>
</Reference>
When I try to add local dlls, I get error saying that it can't reference the assemblies.
Related
I need to use some classes from another project. How can I just import or create a reference to that project in Visual Studio?
Right now if I use "Add reference" in Visual Studio, I get the error:
".NET Core projects only support referencing .NET framework assemblies in this release. <br/>
To reference other assemblies they need to be included in a NuGet package"
.NET Core works with dependencies via NuGet.
If your projects are in the same solution, then yes, you can add a reference using the Visual Studio UI ("Add reference" command). A background reference will be added as a NuGet package.
Manually you can do this by adding <ProjectReference> section to the .csproj file:
<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" />
Otherwise, you should pack your project into a NuGet package (use the dotnet pack command) and then add it as other NuGet packages.
If you do not use any public NuGet sources, you can host your own NuGet feed.
You have the next error:
".NET Core projects only support referencing .NET framework assemblies in this release.
To reference other assemblies they need to be included in a NuGet package"
Because you are trying to add a .NET project to a .NET Core project or wise versa. Look into this issue for more details:
If you're using netcoreapp then you cannot use .NET 4.x
assemblies/packages
If you're using net4xx then you can use the frameworkAssemblies
section of project.json to reference DLL files that are installed by
.NET Framework (the stuff in the GAC)
I had a .Net core project and i wanted to create another project for services in my solution. After adding the project I added the reference as follows:
Right click Dependencies in your solution.
Select Add Reference option.
In the next window, in Projects dropdown select the project you want to add.
Alternatively, you can add a reference by editing the csproj file of the project in which you want to add the dependency/reference. Open the file and add the following:
<ItemGroup>
<ProjectReference Include="..\PATH\TO_YOUR_NEW PROJECT.csproj" />
</ItemGroup>
Hope this helps someone.
You can add reference by adding your project name in csproj file. if your project in same solution
<ItemGroup>
<ProjectReference Include="..\projectName.csproj" />
<ProjectReference Include="..\ProjectName2.csproj" />
<ProjectReference Include="..\ProjectName3.csproj" />
I have a Project Template that I want to make available to people that I work with. How should project templtes (and item templates) be deployed? According to MSDN on this page (https://msdn.microsoft.com/en-us/library/xkh1wxd8.aspx) you should use a vsix package, but template wizards must be installed to the GAC and a vsix package cannot do that.
It seems that you don't need the GAC after all. See:
Using IWizard in an item template without installing assembly in GAC?
Using IWizard in an item template without installing assembly in GAC?
I have created an extension for VS 2010 that deploys a project template. The project template uses a custom wizard (in a specific assembly) that is called when I create a new project based on this template.
I want to package the assembly containing the wizard within the VSIX, so that it gets deployed somewhere the template can find it (I know GAC is not an option with VSIX).
Basically if I deploy the assembly to the GAC, install the VSIX and then create the project the wizard is invoked successfully.
If I do the same without deploying the assembly first, the project templates does not find the assembly when I create the project.
My question is: how to deploy a project template and the assembly it needs using a VSIX package?
Thank you for your help
EDIT: I changed the VSIX Sub Path of the wizard assembly reference to "ProjectTemplates" in both the installer project and updated the vsixmanifest content assembly reference accordingly. It seems to work now.
You don't need to get your assembly containing the IWizard implementation in the GAC. You can simply declare it in your extension.vsixmanifest file as an Assembly element in the Content section.
Unfortunately, this doesn't appear to be documented well anywhere.
The only tricky part is making sure that the AssemblyName attribute has the correct value.
I had no luck with the Assembly element technique to work, so in case anyone else runs into the same problem, here's another solution.
Visual Studio looks for wizard DLLs using the BindingPaths registry key. If you add the folder containing your DLL in a subkey of BindingPaths, then Visual Studio will find your DLL.
To do this from a VSIX, create a .pkgdef file in your VSIX project. Set its Include in VSIX property to True, and paste the following text into it:
[$RootKey$\BindingPaths\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}]
"$PackageFolder$"=""
(where the Xs represent the package GUID, though I suspect any GUID will do).
This works for me:
[$RootKey$\BindingPaths\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}]
"$PackageFolder$"=""
But assembly element doesn't work.
I have installed the strong named assembly TestReflection into the GAC (I am using .NET 4.0 and VS 2010).
Different versions of the TestReflection DLL are in GAC of .NET 4.0 (C:\WINDOWS\Microsoft.NET\assembly\GAC_32\TestReflection\), however, the assembly does not appear in the "Project" -> "Add reference" box of VS 2010.
How can I refer to my assembly deployed in GAC at design time from another project?
This page says that:
You cannot add references from the Global Assembly Cache (GAC), as it is strictly part of the run-time environment.
Referring to this statement, I would like to know how to make your project's DLL shared assembly for other consumers if it's the requirement?
The dll's shown in the .Net tab of the "Add references" dialog are not actually the ones registered in the GAC. They are found by searching a few paths on your filesystem.
The paths being searched are located by Visual Studio by looking up the following registry entries:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetFramework\{Version}\AssemblyFoldersEx\
There should be some keys added there already, so if you want your own dll to show up on the .Net tab, you can add it to one of the folders defined there. You could also add a new registry key pointing to a custom folder, which would only contain your own dll's.
The GAC is only meant for loading assemblies at runtime after your application has been deployed, so I don't think you should use it while developing. When you deploy your app, make sure to set "Copy local" to false on your reference so the dll won't be copied to the bin folder, and then install it into the GAC and it will be loaded from there instead.
Another simple option would be to manually edit the project file as XML in visual studio (You will have to unload the project first), and simply add node <Reference Include="<name of dll>" /> in MSBuild project file. After reloading the project, VS will pick up the reference without problem.
If you want to add Global Assembly Cache references to your VS2010 project, there is an extension you can use: Muse.VSExtensions.
It has some quirks but does a decent job. Check it out...
The answer is the Reference Paths in the property windows, you have to set it with the GAC path
Please see my post here:
I have a dll in the GAC. I browse to this same dll in a different place then referenced in the GAC using the file dialog of add reference.
Visual studio repoints it to the gac location.
Boom my build blows up on the build server that doesn't have this dll in the gac or at that location.
What is the best way to fix this?
Assuming the directory structure on the build machine is the same as on your local machine, you could add hint path to the project file. Right click on the project and select 'Unload Project', then right click again and select Edit. After adding the hint path, right click on the project again and select 'Reload Project'.
<Reference Include="YourReference, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxx, processorArchitecture=x86">
<HintPath>..\..\bin\YourReference.dll</HintPath>
</Reference>