Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU intensive process left running after closing a winforms .Net6 app that uses OleDB #76054

Open
ajos6183 opened this issue Sep 23, 2022 · 14 comments

Comments

@ajos6183
Copy link

Description

CPU intensive process left running after closing a WinForms .Net6 app that uses OleDB. I am not the first person to experience this. Please see following StackOverflow questions C# WinForm - EXE not terminating when closing main form & Reading access database, background process still running on close.

Reproduction Steps

Sample code attached WinFormsApp.zip. For the bug to be replicated, the exe must be opened outside of the visual studio environment.

Expected behavior

All processes would close on application exit.

Actual behavior

Process left running.

Regression?

This issue didn't happen in .Net framework as far I can tell but I didn't specifically test for it.

Known Workarounds

No response

Configuration

No response

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 23, 2022
@ghost
Copy link

ghost commented Sep 23, 2022

Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

CPU intensive process left running after closing a WinForms .Net6 app that uses OleDB. I am not the first person to experience this. Please see following StackOverflow questions C# WinForm - EXE not terminating when closing main form & Reading access database, background process still running on close.

Reproduction Steps

Sample code attached WinFormsApp.zip. For the bug to be replicated, the exe must be opened outside of the visual studio environment.

Expected behavior

All processes would close on application exit.

Actual behavior

Process left running.

Regression?

This issue didn't happen in .Net framework as far I can tell but I didn't specifically test for it.

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: ajos6183
Assignees: -
Labels:

area-System.Diagnostics.Process

Milestone: -

@ghost
Copy link

ghost commented Sep 23, 2022

Tagging subscribers to this area: @roji, @ajcvickers
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

CPU intensive process left running after closing a WinForms .Net6 app that uses OleDB. I am not the first person to experience this. Please see following StackOverflow questions C# WinForm - EXE not terminating when closing main form & Reading access database, background process still running on close.

Reproduction Steps

Sample code attached WinFormsApp.zip. For the bug to be replicated, the exe must be opened outside of the visual studio environment.

Expected behavior

All processes would close on application exit.

Actual behavior

Process left running.

Regression?

This issue didn't happen in .Net framework as far I can tell but I didn't specifically test for it.

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: ajos6183
Assignees: -
Labels:

area-System.Diagnostics.Process, untriaged, area-System.Data.OleDB

Milestone: -

@ajcvickers ajcvickers added this to the Future milestone Sep 23, 2022
@ajcvickers ajcvickers removed the untriaged New issue has not been triaged by the area owner label Sep 23, 2022
@roji
Copy link
Member

roji commented Sep 24, 2022

I can confirm this indeed repros; however, changing the OleDB provider from ACE to SQL Server makes the problem go away - the process exits properly once the window is closed. In other words, this is most probably a problem with the ACE provider rather than System.Data.OleDB, and should be reproducible outside of .NET.

SQL Server repro details
CREATE TABLE MaterialTable (
    ID int PRIMARY KEY,
    material nvarchar(max)
);
INSERT INTO MaterialTable (ID, material) VALUES (1, 'Copper');

In the application, replace the connection string with the following:

Dim connect_string As String = "Provider=sqloledb;Data Source=localhost;Initial Catalog=test;User Id=SA;Password=Abcd5678;"

@roji roji removed this from the Future milestone Sep 24, 2022
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 24, 2022
@ajcvickers
Copy link
Member

@roji Did you intend to do something here for 7.0?

@roji
Copy link
Member

roji commented Sep 26, 2022

No, as far as I can tell at this point, this isn't an issue in System.Data.Odbc and there's nothing actionable on our side - though I can't be 100% sure. We can keep this open and move to Future, trying to bring this to the attention of the ACE OleDb driver maintainers.

@ajcvickers ajcvickers added this to the Future milestone Sep 26, 2022
@ajcvickers ajcvickers removed the untriaged New issue has not been triaged by the area owner label Sep 26, 2022
@ajos6183
Copy link
Author

ajos6183 commented Oct 4, 2022

@roji Thank you for your response. I will investigate your suggestion of changing the OleDB provider from ACE to SQL.

@roji
Copy link
Member

roji commented Oct 4, 2022

@ajos6183 rather than switching from ACE to SQL Server (which is quite a big type of change), I would recommend switching from OleDB to ADO.NET, which is the modern way to access databases in .NET. At that point you can use SQLite, which should be more similar to ACE than SQL Server (both being embeddable, single-file databases).

@rutledget
Copy link

@ajos6183 rather than switching from ACE to SQL Server (which is quite a big type of change), I would recommend switching from OleDB to ADO.NET, which is the modern way to access databases in .NET. At that point you can use SQLite, which should be more similar to ACE than SQL Server (both being embeddable, single-file databases).

In regards to #76712 , we are using ADO.NET with System.Data.OleDb provider. We can't exactly tell a client to 'use SQLite' when the issue arises from client importing data from Access databases into the application. The problem is not consistent across all machines that have the same .NET and same Office version; I agree it is likely an ACE or general office issue. The problem is consistent with .NET 5 and .NET 6; Framework 4.8 does not exhibit this behavior. Of course, 4.8 cannot see O365 dll's and require the Access runtime be separately installed. However, the problem also does occur in NET 5/6 when Access runtime is separately installed.

The problem may arise in the ACE driver, but the NET application is stuck in endless loop of exception handling.

@roji
Copy link
Member

roji commented Oct 6, 2022

I'll try to take another look at this soon; the information that this works on .NET Framework 4.8 may indicate an issue in .NET 6, since I'm assuming the same native ACE DLL OleDb driver is being used.

@ajos6183
Copy link
Author

ajos6183 commented Oct 6, 2022

Thanks guys, just an update that the issue seems to be resolved. A windows update may have taken care of the ACE issue. I suspect it is KB5002243 but i can't be sure. However, as @rutledget pointed out, the issue with the .NET5/6 exception handling may still exist and require attention.

@roji
Copy link
Member

roji commented Oct 6, 2022

@ajos6183 thanks for the info! To be sure I understand, are you saying that after KB5002243, everything works well for you and there's no issue using ACE from .NET's System.Data.OleDb? In other words, do you suspect that there's a bug in .NET's System.Data.OleDb that only manifests when using a pre-KB5002243 ACE driver?

@ajos6183
Copy link
Author

ajos6183 commented Oct 6, 2022

@roji yes, I believe so. My testing from yesterday and today shows that all processes exit when I close the application. Whereas before, a process was left which used 100% of a CPU core. No changes were made to the application.

@roji
Copy link
Member

roji commented Oct 7, 2022

Thank you! I'll try to take a look, though it may take a while before I'm able to do so. In the meantime it's good to know that installing KB5002243 can be a good workaround.

@ajos6183
Copy link
Author

ajos6183 commented Oct 18, 2022

Hi @roji , unfortunately, this is happening again. I can't explain why. There were a few security updates for Office 2016 and the .NET 6.0.10 update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants