Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update the maximum message length in the EventLog.WriteEntry method documentation#9999

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
0xced wants to merge1 commit intodotnet:main
base:main
Choose a base branch
Loading
from0xced:patch-1

Conversation

0xced
Copy link

Summary

It was found empirically on Windows 10 that the maximum message length is 31,718.

It was found empirically on Windows 10 that the maximum message length is 31,718.
@0xced0xced requested a review froma team as acode ownerJune 6, 2024 13:26
@dotnet-policy-servicedotnet-policy-servicebot added the community-contributionIndicates that the PR has been added by a community member labelJun 6, 2024
@dotnet-policy-serviceDotnet Policy Service
Copy link
Contributor

Tagging subscribers to this area:@tommcdon

@learn-build-service-prodLearn Build Service (PROD)

Learn Build status updates of commita78d259:

✅ Validation status: passed

FileStatusPreview URLDetails
xml/System.Diagnostics/EventLog.xml✅SucceededView

For more details, please refer to thebuild report.

For any questions, please:

@gewarren
Copy link
Contributor

@tommcdon Could you review?

@tommcdon
Copy link
Member

.NET is usingReportEvent, and according to the Windows documentation forReportEvent, our existing documentation is correct:

https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-reporteventw

[in] lpStringsA pointer to a buffer containing an array of null-terminated strings that are merged into the message before Event Viewer displays the string to the user. This parameter must be a valid pointer (or NULL), even if wNumStrings is zero. Each string is limited to 31,839 characters.Prior to Windows Vista:  Each string is limited to 32K characters.

The .NET code that callsReportEvent is checking 32K-2 characters:

https://github.com/dotnet/runtime/blob/c1a9f26efa4fcf2e3fdcd8557da19d358f51eb00/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogInternal.cs#L1354-L1357

// make sure the strings aren't too long.  MSDN says each string has a limit of 32k (32768) characters, but// experimentation shows that it doesn't like anything larger than 32766if(strings[i].Length>32766)thrownewArgumentException(SR.LogEntryTooLong);

Therefore, the error would likely be coming from Windows and not .NET for string lengths <= 32766 characters. Given that .NET has no control over the version of Windows and the various character limits it is imposing, I suggest we remove mentions of specific character limits under 32766 characters.

Also I would expect that if the string length is <= 32766 and the API call fails due to a restriction from Windows, we would get a Win32Exception and not an ArgumentException.@0xced can you confirm?

If yes, then I suggest changing the text to something like:
The message string is longer than 32,766 bytes.

Copy link
Member

@tommcdontommcdon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I left a comment for your review

@gewarren
Copy link
Contributor

@0xced Do you plan to address the requested changes?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tommcdontommcdontommcdon requested changes

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
area-System.Diagnosticscommunity-contributionIndicates that the PR has been added by a community member
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@0xced@gewarren@tommcdon

[8]ページ先頭

©2009-2025 Movatter.jp