0
votes

I have a C# class library project which defines some windows forms controls. This library targets .NET 3.5 and is called from a C++/CLI windows forms project which targets .NET 4.0. I would like to avoid having my application loading/requiring multiple .NET runtimes. Is it safe if I simply changed the target framework of the class library to .NET 4.0? Are there any other changes I need to make? What incompatibilities (if any) exist when moving from .NET 3.5 to .NET 4.0?

There are no other clients using the windows forms library except for the windows forms application I mentioned.

2
No changes to the class library project are required, the CLR automagically maps 3.5 to 4.0 types. There were some breaking bug fixes in 4.0, the odds that you took a dependency on such a bug are extremely low. Do keep in mind that the future for C++/CLI Winforms projects is cloudy with a chance of meatballs, VS2012 took the first drastic step by removing the project templates.Hans Passant
@HansPassant Going forward what is the preferred UI platform for C++ based windows GUI apps?Agnel Kurian
Well, look around you. In my neck of the woods everybody is using a browser or a phone these days.Hans Passant

2 Answers

1
votes

I found this page on MSDN, which seems to highlight some migration issues.

http://msdn.microsoft.com/en-us/library/vstudio/ee941656%28v=vs.100%29.aspx

If your C# library depends on third party components, you may want to also review what framework dependencies they may have.

If you do not have any framework restrictions from researching the above, it should be relatively safe to just change the target version of the framework in the Application section of the Project Settings. If you do not receive any compile errors, you should just test your application to verify how it responds.

0
votes

As Windows Forms hasn't changed all that much since 3.5 I'm pretty certain you're not going to encounter any issues, such as breaking API issues, it should just be a simple recompile.

Even if you're referencing libraries which use an older version of the .NET framework it will still work due to Side-by-Side execution. But even still if possible I would update the third party libraries for releases for .NET 4.0

I would also add that .NET 4 Winforms applications can reference.NET 3.5 class libraries again using side-by-side execution.