Can't load EntityFramework.dll 5.0.0.0 inside Visual Studio 2013 extension - visual-studio-2013

I'm writing a Visual Studio extension which depends on EntityFramework 5.0.0.0. I included EntityFramework in my project. When I install my extension, my extension's DLL appears in VS extensions folder, and EntityFramework.dll appears with it as well.
However, when I run my Extension in Visual Studio 2013 (update 5), it can't load EntityFramework: System.IO.FileNotFoundException: Could not load file or assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
Looking in Process Monitor, I saw that when I run my extension, VS2013 tries to load EntityFramework from a different path, which has it in a different version - 4.2. I'd expect VS2013 to continue to search for EntityFramework, and find it in my extension's folder, like it does for other dlls included in my extension, but it doesn't.
In VS2015, VS does manage to load EntityFramework 5.0.0.0, but it does so also from yet another different path.
Why doesn't VS2013 continue to search for EntityFramework in my extension's folder?

You need to specify a ProvideCodeBase attribute to specify that your extra assemblies should be loaded. "Sometimes" you get lucky and it finds something else, but that's never guaranteed to work. You can see a few examples of that being used here.

Related

What does "Version" mean when viewing reference properties in Visual Studio?

I am currently battling "DLL hell" in Visual Studio 2017. For unknown reasons, I suddenly got a problem with System.ValueTuple, where the error I get is the classic problem that have been asked many times before:
Could not load file or assembly 'System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
I cannot really figure it out, as I don't think I should have any reference to 4.0.2.0. VS tells me the following:
What I don't get is how the "Version" of the System.ValueTuple says 4.0.2.0, when I have installed version 4.4.0 according to the path of the DLL and according to NuGet Manager.
So, why is it like this?

How to compile an ArcGIS Desktop add-in in Visual Studio 2013

I have several projects made in Visual Studio 2010, those projects are ArcGIS Desktop Add-in's. I have been change of computer, and my new one only have Visual Studio 2013 due to some company politics I'm not allowed to install VS2010.
I tried to open this projects in VS2013, and they open with no problem, but when i try to compile it, it get me the following issue:
ESRI.ArcGIS.AddIns.SDK, Version=10.2.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86. Could not load file or assembly 'Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
my research so far has get me to install the VS SDK, but I'm not quite sure about which one(2008...2013)
Any one has any possible solution for this?
First, I check that Microsoft.VisualStudio.Shell.9.0 was in the GAC, It was not there... :( then I proceed as Juho Vainio in Geonet suggest : Visual Studio Command Prompt --> Run as Administrator --> gacutil /i Microsoft.VisualStudio.Shell.9.0.dll, but it failed because I was not giving the full pat of the dll, so I search for it in the Visual Studio 2008 SDK, and Voila!!! it appear in the GAC
but the project still does not compile, so, I chec in the real GAC:
C:\Windows\Microsoft.NET\assembly
and found that the file does not exist neither in the GAC_32, nor GAC_64 folder, moreover, it exists in the folder GAC_MSIL, so....i took the folder C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualStudio.Shell.9.0 and copied it to the folders GAC_32 and GAC_64.
Now the project compiles.

How can a VS extension target multiple versions in regard to Microsoft.VisualStudio.* references?

A few extensions that I'm using are broken under VS2012 because at some point they were updated to work with VS2013, by changing the version of referenced libraries. At runtime an error like this can be produced:
Could not load file or assembly 'Microsoft.VisualStudio.Shell.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I see various extensions referencing multiple versions of the same library:
<Reference Include="Microsoft.VisualStudio.Shell.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Others release an extension per VS version.
Another option, according to this article, is to dynamically load the correct version.
I'd like to help fix these extensions, but what's the proper way to tackle this issue?
So the Visual Studio reference assemblies break down into a few different categories, which you should handle differently depending upon the category:
Interop assemblies: these are the ones like the Interop.* assemblies you listed in your question. Each interop assembly isn't a newer version of the "same" thing, but rather an assembly that contains all the COM interfaces that were added in that version of Visual Studio. Referencing old versions is fine, just don't reference a newer one than the lowest version of Visual Studio you want to target
Editor assemblies, Roslyn: Anything related to the core text editor (assemblies are Microsoft.VisualStudio.Text.Data, Microsoft.VisualStudio.Text.UI, Microsoft.VisualStudio.Text.UI.Wpf, and Microsoft.VisualStudio.Editor) and Roslyn Visual Studio includes assembly redirects that redirect whatever version you're referencing to the version of VS you're actually running in. Once again, target the lowest version that you intend to support.
Microsoft.VisualStudio.Shell.[version]: this one confuses people a lot. How this particular assembly works is for each version of Visual Studio that ships, a new assembly name (with the version in the assembly) is made. Then, in future versions of the Visual Studio, we ship a newer version of the assembly that you target. So again, make sure you're targeting Microsoft.VisualStudio.Shell.[version] with the lowest version you intend to support.
The tricky problem here is the VSSDK project upgrader likes to upgrade your projects to newer versions. Get used to editing MSBuild files by hand to ensure it doesn't do this, or downgrade what it already did. For the final VSIX you ship to users it's often best to either build with an older version of VS to ensure it's not picking up newer stuff by accident. If you want to only use a newer version, then you'll have to find the VS binaries from the older version you wish to use and check those into your source control system to ensure the older versions are still being picked up. Test your VSIX if you go this route as it's easy to make a mistake and reference something newer by accident.
I wrote an article discussing the various assembly versioning policies used by Visual Studio assemblies.
http://tunnelvisionlabs.github.io/vsbase/docs-master/html/edbfd3ce-43f4-4f3f-a90c-bc22bda19fae.htm
In addition, the VSSDK.* NuGet packages use dependency declarations to help you identify the version(s) of Visual Studio each extension can be used with.
The particular version of Microsoft.VisualStudio.Shell you referenced is a Versioned Assembly (per the previous article) and included in the VSSDK.Shell.12 package, with the following description:
This package provides the Visual Studio "Shell" reference assembly used by Visual Studio 2013 and newer.
To easily target both Visual Studio 2012 and Visual Studio 2013, use NuGet to manage your VS SDK dependencies, and ensure the following conditions hold:
Make sure your assembly does not have a dependency on the VSSDK.IDE.12 NuGet package. This dependency means one or more assemblies referenced by your project only work with Visual Studio 2013 and newer.
Make sure your assembly does not have a dependency on VSSDK.IDE.10Only, VSSDK.IDE.11Only, or VSSDK.IDE.12Only. These indicate that your package references one or more assemblies that only work with a particular version of Visual Studio.
Ideally you would only want to install VSSDK NuGet packages which include both the vs2012 and vs2013 tags.

Unable To Reference Wizard Assembly in VSIX Deployed Template

I am trying to create a VISX extension for Visual Studio 2010 that contains a few project templates. These templates aren't very complex, but I want to expose some additional configuration for them during creation via a wizard. I have successfully set up my VISX package to deploy the templates to the directory structure I want in VS2010, but as soon as I try to configure and run a wizard, I receive an error when I create the template along the lines of:
Error: this template attempted to load component assembly
'My.Assembly, Version 1.0.0.0, Culture=neutral, PublicKeyToken=...
My current configuration is as follows:
All the projects live in the same solution.
The VISX project includes project references to the project containing the wizards and to each template.
Each template is built from a project template template (...confusing terminology).
They are added through the .vsixmanifest designer as content, referencing the projects.
Each .vstemplate file has a WizardExtension element pointing to the IWizard implementation and containing assembly.
The wizard assembly is signed.
The .vstemplate files point to their wizards like this:
<WizardExtension>
<Assembly>My.Assembly, Version=1.0.0.1, Culture=neutral, PublicKeyToken=a494da9e6e53f845, Custom=null
</Assembly>
<FullClassName>My.Assembly.Wizard</FullClassName>
</WizardExtension>
This, as far as I can tell, is how I'm supposed to do it. What exactly is going wrong? It looks like it can't find the assembly. Are there any other steps I need to take in order to get the assembly visible to the templates? The assembly is deployed to the extension folder when it is installed (I verified this), so it is at least making it out. Is there something special I need to do to the .vstemplate files to tell them to look in the extensions folder vs the GAC? Did I just miss something?
Note that I have found several pages on the internet stating that I have to GAC the assembly manually or with a script. However, few had my exact scenario (Project template templates being referenced by a VISX project, most examples are using a regular project exported via the project template wizard and having their packages dumped into the VISX folder structure). The only one I found that matched my scenario was an example from Microsoft. I tried to match that, but alas it still does not work. I tried relocating the project I downloaded to reference in this question but I cannot find it again, though.
Using scripts is how we've done this before, but I want to try and make things a little cleaner using VISX packages. I would like to avoid this, but if it's mandatory to script the VISX to install the template to GAC, I can do that.
When deploy the wizard based project template by VSIX Extension, it is better to use Short-Named assembly in .vstemplate. This can avoid the GAC deployment.
In your case, it should be:
<WizardExtension>
<Assembly>My.Assembly</Assembly>
<FullClassName>My.Assembly.Wizard</FullClassName>
</WizardExtension>
I am using VS2015 and faced this issue on and off. When I started building VSIX project with Wizard implementation, everything worked fine for sometime (4-6 weeks) and suddenly it stopped working. After a couple of weeks it would start working again and stop working without notice. Took me long time to find a workaround (still don't know why it suddenly stops).
This is how my VSIX project is built
I have VSIX project, project template and Wizard implementation in
the same solution.
VSIX and Wizard implementation are in the same project.
Added VSIX project dll and project template as Assets in VSIX project source.extension.vsixmanifest.
Project template *.vstemplate has Wizard section which refers to VSIX project with strong name:
<<<<<<<<<<<<<<<<<<<<<<
<WizardExtension>
<Assembly>Test.Template.TemplateInstallerWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ab381f68dc4f5e</Assembly>
<FullClassName>Test.Template.TemplateInstallerWizard.WizardImplementation</FullClassName>
</WizardExtension>
None of these worked for me
Uninstalled extension from VS regular instance via Tools->Extensions
and Updates..
Uninstalled extension from VS experimental instance by
launching VS exp instance from VS2015 command prompt as Administrator:
devenv.exe /rootsuffix exp
and then uninstalling the extension via Tools->Extensions and Updates..
Using short named assembly as explained by #Ethan Wu.
Installing templates via this command from VS2015 command prompt launched as administrator:
devenv /installvstemplates
Rebooting VS2015, my machine several times during this process.
This is what worked for me (thanks to #Ethan Wu)
Remove certificate from VSIX project.
Remove strong name from Project Template *.vstemplate
file
<WizardExtension>
<Assembly>Test.Template.TemplateInstallerWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Assembly>
<FullClassName>Test.Template.TemplateInstallerWizard.WizardImplementation
Clean and build the project.
Remove extension from VS regular instance and close VS2015 (not
absolutely required)
Install the extension.
Open new VS2015 instance and try to create the project with
wizard.
Couple of things to help debug
When VSIX project is build, in bin\debug folder a file is
created -extension.vsixmanifest which has the assets type.
Look for Asset Type="Microsoft.VisualStudio.Assembly":
AssemblyName value is what is expected in project template's
*.vstemplate WizardExtension section - they should match exactly.
After installing extension, go to VS2015 extension location on
local box:
%appdata%\..\Local\Microsoft\VisualStudio\14.0\Extensions\<some_temp_folder>
open extension.vsixmanifest to ensure that Asset
Type="Microsoft.VisualStudio.Assembly" AssemblyName value is
correctly populated. If required, you can change this value and
restart VS2015 to make this in effect.
Hope this will help someone and save tons of time as there is very little help on Wizard and custom project templates.
Thanks,
RDV
I run into the same problem, but mine came to light when I updated the AssemblyVersion of my wizard project. I checked and the versions in the manifest files matched as they should.
I simply went into C:\Users\Albert\AppData\Local\Microsoft\VisualStudio\16.0_c340331cExp\Extensions, found my extension and deleted it there. Now it works again.
(Note that I did find a few others since I've since changed the company name etc, in the AssemblyInfo file, so it could be the old ones laying around that also caused this)

Add Deployable Assemblies option missing from Visual Studio 2010

I've uploaded an MVC3 website and I'm getting this error:
Could not load file or assembly 'System.Web.Helpers, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified.
Having seen this before I know that it's an issue where the libraries I need aren't there. I have to bin deploy.
However I can't find the "Add Deployable Assemblies" option when I right click the project.
And according to this answer:
Starting with MVC 3 Tools Update we are now using Nuget package
references, which means that your project is automatically
bin-deployable. Since the tooling gesture is no longer necessary it
was removed from VS 11.
So why hasn't my application been "automatically bin-deployed" if this is the case?
Any suggestions?
Install Visual Studio 2010 Service Pack1 and you will get the option.
http://iwantmymvc.com/2011-03-23-bin-deploy-aspnet-mvc-3-visual-studio

Resources