Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
c230ba6b
R
runtime
项目概览
dotNET Platform
/
runtime
大约 1 年 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c230ba6b
编写于
6月 19, 2022
作者:
B
Badre BSAILA
提交者:
GitHub
6月 18, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EventLogException is missing the original win32 error code (#70629)
上级
e771b5dd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
16 deletion
+45
-16
src/libraries/Common/src/Interop/Windows/Interop.Errors.cs
src/libraries/Common/src/Interop/Windows/Interop.Errors.cs
+10
-0
src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj
...agnostics.EventLog/src/System.Diagnostics.EventLog.csproj
+3
-1
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs
...entLog/src/System/Diagnostics/Reader/EventLogException.cs
+20
-15
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogSessionTests.cs
...g/tests/System/Diagnostics/Reader/EventLogSessionTests.cs
+12
-0
未找到文件。
src/libraries/Common/src/Interop/Windows/Interop.Errors.cs
浏览文件 @
c230ba6b
...
...
@@ -71,6 +71,7 @@ internal static partial class Errors
internal
const
int
ERROR_DDE_FAIL
=
0x484
;
internal
const
int
ERROR_DLL_NOT_FOUND
=
0x485
;
internal
const
int
ERROR_NOT_FOUND
=
0x490
;
internal
const
int
ERROR_CANCELLED
=
0x4C7
;
internal
const
int
ERROR_NETWORK_UNREACHABLE
=
0x4CF
;
internal
const
int
ERROR_NON_ACCOUNT_SID
=
0x4E9
;
internal
const
int
ERROR_NOT_ALL_ASSIGNED
=
0x514
;
...
...
@@ -93,6 +94,15 @@ internal static partial class Errors
internal
const
int
ERROR_TRUSTED_RELATIONSHIP_FAILURE
=
0x6FD
;
internal
const
int
ERROR_RESOURCE_TYPE_NOT_FOUND
=
0x715
;
internal
const
int
ERROR_RESOURCE_LANG_NOT_FOUND
=
0x717
;
internal
const
int
RPC_S_CALL_CANCELED
=
0x71A
;
internal
const
int
ERROR_NOT_A_REPARSE_POINT
=
0x1126
;
internal
const
int
ERROR_EVT_QUERY_RESULT_STALE
=
0x3AA3
;
internal
const
int
ERROR_EVT_QUERY_RESULT_INVALID_POSITION
=
0x3AA4
;
internal
const
int
ERROR_EVT_INVALID_EVENT_DATA
=
0x3A9D
;
internal
const
int
ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND
=
0x3A9A
;
internal
const
int
ERROR_EVT_CHANNEL_NOT_FOUND
=
0x3A9F
;
internal
const
int
ERROR_EVT_MESSAGE_NOT_FOUND
=
0x3AB3
;
internal
const
int
ERROR_EVT_MESSAGE_ID_NOT_FOUND
=
0x3AB4
;
internal
const
int
ERROR_EVT_PUBLISHER_DISABLED
=
0x3ABD
;
}
}
src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj
浏览文件 @
c230ba6b
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
...
...
@@ -110,6 +110,8 @@ System.Diagnostics.EventLog</PackageDescription>
Link="Common\Interop\Windows\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)System\Diagnostics\NetFrameworkUtils.cs"
Link="Common\System\Diagnostics\NetFrameworkUtils.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.HRESULT_FROM_WIN32.cs"
Link="Common\Interop\Windows\Interop.HRESULT_FROM_WIN32.cs" />
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
...
...
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs
浏览文件 @
c230ba6b
...
...
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using
System.ComponentModel
;
using
System.IO
;
using
System.Runtime.Serialization
;
namespace
System.Diagnostics.Eventing.Reader
...
...
@@ -16,30 +17,30 @@ internal static void Throw(int errorCode)
{
switch
(
errorCode
)
{
case
2
:
case
3
:
case
15007
:
case
15027
:
case
15028
:
case
15002
:
case
Interop
.
Errors
.
ERROR_FILE_NOT_FOUND
:
case
Interop
.
Errors
.
ERROR_PATH_NOT_FOUND
:
case
Interop
.
Errors
.
ERROR_EVT_CHANNEL_NOT_FOUND
:
case
Interop
.
Errors
.
ERROR_EVT_MESSAGE_NOT_FOUND
:
case
Interop
.
Errors
.
ERROR_EVT_MESSAGE_ID_NOT_FOUND
:
case
Interop
.
Errors
.
ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND
:
throw
new
EventLogNotFoundException
(
errorCode
);
case
13
:
case
15005
:
case
Interop
.
Errors
.
ERROR_INVALID_DATA
:
case
Interop
.
Errors
.
ERROR_EVT_INVALID_EVENT_DATA
:
throw
new
EventLogInvalidDataException
(
errorCode
);
case
1818
:
// RPC_S_CALL_CANCELED is converted to ERROR_CANCELLED
case
1223
:
case
Interop
.
Errors
.
RPC_S_CALL_CANCELED
:
case
Interop
.
Errors
.
ERROR_CANCELLED
:
throw
new
OperationCanceledException
();
case
15037
:
case
Interop
.
Errors
.
ERROR_EVT_PUBLISHER_DISABLED
:
throw
new
EventLogProviderDisabledException
(
errorCode
);
case
5
:
case
Interop
.
Errors
.
ERROR_ACCESS_DENIED
:
throw
new
UnauthorizedAccessException
();
case
15011
:
case
15012
:
case
Interop
.
Errors
.
ERROR_EVT_QUERY_RESULT_STALE
:
case
Interop
.
Errors
.
ERROR_EVT_QUERY_RESULT_INVALID_POSITION
:
throw
new
EventLogReadingException
(
errorCode
);
default
:
...
...
@@ -50,7 +51,11 @@ internal static void Throw(int errorCode)
public
EventLogException
()
{
}
public
EventLogException
(
string
message
)
:
base
(
message
)
{
}
public
EventLogException
(
string
message
,
Exception
innerException
)
:
base
(
message
,
innerException
)
{
}
protected
EventLogException
(
int
errorCode
)
{
_errorCode
=
errorCode
;
}
protected
EventLogException
(
int
errorCode
)
{
_errorCode
=
errorCode
;
HResult
=
Interop
.
HRESULT_FROM_WIN32
(
errorCode
);
}
public
override
string
Message
{
...
...
src/libraries/System.Diagnostics.EventLog/tests/System/Diagnostics/Reader/EventLogSessionTests.cs
浏览文件 @
c230ba6b
...
...
@@ -106,5 +106,17 @@ public void ClearLog_LogExists_Success()
session
.
CancelCurrentOperations
();
}
}
[
ConditionalFact
(
typeof
(
Helpers
),
nameof
(
Helpers
.
SupportsEventLogs
))]
[
SkipOnTargetFramework
(
TargetFrameworkMonikers
.
NetFramework
)]
public
void
EventLogExceptionShouldHaveHResultSet
()
{
using
(
var
session
=
new
EventLogSession
())
{
EventLogNotFoundException
exception
=
Assert
.
Throws
<
EventLogNotFoundException
>(()
=>
session
.
ExportLog
(
LogName
,
PathType
.
FilePath
,
LogName
,
GetTestFilePath
()));
Assert
.
Equal
(
unchecked
((
int
)
0x80070002
),
exception
.
HResult
);
session
.
CancelCurrentOperations
();
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录