Legacy Security Policy in Visual Studio 2010 and COM References - visual-studio-2010

I have a project using DevExpress 8.3 (2008.3) which I just recently upgraded to use VS 2010. After doing so, everything compiled fine but I got errors trying to use the designer. I resolved this as described here:
NetFx40_LegacySecurityPolicy in design-time mode
by adding <NetFx40_LegacySecurityPolicy enabled="true"/> to my devenv.exe.config.
Designer works fine now, but some of the projects in the solution which have COM references no longer compile, with the exception:
The "ResolveComReference" task could not be instantiated from "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag.
The COM references for those projects are also flagged with a yellow exclamation mark.
The only google result I found for this error was here:
http://social.msdn.microsoft.com/Forums/en/vsx/thread/197b8dca-5610-4ac5-86fc-c56d5182e46b
which describes the exact same problem but with no resolution. I tried adding
<GenerateResourceNeverLockTypeAssemblies>true<GenerateResourceNeverLockTypeAssemblies>
as the post suggests but that doesn't have any effect for me.
Anyone know anything about this?
Thanks.

I logged into my DX account and found (to my surprise) that DX was offering me an upgrade to a new hotfix version of the same 2008.3 release (even though my subscription is expired). This fixed the problem (and allowed me not to have to use Legacy Security Policy at all).

Related

Visual Studio asks me to reference a nonexistent assembly

I somehow brought my project to a state where Visual Studio 2013 fails to compile it with a ridiculous error:
The type 'System.Collections.Generic.Dictionary`2' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
First of all, there is no such assembly, it does not exist.
Second, Dictionary<TKey, TValue> is defined in mscorlib.dll, which is referenced by default, of course. Resharper (which has its own code analysis engine) reports that the solution should compile normally.
I don't know how on Earth it could happen, because my latest changes have nothing to do with the supposedly erroneous place at all. The line references some standard LINQ functions (GroupBy and ToDictionary), and it worked for months without any changes. Unfortunately, I cannot create any MREs: obviously, this error only appears in the context of my huge solution, and only with some specific changes made in the presumably irrelevant places.
Here's what I tried, and it didn't work:
Clean + Rebuild
Changing target Framework from .NET 4.5 to .NET 4.5.1 or .NET 4.0
Has anyone seen such a quirk before?
I had the same problem, but it was on a website project - not any easy way to remove & re-add the references. Luckily, I found that this answer worked for me - and was even quicker than messing with references
https://stackoverflow.com/a/29575865/3841490
adding a new assembly tag to web.config seems to have resolved this
issue. The tag I added was under the tag and as follows:
<assemblies>
<add assembly="System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
I had the exact same issue and it seemed to be related to two NuGet packages containing the same assembly "System.Collections.Immutable". The two NuGet packages where "Microsoft.Bcl.Immutable" (Unlisted) and "System.Collections.Immutable".
I haven't been able to reproduce the issue reliably, and it seems the problem was solved by using VS2015.
However, i would suggest looking for NuGet packages containing the same assembly.
Removing Microsoft.Bcl.Immutables solved this for me.
Check that all the (core .net) references in your project are valid and they all reference the same .NET framework version.
If in doubt, remove all references and add them again (using the 4.0.0.0) versions.
I had this happen to me once (with the exact same error) and it was due to some "screw up" on the version of the references. I never got to find out WHY it happened, but removing all references and adding them again worked for me.

Missing Method exception "System.Web.Routing.RouteValueDictionary System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)

I've created a new project in Visual Studio 2013.2 with WebAPI and MVC enabled. Right out of the box, compiling the generated project and running gives me the exception. Looking around here, I've come across the following two questions:
Mvc 5.1 MissingMethodException System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached
System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached
Both these answers involve assembly redirects; however, in my case the assembly redirects are present and I'm still getting an issue. My problem is that the GAC is loading version 3.00.11001.0 which is listed under assembly version 3.0.0.0 and my application wants 3.20.20520.0 which is also listed as assembly version 3.0.0.0. (Note that in diagnosing the project I installed the 5.2 pre-release nuget package, but I had the same problem with the original versions, I just don't have those readily available)
Since the GAC is preferred over the bin directory, it seems that my development machine will always pull the wrong file.
Is it safe to remove these files from the GAC? It appears that these are required for Visual Studio to produce Razor intellisense
Removing the Assemblies from the GAC did behave exactly as expected. The Razor intellisense for the project stopped working; however, the application began functioning properly.
You have to add the reference of System.Web to get it working.

Error registering package in Visual Studio 11

When I try to register a visual studio package using regpkg in Visual Studio 11 RC, I get the following error:
regpkg.exe /root:Software\Microsoft\VisualStudio\11.0 /codebase myvspackage.dll
Could not load file or assembly 'Microsoft.VisualStudio.Shell, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.
This worked fine with previous versions of Visual Studio. I'm working in a clean virtual machine that only has Visual Studio 2012 RC.
I've been surfing the web looking for a solution with no success.
If I just copy the Microsoft.VisualStudio.Shell.dll in my app location it works fine, but this dll is not redistributable, so... what's the right way of registering a package in Visual Studio 11?
Thanks in advance for your help,
Luis
I'll assume you also posted this to the MSDN forums since a question with identical text was posted there which I answered yesterday.
http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/96556cd4-44dd-4e01-8198-b83a66c6df26
In short it sounds like you have an explicit reference to v2 of Microsoft.VisualStudio.Shell.dll, James is incorrect in saying you aren't supposed to use this, this is simply MPF from 2005. Referencing it is perfectly fine. If you have an explicit version in the reference in the project file try dropping it, if not try adding the binding redirect mentioned in my MSDN forum post.
I have started a mail with the SDK team about this issue though I don't know if they will be taking any changes this close to release. Also, as an FYI, since Shell.dll is from 2005, it is nearing the end of its supported life, we generally support three versions of previous VS releases.
On release of 2012 the support will be 2008,2010, 2012. I suspect in the next release (after 2012) we may stop including Shell.dll (the 2005 version) entirely in the shipped product. Unless you need to run downlevel on say 2005 I would update the reference to one of the newer shell assemblies (like 9.0, 10.0 or 11.0)

Integrating IronScheme into Visual Studio 2010

Is there a way (or can anyone find a way) to import IronScheme into VS2010? I've already taken a look at this question, and I've done everything I could - I even edited the binary files involved to change the version numbers. My question: Does anyone have a solution for getting IronScheme installed into VisualStudio 2010? at present, following the directions to install it into VS2008 does not work for VS2010. Thanks in advance :)
Update 1: I suppose I should post the error I get when I try to follow the directions for installing it via commandline:
C:\Program Files\IronScheme>RegPkg.exe /codebase "C:\Program Files\IronScheme\IronScheme.VisualStudio.dll"
After I run that, I get a Windows 7 popup error:
RegPkg.exe Has Stopped Working - Windows is checking for a solution to
the problem...
When I click out of that, it gives me this error on the console:
Unhandled Exception: System.IO.FileNotFoundException: 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.
File name: 'Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.VisualStudio.Tools.RegPkg.Main(String[] arguments)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
I wrote the VS2008 plugin.
When VS2010, the whole API changed again, and if you have ever been in the VS SDK API, you will know it is a maze. I just did not feel like the effort again.
I have a bunch of great ideas but for the life of me I cannot even figure the simple stuff out.
If someone want to actually port my code from VS2008, I would appreciate it. It should not be too hard if you are a bit more familiar with the API than I am.
The source code for the VS2008 plugin is not currently available for the public. Please let me know if anyone is serious about so I can create a github (or similar) repo for it.
Update:
Created a github repo. The code is not the same as the existing DLL I distribute; it contains various half working ideas I was trying.
Update 2:
Here you go :) Very basic, but works on VS2010 and VS11 (should work on Express versions too). Source is in the vs11 branch of above mentioned github repo. It is just a subset of what the VS2008 plugin does as some features seem to be broken or have broken due to bit rot.
Update 3:
Seems the VS2010 plugin fails if only VS2010 is installed. Will have to investigate. Works fine if both VS2010 and VS11 is installed. FIXED :)
I have started rewriting a new plugin.
You can see the github repo for more details:
https://github.com/leppie/IronScheme.VisualStudio2
There is also a download available to try out :)

ReSharper isn't able to resolve Razor

I have an ASP.NET MVC 3 Solution within Visual Studio 2010 Premium with Service Pack 1.
In the Web.Config my ReSharper Version (Build 5.1.3000.12) isn't able to resolve System.Web.WebPages.Razor.*
For example
<sectionGroup name="system.web.webPages.razor"
type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup,
System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
lets ReSharper mark the error Cannot resolve symbol 'Razor' and error Invalid module qualification: Failed to resolve assembly System.Web.WebPages.Razor
But all views (*.cshtml) are working fine and ReSharper doesn't mark errors there. Also under References I included System.Web.Razor.
This errors also appeared with Visual Studio Premium without Service Pack 1. I'm getting this errors even if I create a new MVC 3 Project out of Visual Studio.
Thanks in advance for any help.
Resharper 5.1 doesn't support Razor, 6.0 will. You can download and use the nightly builds if you like, but they can be somewhat unstable. Use at your own risk.
As others have cited, this is a feature not a bug ;-)
If you would like to avoid annoyance with these errors, you may right click "web.config" in the "Errors in Solution" window (ReSharper -> Windows -> Solution Errors Window) and choose "Ignore Errors." Then they won't bug you any more.
Another plug for the ReSharper EAP program, I used it with 5.0+ and found it to be a reasonable way to get the latest and greatest. As others have said, your stability mileage may vary as these are nightly builds.
http://confluence.jetbrains.net/display/ReSharper/ReSharper+6.0+Nightly+Builds

Resources