3

I have an ASP.NET project that was working correctly compiled with Visual Studio 2010 and NET4.0.

Then I have installed VS Express 2012 and NET4.5 and I always get an Exception trying to open a SqlConnection.

Can I have some chance to recompile my project targeting NET4.0 (so without disinstalling 4.5) and have it working?

In VS Express 2012 I have this web.config:

<system.web>
<compilation debug="true" targetFramework="4.0"/>

The referenced assemblies correctly target the v4.0, for example:

Assembly System.Data
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll

EDIT 2 As this blog http://blogs.msdn.com/b/msbuild/archive/2007/04/12/new-reference-assemblies-location.aspx and also this answer https://stackoverflow.com/a/8543850/1012244 explains very well, there is a BIG difference betweeen Referenced Assemblies (folder contains those assemblies that ship with the x.xx Framework which are useful for referencing during the design and build of new components) and Runtime scenario (At runtime, these components will still be loaded from the GAC in most cases).

However, when I run the project I always get the Exception, as if the project actually was using NET4.5... Why?

PS. If I deploy this project on a production server machine with only NET4.0 installed, the connection is fine. (This is clear now: Installing Net4.5 essentially replaces Net4.0)

UPDATED QUESTION - Can I have some chance to recompile my project targeting an OLD NET4.0 .dll (System.Data.dll in my case) instead of the new Net4.5 dll?


EDIT - Additional info

At this MSDN link http://msdn.microsoft.com/en-us/library/ff602939.aspx I found:

If you determine that a change in the .NET Framework 4.5 has broken your application, check the Runtime Settings Schema to determine whether you can use a runtime setting in your application configuration file to restore the previous behavior.

Could this help me? And how?

Community
  • 1
  • 1
spiderman
  • 1,565
  • 2
  • 16
  • 37
  • Whats the "Exception" ? Try to solve the problem not to go back, from the moment you have 4.5, forget the 4.0, is not exist any more. – Aristos Jun 05 '13 at 10:22
  • The Exception is SqlException: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.) – spiderman Jun 05 '13 at 10:25
  • @Aristos I have posted another thread for it [link](http://stackoverflow.com/questions/16911681/a-connection-was-successfully-established-with-the-server-but-then-an-error-occ) – spiderman Jun 05 '13 at 10:26

0 Answers0