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

ObjectDisposedException in TelnetAppender (3.0.1) #194

Closed
VianneyTremelo opened this issue Oct 14, 2024 · 6 comments · Fixed by #195
Closed

ObjectDisposedException in TelnetAppender (3.0.1) #194

VianneyTremelo opened this issue Oct 14, 2024 · 6 comments · Fixed by #195
Assignees
Milestone

Comments

@VianneyTremelo
Copy link

VianneyTremelo commented Oct 14, 2024

I migrated two (C#) applications to the version 3.01. And I've now an exception : "System.ObjectDisposedException: 'Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'.'" (see screenshot below)

  • When the application start on my first migrated application
  • When the application is disposed on my 2nd migrated application

The port that I use is not locked by another application, because if I rollback my changes and run my application with previous version of log4net (v2.0.1) => it's works fine.

My config:

<appender name="TelnetAppender" type="log4net.Appender.TelnetAppender">
  <port value="4060" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date{HH:mm:ss.fff} %-5level - %message%newline" />
  </layout>
</appender>

Error:

image

(edit - added from https://stackoverflow.com/questions/79053363/log4net-telnetappender-doesnt-work-after-migrate-to-log4net-3)
https://github.com/apache/logging-log4net/blob/Feature/TelnetBug/src/log4net.Tests/Appender/TelnetAppenderTest.cs
I tried to run the UnitTest (TelnetAppenderTest) in Execution mode : OK, no error.
But when I try to run it in debug, I have the same issue (but at the end). When the test tries to dispose the Telnet Client, an error "Cannot access a disposed object" appears (see screenshot link below). It's the issue that I have.
https://snipboard.io/Dnb8Vj.jpg

I migrated two applications: both have the same issue - One at the end, when the application are being to be dispose - The 2nd have the issue at the startup.

@FreeAndNil FreeAndNil self-assigned this Oct 14, 2024
@FreeAndNil
Copy link
Contributor

@VianneyTremelo thanks for reporting, I will take a look.

@VianneyTremelo
Copy link
Author

Additional information: I'm using VS 2022 and my applications run with DotNet Framework 4.8 on Windows 10/11

@FreeAndNil FreeAndNil changed the title Update to 3.0.1 bring issue on TelnetAppender ObjectDisposedException in TelnetAppender (3.0.1) Oct 15, 2024
@FreeAndNil
Copy link
Contributor

@VianneyTremelo I've found a bug in the Dispose logic (see #195).
Can you check whether this solves your problem?

@VianneyTremelo
Copy link
Author

@FreeAndNil : The ObjectDisposedException is now fixed. Thank you.
But on my side when I run TelnetAppenderTest into debug mode, an IOException appears (see screenshot: https://snipboard.io/GKjZW7.jpg)

Let me know when a new release with the fix will be available that I can double-check with my apps

@FreeAndNil
Copy link
Contributor

@VianneyTremelo can you please test with https://github.com/apache/logging-log4net/releases/tag/rc%2F3.0.2-preview.1
or https://www.nuget.org/packages/log4net/3.0.2-preview.1

@VianneyTremelo
Copy link
Author

I tested my 2 applications with v3.0.2-preview --> In the both cases, It's works fine !
Thanks you.

@FreeAndNil FreeAndNil added this to the 3.0.2 milestone Oct 15, 2024
FreeAndNil added a commit that referenced this issue Oct 17, 2024
#194 fixed a bug in the Dispose-Logic of TelnetAppender
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants