question

KeldSor-3611 avatar image
0 Votes"
KeldSor-3611 asked rijwanansari answered

Very slow starting of C# programs made with Visual Studio ??

Years back I made some C# programs and have used the EXE-files since then, but lately - a year or two - I noticed they are very slow to start - and we're talking 20-30 seconds from I 2-click to the userface shows up.

Why and how can I make them faster ?

dotnet-csharp
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Is it possible to recompile the projects using Visual Studio 2022, and maybe to use a modern .NET Framework, such as 4.8?


0 Votes 0 ·

THX, I'll try !

0 Votes 0 ·

we're talking 20-30 seconds from I 2-click to the userface shows up

Sounds like perhaps a virus program may be causing this, scanning the executable each time but also odd that it started all of the sudden. Another thought is a Windows update may be the issue.
0 Votes 0 ·
Castorix31 avatar image
0 Votes"
Castorix31 answered

They start immediately on my OS, Debug or Release
(Windows 10 21H1, VS 2022)

Random exe =>

214224-startexe.gif



startexe.gif (187.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KeldSor-3611 avatar image
0 Votes"
KeldSor-3611 answered Viorel-1 commented

I now downloaded 4.8 as explaned here:

Severity Code Description Project File Line Suppression State
Error The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks KSPause

but still it wants I get this error !

I think it has to do with references ... but where are they 'hidden' in the VS2022 ... I haven't worked in VS since VS2008 !

· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I think it has to do with references ... but where are they 'hidden' in the VS2022

This means the project is targeting .NET Core Framework not the old .NET Framework.
0 Votes 0 ·
KeldSor-3611 avatar image KeldSor-3611 karenpayneoregon ·

What should I then do instead ?

0 Votes 0 ·

Pick green which is classic .NET Framework while red is .NET Core Framework

214363-f1.png


0 Votes 0 ·
f1.png (19.5 KiB)
Show more comments

Did you open the original project in Visual Studio and did it ask to use the new .NET Framework 4.8 automatically?


0 Votes 0 ·

I tried to open my VS2008 project in VS2022 - I then was forced to UPDATE it and succeeded - then compiled and then came the error message shown earlier.

0 Votes 0 ·

My advice is to never open a old project in a new version of Visual Studio, always make a copy and use the copy. Also, consider using some form of source control such as GitHub which is a) free b) works in Visual Studio. There are plenty of information out there to get started with Visual Studio and GitHub.

0 Votes 0 ·
Viorel-1 avatar image Viorel-1 KeldSor-3611 ·

Is it a Windows Forms application that contains just sources (no other libraries)?

Did you check if the Solution Explorer window and Project Properties look familiar?


0 Votes 0 ·
rijwanansari avatar image
0 Votes"
rijwanansari answered

Hi @KeldSor-3611

Since your application is using older version of .Net Framework, it is recommended to upgrade to latest version. However, it is not only the reason for slowness.

You can do following troubleshoot:
1. Check startup functions like form load or preload. You can write log with time to know the execution time.
2. Avast Antivirus also uses a technique called "Deepscreen" which check excutable files before they are allowed launch. I added an exception for the path to the application in Avast Exlusions setting screen and it now starts instantly without any abnormal delay.
3. Check if you are connecting to any external DB or Network files are okay
4. Also use release file not debug one
5. Try with some other machines to verify


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.