Upgrading .net frame work to .net 6 win forms results in UI being larger - upgrade

I i've upgraded winforms from .net framework to .net 6 without compile issues an builds and runs however as the UI is slightly larger. This makes most of the app out of order in terms of size (things are getting cut off or not appearing as they are off the control etc).
i've checked the designers for both controls and the size values are the same between the framework version and .net 6 version
is there some setting in the project files which was shrinking control UI in .net framework?
an example this is the .net framwork version
and this is the .net 6 version
below is what it looks like at run time, the .net6 being in red and .netframework version being in blue

Adding this line seems to have resolved the issue in the startup / program.cs class https://www.codeguru.com/csharp/windows-forms-gets-font-changes-designers-and-more-in-net-6-0/
[STAThread]
public static void Main(string[] args)
{
.....
Application.SetDefaultFont(new Font(new FontFamily("Microsoft Sans Serif"), 8f));
......
}

Try replacing all instances of AutoScaleBaseSize with AutoScaleDimensions using a solution-wide replace. This seems to fix the problem for us when using the new WinForms designer.
UndeadEmo's answer was also helpful but seems to only correct the issue at runtime.
See also: https://github.com/dotnet/winforms/issues/1827#issuecomment-529831732

Related

Trying to upgrade, from EF4.1 to EF6.1, ObjectContext reference code?

I am trying to upgrade my MVC3/.NET4.5 application to use EF6.1, in the main part for its performance improvements.
One of my problem code lines is :
private AppEntities db = new AppEntities();
I have removed system.data.entity from references and web.config, but this line still seems to be looking for this dll. I did try and add:
using System.Data.Entity.Core.Objects.ObjectContext;
Did not seem to fix the issue with AppEntities line trying to find system.data.Entity v4.0.0.0
Many thanks
EDIT:
I managed to sort this by adding:
using System.Data.Entity.Core.EntityClient;
using System.Data.Entity.Core.Objects;
to AppEntities.cs file.
Also needed to add to some of the POCO files.
using System.Data.EntityClient;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
It all builds fine.
However my problem now is that it seems to take an age to show the page on first load, guess this is to do with native code creation. Also I have heard that much EF code that was native in .NET is now MSIL in Entity Framework.dll and thus need compiling to native code as well. Perhaps this is what is causing my pain, see: EF6 Warm up metrics

Infragistics UltraWebGrid client side events broken in .NET 4.5

I've recently updated my ASP.NET project to .NET 4.5 (from 3.5) . This led to ClientSideEvents not firing properly on my Infragistics UltraWebGrid.
The problem is that in my .aspx file I have configured a client side event on the UltraWebGrid like this:
<ClientSideEvents ClickCellButtonHandler="webGridSoftwareConfigurations_CellClickHandler" />
And in a js-file I have the following:
function webGridSoftwareConfigurations_CellClickHandler(gridName, cellId) {
// Do some stuff
}
Previously, when I clicked in a cell, the javascript function was triggered. But now after the update to .NET 4.5, nothing happens. I'm using Infragistics2, Infragistics.Web.dll with version 11.1.20111.2112
I think the root of my problems were actually caused by the fact that ASP.NET 4.x changes how the controls ids are generated. Before, the ids were prefixed with ctl00 and the older Infragistics NetAdvantage controls seem to be dependent of this.
My solution was to:
First, update Infragistics NetAdvantage to a more recent version (NetAdvantage 2011). There are newer version but this one still supports .NET 3.5, and I need this since I can't update all my projects that use Infragistics NetAdvantage to .NET 4.5
And then update the web.config so that we use the old way of naming controls:
<configuration>
<system.web>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" >
Thanks to this answer, and this blog post by Scott Gu.

What's the .NET 4.5 equivalent to UserNameWSTrustBinding?

I am converting a active profile STS to the new .NET 4.5 System.IdentityModel framework. My code using the UserNameWSTrustBinding which doesn't seem to exist in the new framework. Any suggestions.
Although this is an old question, I couldn't find any non-third-party answer on the internet, so here it is:
To replace UserNameWSTrustBinding in .NET 4.5, use the following:
var binding = new WS2007HttpBinding(SecurityMode.{what it was before});
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
I ported the WCF bindings to thinktecture identity model:
https://github.com/thinktecture/Thinktecture.IdentityModel.45
I also had a hard time finding something that for .NET 4.5 that was not a third party library. But I came across this link for code you can include in your project.

What are the Basic different between MEF for framework 3.5 and MEFfor framework 4.0?

I try to below link for window application with MEF
http://geekswithblogs.net/malisancube/archive/2009/05/26/managed-extensibility-framework-101---a.aspx
it's work good in Framework 3.5 but when i try to develop same code for framework 4.0
not able to find below function
return container.GetExportedObject<Form1>();
please give me some properly example for window application with MEF where my container all the Usercontrols on Form
MEF was being developed pre-.NET 4.0 but it became an official part of the framework from .NET 4.0 forwards. The API you are looking for is actually the ExportProvider.GetExportedValue<T> method which CompositionContainer inherits from:
return container.GetExportedValue<Form1>();
GetExportedObject was renamed GetExportedValue, and it occurred with MEF preview 6, which means that blog post was actually based on quite an early revision of MEF.

LinkBuilder.BuildUrlFromExpression not working anymore in .Net 4 / VS 2010?

I recently migrating my ASP.Net MVC 1 application from VS.Net 2008 / C# 3.5 to VS.NET 2010 / C# 4.0.
I massively used a builder to get URL strings from the strongly typed calls.
It looks like this :
// sample call :
string toSamplePage = Url.To<SampleController>(c => c.Page(parameter1, parameter2));
the code is added as an extension to the default UrlHelper :
public static string To<Tcontroller>(UrlHelper helper, Expression<Action<Tcontroller>> action) where Tcontroller : Controller
{
// based on Microsoft.Web.Mvc.dll LinkBuilder
return LinkBuilder.BuildUrlFromExpression<Tcontroller>(helper.RequestContext, helper.RouteCollection, action);
}
The only problem of this, is the reference to Microsoft.Web.Mvc dll, but the gain in readability was worth it.
Problem : it does not work anymore, return (null) whatever the parameters.
Questions :
is there a better way now to build links from an expression ?
(yes I tried to google it without success)
is there a trick to have the former LinkBuilder.BuildUrlFromExpression works ?
I tried to recompile it into C# 4.0, but the problem is that it implies working on my own compilated version of System.Web.Mvc which is not an option.
I'm currently trying to migrate to MVC 2 but I still have issues...
Waiting for your suggestions...
Our team overcame this identical issue by referencing System(Microsoft).Web.Mvc 2.0.0.0 statically in our libraries folder, as opposed to a GAC reference. This permitted us to continue working with MVC 1.0.0.0 projects and also gave us the downstream benefit of not having to install MVC 2 on our servers.
Oki, I found the problem.
I had assemblies versioning problems.
After rebuilding Microsoft.Web.Mvc + unistalling MVC 1 + refreshing all references it finally worked again.
It sucks because I still need MVC 1 for others projects, but at least my main problem has been solved.
To developpers new to the MVC framework : consider starting directly with MVC 2 / VS.Net 2010 / C# 4.0