-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
EventLogRecord.GetFormatDescription() throws "The specified resource type cannot be found in the image file." exception #56469
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
We handle various error codes to cover the case where the formatting of the message fails In the case of ERROR_EVT_UNRESOLVED_VALUE_INSERT we just return what we have figuring it has some value. For ERROR_EVT_MESSAGE_NOT_FOUND, ERROR_EVT_MESSAGE_ID_NOT_FOUND, ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND, ERROR_RESOURCE_LANG_NOT_FOUND, ERROR_MUI_FILE_NOT_FOUND we return null (which does not seem documented). Presumably that at least allows an app to continue enumeration. In all other cases, like this, we throw. This pattern is unfortunately duplicated across 8 places. Per this issue ERROR_EVT_UNRESOLVED_PARAMETER_INSERT which it suggests to treat the same as ERROR_EVT_UNRESOLVED_VALUE_INSERT , ie return the string. It seems they debugged and verified that there is a useable string in this case, albeit not fully formatted. The above issue is encountering another error, ERROR_RESOURCE_TYPE_NOT_FOUND. I do not know whether there is a useable string in this case, but most likely not. My suggestion is that we treat ERROR_EVT_UNRESOLVED_PARAMETER_INSERT the same as ERROR_EVT_UNRESOLVED_VALUE_INSERT (return the string) and ERROR_RESOURCE_TYPE_NOT_FOUND the same as ERROR_EVT_MESSAGE_NOT_FOUND (return null). And we do this in all 8 places where we have this pattern. @dotnet/area-system-diagnostics-eventlog @stephentoub seem reasonable? I would not attempt to create a test to trigger this -- it does not seem likely to be unit testable. |
Moving out since this is existing behavior in .NET 5.0 and doesn't meet the bar for 6.0 at the moment.
This seems reasonable. |
I will deal with this problem |
@danmoseley @ericstj Is this judgment unnecessary? Because it will never be true. |
Should I add |
winerror.h (on my machine it's in C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\winerror.h)
so 0x715 |
That is clearly dead code and therefore can be removed. |
BTW, it would be nice if there was a way to reduce the 8 places we have this pattern. |
PR #57804 |
Description
EventLogRecord.GetFormatDescription() throws "The specified resource type cannot be found in the image file." exception. while querying the Windows EventLog
Here is the StackTrace:
at System.Diagnostics.Eventing.Reader.EventLogException.Throw(Int32 errorCode)
at System.Diagnostics.Eventing.Reader.NativeWrapper.EvtFormatMessageRenderName(EventLogHandle pmHandle, EventLogHandle eventHandle, EvtFormatMessageFlags flag)
at System.Diagnostics.Eventing.Reader.ProviderMetadataCachedInformation.GetFormatDescription(String ProviderName, EventLogHandle eventHandle)
at HMS.Agent.LogInfoRetriever.<>c.b__1_1(EventRecord o) in C:\Users\RemoteUser\Documents\Projects\Code\HMS\HMS.Agent\LogInfoRetriever.cs:line 153
at System.Linq.Enumerable.SelectEnumerableIterator
2.ToList() at HMS.Agent.LogInfoRetriever.<>c__DisplayClass1_0.<GetWindowsEventLogs>b__0() in C:\Users\RemoteUser\Documents\Projects\Code\HMS\HMS.Agent\LogInfoRetriever.cs:line 152 at System.Threading.Tasks.Task
1.InnerInvoke()at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
Configuration
The text was updated successfully, but these errors were encountered: