XSL Transformation fails in VS2010 when NetFx40_LegacySecurityPolicy enabled - visual-studio

I recently upgraded a VS2008 project to VS2010. This is a rather large legacy project, passed through many developer hands but with ongoing development.
It uses Devexpress 9.1 and after the upgrade all Forms\Controls refused to load at design time with a message about "Explicitly us[ing] CAS policy, which is obsolete" - this was fixed by adding the following to devenv.exe.config file:
<NetFx40_LegacySecurityPolicy enabled="true"/>
Unfortunately this seems to have an unintended effect in that it broke XSL Transforms in the project. The project also uses a custom ORM system, apparently developed just before Entity-Framework became popular (why they didn't use nHibernate I'm not sure, but the original developers apparently decided they could do a better job themselves) So it consists of a huge XML file defining the Objects and a large XSLT file to transform this into a cs file.
But after adding the above NetFx40_LegacySecurityPolicy switch now running the XSL Tranform (by just selecting the XSLT file and using "CTRL-ALT+F5") results in the following error:
The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag.
Removing the NetFx40_LegacySecurityPolicy flag fixes this but breaks all Forms\Controls again.
Anybody have any idea how I can use XSL transformation in Visual Studio 2010 with the NetFx40_LegacySecurityPolicy enabled?
EDIT:
Even worse, it seems that having this enabled breaks all MVC tooling in visual studio with the same error message. e.g. I can no longer add MVC views. Ouch.

Related

Conditional Compilation Symbols not working

There are plenty of reported bugs in almost every version of Visual Studio with similar or exactly the same issue. The problem is that every bug report I found has been already resolved. Additional info: My exact same code has worked a month ago. I am using .NET Core 3.1.100 and Visual Studio 16.4.2.
Project GUI
.csproj Configuration
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Demo|AnyCPU'">
<DefineConstants>DEMO</DefineConstants>
</PropertyGroup>
Code (as you can see, the DEMO symbol will not be applied).
Has anyone an idea how to hotfix this issue for my production environment?
Thanks in advance!
This is not how this should be done in ASP.NET Core. ASP.NET Core doesn't use the concept of build configurations natively, and while you can sort of use them in places like this or compiler directives, it goes against the grain of ASP.NET Core app design. ASP.NET Core apps are build once, deploy anywhere, in contrast to ASP.NET where you needed to build for each environment separately.
Instead, this should be handled via config and environments. You can even have a "Demo" environment, if you like, which would then allow you to just inject IWebHostingEnvironment and check _env.IsEnvironment("Demo"). Short of that, you should simply specify via config (JSON, environment variable, etc.) a "Demo" boolean, and then pull that out of IConfiguration.

Porting VS2005 project to VS2008

i need to port a VS2005 Project (.NET2) to a VS2008 (.NET3.5) (or to VS2010 .NET4 not yet defined).
The project is composed by:
resources and configuration files (VS project files, like: .settings
.vbproj .myapp .config .xconfig .Designer.vb);
a lot of VB codes;
xsc, xsd, xss and xsx files;
a lot of Crystal reports for VS2005;
graphical resources.
The application take data in order to generate reports from more DB SQL Server 2005 istances.
What is the best way to approach to a migration activity?
Is there an internal migration tool?
If yes, what's the best practice to use it?
Which kind of files will be automatically ported to the new VS version?
Thanks in advance for all the provided information
It should be backward compatible.
Therefore, you should be able to simply open the project in the target version of Visual Studio and perform a conversion if required (for the project files). I suggest taking a backup first however, just in case.
Then compile test and test some more.
Should be fine.

Custom attributes are not consistent errors moving a VS 2008 solution to VS 2010

I'm trying to move my VS 2008 solution to VS 2010. Everything works perfectly (compile and link) if I keep the target framework at 4.0.
When I change the framework 2.0 and change the platform framework v100 (to get past compile errors) only to run into metadata linking errors, like this one:
error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000f7). C:\Development\Main\Filemaster\SoxService\MSVCMRTD.lib(managdeh.obj)
I've read that I'm supposed to use ILDAsm but it doesn't like my obj file and since the link didn't complete I don't have an exe to load.
Can anyone please provide some advice on how to find the sorts of errors?
I hate nothing worse than fighting the tool!
I was able to get around this problem by going into the project XML file itself and changing the TargetFramework to be 4.0 After that everything compiled and linked fine.
Hans he is referring to C++ Native Multi-Targeting which can be found at this location Platform Framework can be changed under project Properties > General and is advised by the article - however this does not work due to apparent bugs in VC++

Planning to upgrade VS 2005 to VS 2010

I have installed VS 2010 and want to migrate all code written in VS 2005 to VS 2010.
Please note that we do not have VS 2008, all code are in C# 2.0 and Asp.net 2.0 only.
Can anyone please tell me now what all points need to be considered while migrating.
Update:
I have set target framework to 2.0 for all of my Libraries and web projects. It complies without any error!
However, when site opens in IE (Set to default.aspx), it gives me error as below:
InternalXmlHelper.vb(9) : error BC30560: 'ExtensionAttribute' is
ambiguous in the namespace 'System.Runtime.CompilerServices'.
<Global.System.Runtime.CompilerServices.ExtensionAttribute()> _
Keep all the target framework settings to .NET 2.0. This way, there should be no compilation problem at all.
The changes that you should see are the solution and project files only.
Start with known good solutions in source control (and label—you shouldn't need to go back, but easy to add an extra safety net).
Open each solution in VS2010, allow the conversion wizard to do the conversion.
Resolve any issues.
Honestly, if you're just upgrading VS 2010 you don't really need to consider much. Just keep backups (any real SCM product will do) and you're good. You don't have to upgrade your applications' runtime targets at all if you don't want to.
If you're building with CAS policy, you might run into issues with using MSBuild 4.0 to build you 2.0 applications. If you don't know what I'm talking about, never mind.
My advice is to make sure everyone's "checked in" to your source code provider, and run the conversion wizard and see how it goes.

automate adding references in large VS solution

I'm working on a VS solution with 100+ projects in C#. I'm currently migrating it from VS 2008 to VS 2010. There is some work to be done because a lot of the projects use Enterprise Library 4 (which has to be upgraded to 5.0) and WCSF 2008 (which has to be upgraded to SCSF 2010). I'm going through the SCSF upgrade instructions, and one involves doing this:
Add a reference to the following
Service Location assembly in each
project that has a reference to an
Enterprise Library assembly.
Microsoft.Practices.ServiceLocation.dll
Is there any way to do this without going through the IDE? I mean, opening up each of 100-odd projects, then checking the references, then adding a reference if necessary, is one way of doing it, but is there a faster way? I was thinking along the lines of doing a search over the project files for a particular reference, then doing an insert if it was found.
If you've done this kind of thing before, suggestions would be very welcome. Thanks.
If you want to do this through the IDE, you can write a macro using VSProject.References to add/remove references as necessary.
However, C# project files (.csproj) are just XML, so you may be able to write a simple utility that can adjust the file as necessary using the standard XML classes.

Resources