К сведению разработчиков NLog:
У меня есть решение VS 2022 ASP.NET Core, которое работает под .NET 8.0. Я обновил TargetFramework до net9.0, и все работает нормально. Затем я обновил все пакеты NLog.* до последней версии (включая NLog.Web.AspNetCore до 5.3.14), и приложение сломалось.
При запуске Я получаю исключение System.UriFormatException из этого кода:
logger = NLog.LogManager.Setup()
.LoadConfigurationFromAppSettings().GetCurrentClassLogger();
Я устранял неполадки, просматривая разные версии пакета, и в конце концов выяснилось, что поломка происходит при переходе NLog.Web.AspNetCore с 5.3.11 на 5.3.12.< /p>
На данный момент у меня все в порядке, так как я могу придерживаться версии 5.3.11, но имейте в виду, что здесь есть что-то скрытое, над чем вам придется разобраться.
ОБНОВЛЕНИЕ: добавлено содержимое nlog-internal.txt, сгенерированное версией 5.3.12, по запросу @RolfKristensen, под трассировкой стека. Когда я возвращаюсь к версии 5.3.11, аналогичный вывод не заканчивается там, где это происходит в .12:
2024-11-20 15:41:38.5470 Debug Skip loading NLogLoggingConfiguration from empty config section: NLog
2024-11-20 15:41:38.5834 Info Loading NLog config from XML file: Z:\rwells\very\special\NLog.config
...normal loading proceeds...
В .11 кажется, что после того, как NLog отказывается от UNC, казалось бы, без имени хоста, он переходит к Z:, который представляет собой букву диска, сопоставленную с UNC, где мои файлы расположены.
Возможно, в LoggingConfigurationFileLoader произошли некоторые изменения/регресс относительно обработки UNC и сопоставленных дисков с .11 до .12?
ОБНОВЛЕНИЕ 2 (2024.11.21): см. uri-hacking.ps1 и его выходные данные ниже всего остального.
С уважением,
Ричард
Stack Trace
System.UriFormatException
HResult=0x80131537
Message=Invalid URI: The hostname could not be parsed.
Source=System.Private.Uri
StackTrace:
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at System.Uri..ctor(String uriString, UriKind uriKind)
at System.Xml.XmlResolver.ResolveUri(Uri baseUri, String relativeUri)
at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
at System.Xml.XmlReader.Create(String inputUri)
at NLog.Internal.Fakeables.AppEnvironmentWrapper.LoadXmlFile(String path)
at NLog.Config.XmlLoggingConfiguration.CreateFileReader(String fileName)
at NLog.Config.XmlLoggingConfiguration.LoadFromXmlFile(String fileName)
at NLog.Config.XmlLoggingConfiguration..ctor(String fileName, LogFactory logFactory)
at NLog.Web.SetupBuilderExtensions.c__DisplayClass0_0.b__2(ISetupLoadConfigurationBuilder config)
at NLog.SetupBuilderExtensions.LoadConfiguration(ISetupBuilder setupBuilder, Action`1 configBuilder)
at NLog.Web.SetupBuilderExtensions.LoadConfigurationFromAppSettings(ISetupBuilder setupBuilder, String basePath, String environment, String nlogConfigSection, Boolean optional, Boolean reloadOnChange)
at Program.$(String[] args) in Z:\rwells\very\special\Program.cs:line 20
nlog-internal.txt
2024-11-20 15:28:06.7547 Debug No file exists at candidate config file location: \\?\UNC\rwells\very\special\bin\Development\net9.0\IDService.exe.nlog
2024-11-20 15:28:06.7547 Debug No file exists at candidate config file location: \\?\UNC\rwells\very\special\bin\Development\net9.0\IDService.dll.nlog
2024-11-20 15:28:06.7779 Debug Reading config from XML file: \\?\UNC\rwells\very\special\bin\Development\net9.0\NLog.config
2024-11-20 15:28:06.8262 Error Failed loading from config file location: \\?\UNC\rwells\very\special\bin\Development\net9.0\NLog.config Exception: System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at System.Uri..ctor(String uriString, UriKind uriKind)
at System.Xml.XmlResolver.ResolveUri(Uri baseUri, String relativeUri)
at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
at System.Xml.XmlReader.Create(String inputUri)
at NLog.Internal.Fakeables.AppEnvironmentWrapper.LoadXmlFile(String path)
at NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfigurationFile(LogFactory logFactory, String configFile)
at NLog.Config.LoggingConfigurationFileLoader.TryLoadLoggingConfiguration(LogFactory logFactory, String configFile, LoggingConfiguration& config)
2024-11-20 15:28:06.8446 Debug No file exists at candidate config file location: \\?\UNC\rwells\very\special\bin\Development\net9.0\NLog.dll.nlog
2024-11-20 15:28:06.8465 Info NLog Configuration has not been loaded.
2024-11-20 15:28:07.3532 Debug No file exists at candidate config file location: \\?\UNC\rwells\very\special\bin\Development\net9.0\nlog.Development.config
uri-hacking.ps1
$paths = (
'\\sharepoint.business.com\DavWWWRoot\rs\project 1\document.txt',
'Z:\rwells\very\special\place',
'\\actual-hostname\actual-sharename\rwells\very\special\place',
'\\?\UNC\actual-hostname\actual-sharename\rwells\very\special\place'
)
foreach ($path in $paths) {
echo "$path ->"
$uri = [System.Uri]$path
echo " $($uri.AbsoluteUri) [is UNC = $($uri.IsUnc)]"
}
вывод на Windows Server 2022
\\sharepoint.business.com\DavWWWRoot\rs\project 1\document.txt ->
file://sharepoint.business.com/DavWWWRoot/rs/project%201/document.txt [is UNC = True]
Z:\rwells\very\special\place ->
file:///Z:/rwells/very/special/place [is UNC = False]
\\actual-hostname\actual-sharename\rwells\very\special\place ->
file://actual-hostname/actual-sharename/rwells/very/special/place [is UNC = True]
\\?\UNC\actual-hostname\actual-sharename\rwells\very\special\place ->
InvalidArgument: Z:\rwells\Temp\uri-hacking.ps1:11
Line |
11 | $uri = [System.Uri]$path
| ~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot convert value "\\?\UNC\actual-hostname\actual-sharename\rwells\very\special\place" to type "System.Uri". Error: "Invalid URI: The hostname could not be parsed."
file://actual-hostname/actual-sharename/rwells/very/special/place [is UNC = True]
Подробнее здесь: https://stackoverflow.com/questions/792 ... etframewor
NLog.Web.AspNetCore 5.3.12 вызывает исключение System.UriFormatException с net9.0 ⇐ C#
Место общения программистов C#
1733189286
Anonymous
К сведению разработчиков NLog:
У меня есть решение VS 2022 ASP.NET Core, которое работает под .NET 8.0. Я обновил TargetFramework до net9.0, и все работает нормально. Затем я обновил все пакеты NLog.* до последней версии (включая NLog.Web.AspNetCore до 5.3.14), и приложение сломалось.
При запуске Я получаю исключение System.UriFormatException из этого кода:
logger = NLog.LogManager.Setup()
.LoadConfigurationFromAppSettings().GetCurrentClassLogger();
Я устранял неполадки, просматривая разные версии пакета, и в конце концов выяснилось, что поломка происходит при переходе NLog.Web.AspNetCore с 5.3.11 на 5.3.12.< /p>
На данный момент у меня все в порядке, так как я могу придерживаться версии 5.3.11, но имейте в виду, что здесь есть что-то скрытое, над чем вам придется разобраться.
[b]ОБНОВЛЕНИЕ:[/b] добавлено содержимое nlog-internal.txt, сгенерированное версией 5.3.12, по запросу @RolfKristensen, под трассировкой стека. Когда я возвращаюсь к версии 5.3.11, аналогичный вывод не заканчивается там, где это происходит в .12:
2024-11-20 15:41:38.5470 Debug Skip loading NLogLoggingConfiguration from empty config section: NLog
2024-11-20 15:41:38.5834 Info Loading NLog config from XML file: Z:\rwells\very\special\NLog.config
...normal loading proceeds...
В .11 кажется, что после того, как NLog отказывается от UNC, казалось бы, без имени хоста, он переходит к Z:, который представляет собой букву диска, сопоставленную с UNC, где мои файлы расположены.
Возможно, в LoggingConfigurationFileLoader произошли некоторые изменения/регресс относительно обработки UNC и сопоставленных дисков с .11 до .12?
[b]ОБНОВЛЕНИЕ 2[/b] (2024.11.21): см. uri-hacking.ps1 и его выходные данные ниже всего остального.
С уважением,
Ричард
[b]Stack Trace[/b]
System.UriFormatException
HResult=0x80131537
Message=Invalid URI: The hostname could not be parsed.
Source=System.Private.Uri
StackTrace:
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at System.Uri..ctor(String uriString, UriKind uriKind)
at System.Xml.XmlResolver.ResolveUri(Uri baseUri, String relativeUri)
at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
at System.Xml.XmlReader.Create(String inputUri)
at NLog.Internal.Fakeables.AppEnvironmentWrapper.LoadXmlFile(String path)
at NLog.Config.XmlLoggingConfiguration.CreateFileReader(String fileName)
at NLog.Config.XmlLoggingConfiguration.LoadFromXmlFile(String fileName)
at NLog.Config.XmlLoggingConfiguration..ctor(String fileName, LogFactory logFactory)
at NLog.Web.SetupBuilderExtensions.c__DisplayClass0_0.b__2(ISetupLoadConfigurationBuilder config)
at NLog.SetupBuilderExtensions.LoadConfiguration(ISetupBuilder setupBuilder, Action`1 configBuilder)
at NLog.Web.SetupBuilderExtensions.LoadConfigurationFromAppSettings(ISetupBuilder setupBuilder, String basePath, String environment, String nlogConfigSection, Boolean optional, Boolean reloadOnChange)
at Program.$(String[] args) in Z:\rwells\very\special\Program.cs:line 20
[b]nlog-internal.txt[/b]
2024-11-20 15:28:06.7547 Debug No file exists at candidate config file location: \\?\UNC\rwells\very\special\bin\Development\net9.0\IDService.exe.nlog
2024-11-20 15:28:06.7547 Debug No file exists at candidate config file location: \\?\UNC\rwells\very\special\bin\Development\net9.0\IDService.dll.nlog
2024-11-20 15:28:06.7779 Debug Reading config from XML file: \\?\UNC\rwells\very\special\bin\Development\net9.0\NLog.config
2024-11-20 15:28:06.8262 Error Failed loading from config file location: \\?\UNC\rwells\very\special\bin\Development\net9.0\NLog.config Exception: System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at System.Uri..ctor(String uriString, UriKind uriKind)
at System.Xml.XmlResolver.ResolveUri(Uri baseUri, String relativeUri)
at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
at System.Xml.XmlReader.Create(String inputUri)
at NLog.Internal.Fakeables.AppEnvironmentWrapper.LoadXmlFile(String path)
at NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfigurationFile(LogFactory logFactory, String configFile)
at NLog.Config.LoggingConfigurationFileLoader.TryLoadLoggingConfiguration(LogFactory logFactory, String configFile, LoggingConfiguration& config)
2024-11-20 15:28:06.8446 Debug No file exists at candidate config file location: \\?\UNC\rwells\very\special\bin\Development\net9.0\NLog.dll.nlog
2024-11-20 15:28:06.8465 Info NLog Configuration has not been loaded.
2024-11-20 15:28:07.3532 Debug No file exists at candidate config file location: \\?\UNC\rwells\very\special\bin\Development\net9.0\nlog.Development.config
[b]uri-hacking.ps1[/b]
$paths = (
'\\sharepoint.business.com\DavWWWRoot\rs\project 1\document.txt',
'Z:\rwells\very\special\place',
'\\actual-hostname\actual-sharename\rwells\very\special\place',
'\\?\UNC\actual-hostname\actual-sharename\rwells\very\special\place'
)
foreach ($path in $paths) {
echo "$path ->"
$uri = [System.Uri]$path
echo " $($uri.AbsoluteUri) [is UNC = $($uri.IsUnc)]"
}
вывод на Windows Server 2022
\\sharepoint.business.com\DavWWWRoot\rs\project 1\document.txt ->
file://sharepoint.business.com/DavWWWRoot/rs/project%201/document.txt [is UNC = True]
Z:\rwells\very\special\place ->
file:///Z:/rwells/very/special/place [is UNC = False]
\\actual-hostname\actual-sharename\rwells\very\special\place ->
file://actual-hostname/actual-sharename/rwells/very/special/place [is UNC = True]
\\?\UNC\actual-hostname\actual-sharename\rwells\very\special\place ->
InvalidArgument: Z:\rwells\Temp\uri-hacking.ps1:11
Line |
11 | $uri = [System.Uri]$path
| ~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot convert value "\\?\UNC\actual-hostname\actual-sharename\rwells\very\special\place" to type "System.Uri". Error: "Invalid URI: The hostname could not be parsed."
file://actual-hostname/actual-sharename/rwells/very/special/place [is UNC = True]
Подробнее здесь: [url]https://stackoverflow.com/questions/79208703/nlog-web-aspnetcore-5-3-12-raises-system-uriformatexception-with-targetframewor[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия