0

The difference between my question and previously asked questions is that I don't mind having .NET 4.5 installed on the server or the development environment. However, I don't currently intend to change the target framework of my original 4.0 projects in the solution. I wish to have only one new project that targets .NET 4.5 and have one of the other 4.0 projects call it. I tried to add existing item and 'Add as Link' as described here but that didn't help. Can my purpose be implemented anyhow? I don't mind adding a web service to one of my projects if that would be a resolution.

Community
  • 1
  • 1
yazanpro
  • 4,512
  • 6
  • 44
  • 66
  • Why not change the framework from 4.0 to 4.5? You've already made it clear you're willing to modify things. Why not just flip it, then run through your tests and verify the functionality and be done with it? Most likely you won't have to change any code, just test. – mason Aug 05 '14 at 20:24
  • You can reference a 4.5 assembly from a 4.0 project using Reflection. – Golden Dragon Aug 05 '14 at 20:39
  • That seems promising. Can you please provide a link or description? – yazanpro Aug 05 '14 at 20:41
  • 2
    Doing it via reflection means making a modification to your code, perhaps many modifications. That's likely to be buggy and difficult if you haven't used it before. Instead, just recompile and test. Most likely you won't have to change code. Preferably you should have automated unit tests you can run, but if not then it might take a little bit of time to manually do it, but still far less than rewriting it to use a web API or reflection. See [Application Compatibility in the .NET Framework 4.5](http://msdn.microsoft.com/en-us/library/hh367887(v=vs.110).aspx). – mason Aug 05 '14 at 20:45

1 Answers1

3

An assembly/application that is targeted to 4.0 will not be able to make calls to classes/methods in 4.5. If you cannot update the targeting to 4.5, then splitting your app into two separate apps and using webservices would work, as long as your client application doesn't need the 4.5 framework to consume those services (e.g. a data type only in the 4.5 framework.)

Dave Swersky
  • 34,502
  • 9
  • 78
  • 118