Adding multiple versions of WinForms control in Visual Studio Toolbox - winforms

I have multiple DLLs of a WinForms control targeted for different versions of .NET Framework and need to add them all in a Visual Studio Toolbox while showing only the one which is most suitable for currently selected version of .NET.
The control have different features when compiled against different versions of .NET, this is why it would be best to show the most "native" version only. For example, the control have some features removed in .NET 4.0 Client Profile or makes use of .NET 3.0 features when available (not avaiable in .NET 2.0).
The problem is that the control have same name and is signed with same Strong Name Key (SNK).
I can modify source code, but what to do to enable all versions of the component to reside in VS Toolbox?

Related

Adding 3rd party controls to .NET Core WPF application

Section Controls, NuGet Packages, and Existing Assembly References of .NET Core 3 release notes on Support for Windows Desktop Applications states the following:
Desktop applications often have many dependencies, maybe from a
control vendor, from NuGet or binaries that don’t have source any
more. It’s not like all of that can be updated to .NET Core 3 quickly
or maybe not even at all.
As stated above, we intend to support dependencies as-is. If you are
at the Build conference, you will see Scott Hunter demo a .NET Core 3
desktop application that uses an existing 3rd-party control. We will
continue testing scenarios like that to validate .NET Core 3
compatibility.
I created a WPF application targeting .NET Core 3 in VS 2019 using dotnet new wpf command, and it works fine.
However, when I add a 3rd party WPF control from NuGet (control was built targeting .NET Framework 4.6.1) I get the following error message:
Warning NU1701 Package 'Syncfusion.Shared.WPF 16.4.0.52' was restored
using '.NETFramework,Version=v4.6.1' instead of the project target
framework '.NETCoreApp,Version=v3.0'. This package may not be fully
compatible with your project.
The application still builds successfully but when I attempt to run the application public MainWindow() throws :
System.Windows.Markup.XamlParseException: ''The invocation of the
constructor on type 'Syncfusion.Windows.Tools.Controls.GroupBar' that
matches the specified binding constraints threw an exception.' Line
number '16' and line position '10'.'
Was anyone able to add a reference to a 3rd party WPF control to a WPF application targeting .NET Core 3 and if so what is the trick?

Building Windows Presentation Form for multiple versions of .net

I am building a windows presentation form application. The issue I have is that my co-workers have different versions of .net installed on the desktops. If I build it on my machine which has .net version which is 4.6. When another person has a lower version of .net it fails. I can build the application multiple time with different version of .net but I would like to avoid that. So is there a way in Visual Studio to build a WPF that will work on multiple platforms and versions of .net?
You can change your target framework in the project properties (right click the project and select Properties):
Because higher .NET versions are backwards compatible with earlier versions, you can target a lower version that what is on your machine, though it means that you lose out on the newer apis.
So, for example, if you and your colleagues decide that .NET 4.0 is a good target, then having .NET 4.5 or .NET 4.0 will work for building and running the application.
For more information on Framework Targets, see:
What does it really mean to target a framework, and how do I maximize compatibility?
What is the effect of setting a “Target framework” in Visual Studio

Installed .Net Framework 4.5 and Visual Studio 2012, My WPF version is still showing 3.0

I followed the following link http://msdn.microsoft.com/en-us/library/aa349641.aspx and found out that my WPF version is 3.0.6920.2011 even though I have already installed .Net Framework 4.5 and Visual Studio 2012. How can that be? I can not write XAML to exploit the new features like Ribbon (cannot find it in the toolbox) with current version of WPF. Thanks.
Right click on References in your project in solution Explorer, choose Add Reference, then enter Assemblies -> Framework, find PresentationCore/PresentationFramework. There you can find version used by your projects.
Note that in some cases - for example if you want to use Ribbon presented in newer WPF, you will have to add suitable reference.

Silverlight 3 and Silverlight 4 Coexistance

I work on several projects with different development environments. I would like to maintain a Visual Studio 2008/Silverlight 3 environment on the same development workstation as a Visual Studio 2010/Silverlight 4 environment. If possible, I would like to be able to work on both at the same time, without using virtual machines.
Has anyone done that successfully? Is there anything special I need to do to help them coexist? I previously installed Silverlight 4, and it prevented me from working in the Visual Studio 2008/Silverlight 3 environment. But it is possible that I did something wrong in the setup.
I don't think the two can coexist next to each other. You will either need to make a VM with the specified configuration, or specify the SL version in Visual Studio.
Can you ellaborate why you can't run you SL3 project in VS 2008?
Could you use VS 2010 for your SL3 work? VS 2010 includes multi-targeting capabilities, and is compatible with Silverlight 3 out of the box. SL4 support is added with the SL4 development tools, so at that point it supports both.
You can pick which Silverlight version you want each project to be either at project creation time (for new projects), or in the project Properties (for existing projects).

Silverlight 3.0: Can't add references beyond v2

I wanted to add System.Data.Linq to my Silverlight 3.0 app, but the only references that are available to me are listed as version 2.0.50727 or lower. Shouldn't I have access to more than that?
In my project's properties, my Target Silverlight Version is set to "Silverlight 3.0" (the only option), and I'm using Visual Studio 2010 Beta 2.
Is this expected behavior, or should I be able to add that reference, and more?
You can't access System.Data.Linq in Siverlight, this dll would make no sense in the sandboxed client-side silverlight runtime. Hence no such silverlight dll exists. What you probably need to be looking into is Entity Framework on the server plus WCF to access the data from Silverlight.
For reasons best known by Microsoft all the standard Silverlight dlls have the 2.0.5.0 version numbers even the new ones added to the Silverlight 3 SDK.
This is the version number of the controls in Silverlight 3. It confused me at first. Also it's System.Linq in Silverlight and should be included by default when you create a new project.
Silverlight 4 is a separate download to VS2010.

Resources