Меню Рубрики

Net framework initialization error windows xp

.NET Framework initialization errors: Managing the user experience

The common language runtime (CLR) activation system determines the version of the CLR that will be used to run managed application code. In some cases, the activation system might not be able to find a version of the CLR to load. This situation typically occurs when an application requires a CLR version that is invalid or not installed on a given computer. If the requested version is not found, the CLR activation system returns an HRESULT error code from the function or interface that was called, and may display an error message to the user who is running the application. This article provides a list of HRESULT codes and explains how you can prevent the error message from being displayed.

The CLR provides logging infrastructure to help you debug CLR activation issues, as described in How to: Debug CLR Activation Issues. This infrastructure should not be confused with assembly binding logs, which are entirely different.

CLR activation HRESULT codes

The CLR activation APIs return HRESULT codes to report the result of an activation operation to a host. CLR hosts should always consult these return values before proceeding with additional operations.

UI for initialization errors

If the CLR activation system cannot load the correct version of the runtime that is required by an application, it displays an error message to users to inform them that their computer is not properly configured to run the application, and provides them with an opportunity to remedy the situation. The following error message is typically presented in this situation. The user can choose Yes to go to a Microsoft website where they can download the correct .NET Framework version for the application.

Resolving the initialization error

As a developer, you have a variety of options for controlling the .NET Framework initialization error message. For example, you can use an API flag to prevent the message from being displayed, as discussed in the next section. However, you still have to resolve the issue that prevented your application from loading the requested runtime. Otherwise, your application may not run at all, or some functionality may not be available.

To resolve the underlying issues and provide the best user experience (fewer error messages), we recommend the following:

For .NET Framework 3.5 (and earlier) applications: Configure your application to support the .NET Framework 4 or later versions (see instructions).

For .NET Framework 4 applications: Install the .NET Framework 4 redistributable package as part of your application setup. See Deployment Guide for Developers.

Controlling the error message

Displaying an error message to communicate that a requested .NET Framework version was not found can be viewed as either a helpful service or a minor annoyance to users. In either case, you can control this UI by passing flags to the activation APIs.

The ICLRMetaHostPolicy::GetRequestedRuntime method accepts a METAHOST_POLICY_FLAGS enumeration member as input. You can include the METAHOST_POLICY_SHOW_ERROR_DIALOG flag to request an error message if the requested version of the CLR is not found. By default, the error message is not displayed. (The ICLRMetaHost::GetRuntime method does not accept this flag, and does not provide any other way to display the error message.)

Windows provides a SetErrorMode function that you can use to declare whether you want error messages to be shown as a result of code that runs within your process. You can specify the SEM_FAILCRITICALERRORS flag to prevent the error message from being displayed.

However, in some scenarios, it is important to override the SEM_FAILCRITICALERRORS setting set by an application process. For example, if you have a native COM component that hosts the CLR and that is hosted in a process where SEM_FAILCRITICALERRORS is set, you may want to override the flag, depending on the impact of displaying error messages within that particular application process. In this case, you can use one of the following flags to override SEM_FAILCRITICALERRORS:

Use METAHOST_POLICY_IGNORE_ERROR_MODE with the ICLRMetaHostPolicy::GetRequestedRuntime method.

Use RUNTIME_INFO_IGNORE_ERROR_MODE with the GetRequestedRuntimeInfo function.

UI policy for CLR-provided hosts

The CLR includes a set of hosts for a variety of scenarios, and these hosts all display an error message when they encounter problems loading the required version of the runtime. The following table provides a list of hosts and their error message policies.

CLR host Description Error message policy Can error message be disabled?
Managed EXE host Launches managed EXEs. Is shown in case of a missing .NET Framework version No
Managed COM host Loads managed COM components into a process. Is shown in case of a missing .NET Framework version Yes, by setting the SEM_FAILCRITICALERRORS flag
ClickOnce host Launches ClickOnce applications. Is shown in case of a missing .NET Framework version, starting with the .NET Framework 4.5 No
XBAP host Launches WPF XBAP applications. Is shown in case of a missing .NET Framework version, starting with the .NET Framework 4.5 No

Windows 8 behavior and UI

The CLR activation system provides the same behavior and UI on Windows 8 as it does on other versions of the Windows operating system, except when it encounters issues loading CLR 2.0. Windows 8 includes the .NET Framework 4.5, which uses CLR 4.5. However, Windows 8 does not include the .NET Framework 2.0, 3.0, or 3.5, which all use CLR 2.0. As a result, applications that depend on CLR 2.0 do not run on Windows 8 by default. Instead, they display the following dialog box to enable users to install the .NET Framework 3.5. Users can also enable the .NET Framework 3.5 in Control Panel. Both options are discussed in the article Install the .NET Framework 3.5 on Windows 10, Windows 8.1, and Windows 8.

The .NET Framework 4.5 replaces the .NET Framework 4 (CLR 4) on the user’s computer. Therefore, .NET Framework 4 applications run seamlessly, without displaying this dialog box, on Windows 8.

When the .NET Framework 3.5 is installed, users can run applications that depend on the .NET Framework 2.0, 3.0, or 3.5 on their Windows 8 computers. They can also run .NET Framework 1.0 and 1.1 applications, provided that those applications are not explicitly configured to run only on the .NET Framework 1.0 or 1.1. See Migrating from the .NET Framework 1.1.

Starting with the .NET Framework 4.5, CLR activation logging has been improved to include log entries that record when and why the initialization error message is displayed. For more information, see How to: Debug CLR Activation Issues.

Источник

Ошибки инициализации платформы .NET Framework: управление пользовательской средой .NET Framework initialization errors: Managing the user experience

Система активации среды CLR определяет версию среды CLR, которая будет использоваться для выполнения управляемого кода приложения. The common language runtime (CLR) activation system determines the version of the CLR that will be used to run managed application code. В некоторых случаях система активации может не найти версию среды CLR для загрузки. In some cases, the activation system might not be able to find a version of the CLR to load. Эта ситуация обычно возникает в том случае, если приложение требует версии среды CLR, которая недопустима или не установлена на данном компьютере. This situation typically occurs when an application requires a CLR version that is invalid or not installed on a given computer. Если запрошенная версия не найдена, то система активации среды CLR получает код ошибки HRESULT из вызванных функции или интерфейса и может отобразить сообщение об ошибке для пользователя, запустившего приложение. If the requested version is not found, the CLR activation system returns an HRESULT error code from the function or interface that was called, and may display an error message to the user who is running the application. В этой статье приводится список кодов HRESULT и объясняется, как можно запретить отображение сообщения об ошибке. This article provides a list of HRESULT codes and explains how you can prevent the error message from being displayed.

Среда CLR предоставляет инфраструктуру ведения журнала для облегчения отладки проблем активации среды CLR, как описано в разделе Практическое руководство. Отладка проблем при активации среды CLR. The CLR provides logging infrastructure to help you debug CLR activation issues, as described in How to: Debug CLR Activation Issues. Эту инфраструктуру не следует путать с журналами привязки сборок, которая полностью отличается. This infrastructure should not be confused with assembly binding logs, which are entirely different.

Коды HRESULT активации CLR CLR activation HRESULT codes

Интерфейсы API активации среды CLR возвращают коды HRESULT, чтобы сообщить о результатах операции активации основному приложению. The CLR activation APIs return HRESULT codes to report the result of an activation operation to a host. Основные приложения среды CLR должны всегда обращаться к этими возвращаемым значениям, прежде чем предпринимать какие-либо дополнительные действия. CLR hosts should always consult these return values before proceeding with additional operations.

Пользовательский интерфейс для ошибок инициализации UI for initialization errors

Если системе активации среды CLR не удается загрузить правильную версию среды выполнения, которая требуется приложению, она отображает сообщение об ошибке, чтобы уведомить пользователя, что компьютер не настроен должным образом для запуска приложения, и предоставить с возможность исправить ситуацию. If the CLR activation system cannot load the correct version of the runtime that is required by an application, it displays an error message to users to inform them that their computer is not properly configured to run the application, and provides them with an opportunity to remedy the situation. Обычно в такой ситуации отображается следующее сообщение об ошибке. The following error message is typically presented in this situation. Пользователь может выбрать Да, чтобы перейти к веб-сайту Майкрософт, где он может загрузить правильную версию платформы .NET Framework для приложения. The user can choose Yes to go to a Microsoft website where they can download the correct .NET Framework version for the application.

Устранение ошибок инициализации Resolving the initialization error

В распоряжении разработчика имеются различные параметры для контроля сообщений об ошибках инициализации платформы .NET Framework. As a developer, you have a variety of options for controlling the .NET Framework initialization error message. Например, можно использовать флаг API для запрета отображения сообщения, как описано в следующем разделе. For example, you can use an API flag to prevent the message from being displayed, as discussed in the next section. Тем не менее причину, по которой приложение не смогло загрузить нужную среду выполнения, нужно устранить. However, you still have to resolve the issue that prevented your application from loading the requested runtime. В противном случае приложение не сможет работать либо часть функций будет недоступна. Otherwise, your application may not run at all, or some functionality may not be available.

Для разрешения проблем и наилучшего взаимодействия с пользователем (меньшее количество сообщений об ошибках), рекомендуется следующее: To resolve the underlying issues and provide the best user experience (fewer error messages), we recommend the following:

Для приложений на .NET Framework 3.5 (и более ранних версий): настройте приложение для поддержки .NET Framework 4 или более поздней версии (см. раздел Инструкции). For .NET Framework 3.5 (and earlier) applications: Configure your application to support the .NET Framework 4 or later versions (see instructions).

Для приложений .NET Framework версии 4: установите распространяемый пакет платформы .NET Framework 4 в составе установки приложения. For .NET Framework 4 applications: Install the .NET Framework 4 redistributable package as part of your application setup. См. раздел Руководство по развертыванию для разработчиков. See Deployment Guide for Developers.

Управление сообщениями об ошибках Controlling the error message

Отображение сообщения об ошибках для уведомления о том, что запрошенная версия платформы .NET Framework не найдена, можно рассматривать как полезную услугу или источник раздражения для пользователя. Displaying an error message to communicate that a requested .NET Framework version was not found can be viewed as either a helpful service or a minor annoyance to users. В любом случае этим пользовательским интерфейсом можно управлять, передавая флаги в API активации. In either case, you can control this UI by passing flags to the activation APIs.

Метод ICLRMetaHostPolicy::GetRequestedRuntime принимает в качестве входных данных элемент перечисления METAHOST_POLICY_FLAGS. The ICLRMetaHostPolicy::GetRequestedRuntime method accepts a METAHOST_POLICY_FLAGS enumeration member as input. Можно включить флаг METAHOST_POLICY_SHOW_ERROR_DIALOG для запроса сообщения об ошибке, если запрошенная версия среды CLR не будет найдена. You can include the METAHOST_POLICY_SHOW_ERROR_DIALOG flag to request an error message if the requested version of the CLR is not found. По умолчанию сообщение об ошибке не отображается. By default, the error message is not displayed. (Метод ICLRMetaHost::GetRuntime не поддерживает этот флаг и не предоставляет иных способов отобразить сообщение об ошибке.) (The ICLRMetaHost::GetRuntime method does not accept this flag, and does not provide any other way to display the error message.)

Windows предоставляет функцию SetErrorMode, с помощью которой можно объявить, должны ли сообщения об ошибках отображаться как результат выполнения кода, выполняемого внутри процесса. Windows provides a SetErrorMode function that you can use to declare whether you want error messages to be shown as a result of code that runs within your process. Можно указать флаг SEM_FAILCRITICALERRORS, чтобы запретить отображение сообщения об ошибке. You can specify the SEM_FAILCRITICALERRORS flag to prevent the error message from being displayed.

Но в некоторых случаях важно переопределить параметр SEM_FAILCRITICALERRORS, установленный процессом приложения. However, in some scenarios, it is important to override the SEM_FAILCRITICALERRORS setting set by an application process. Например, если имеется собственный компонент COM, в котором находится среда CLR и расположенный в процессе, для которого установлен флаг SEM_FAILCRITICALERRORS, можно переопределить флаг в зависимости от влияния отображения сообщений об ошибках в пределах данного процесса приложения. For example, if you have a native COM component that hosts the CLR and that is hosted in a process where SEM_FAILCRITICALERRORS is set, you may want to override the flag, depending on the impact of displaying error messages within that particular application process. В этом случае для переопределения SEM_FAILCRITICALERRORS можно воспользоваться одним из следующих флагов: In this case, you can use one of the following flags to override SEM_FAILCRITICALERRORS:

Используйте METAHOST_POLICY_IGNORE_ERROR_MODE с методом ICLRMetaHostPolicy::GetRequestedRuntime. Use METAHOST_POLICY_IGNORE_ERROR_MODE with the ICLRMetaHostPolicy::GetRequestedRuntime method.

Используйте RUNTIME_INFO_IGNORE_ERROR_MODE с функцией GetRequestedRuntimeInfo. Use RUNTIME_INFO_IGNORE_ERROR_MODE with the GetRequestedRuntimeInfo function.

Политика пользовательского интерфейса для узлов в среде CLR UI policy for CLR-provided hosts

Среда CLR включает в себя набор узлов для различных сценариев. Все эти узлы отображают сообщение об ошибке при возникновении проблем с загрузкой необходимой версии среды выполнения. The CLR includes a set of hosts for a variety of scenarios, and these hosts all display an error message when they encounter problems loading the required version of the runtime. В следующей таблице приводится список узлов и их политик сообщений об ошибках. The following table provides a list of hosts and their error message policies.

Узел CLR CLR host Описание Description Политика сообщения об ошибках Error message policy Можно ли отключить сообщение об ошибке? Can error message be disabled?
Узел управляемых EXE-файлов Managed EXE host Запускает управляемые EXE-файлы. Launches managed EXEs. Отображается в случае отсутствия версии платформы .NET Framework Is shown in case of a missing .NET Framework version Нет No
Узел управляемого COM Managed COM host Загружает управляемые компоненты COM в процесс. Loads managed COM components into a process. Отображается в случае отсутствия версии платформы .NET Framework Is shown in case of a missing .NET Framework version Да, установив флаг SEM_FAILCRITICALERRORS Yes, by setting the SEM_FAILCRITICALERRORS flag
Узел ClickOnce ClickOnce host Запускает приложения ClickOnce. Launches ClickOnce applications. Отображается в случае отсутствия версии платформы .NET Framework начиная с .NET Framework 4.5 Is shown in case of a missing .NET Framework version, starting with the .NET Framework 4.5 Нет No
Узел XBAP XBAP host Запускает приложения WPF XBAP. Launches WPF XBAP applications. Отображается в случае отсутствия версии платформы .NET Framework начиная с .NET Framework 4.5 Is shown in case of a missing .NET Framework version, starting with the .NET Framework 4.5 Нет No

Поведение и пользовательский интерфейс Windows 8 Windows 8 behavior and UI

Система активации CLR обеспечивает такое же поведение и пользовательского интерфейса в Windows 8, как и в других версиях операционной системы Windows, за исключением ситуаций с возникающими при загрузке CLR 2.0 проблемами. The CLR activation system provides the same behavior and UI on Windows 8 as it does on other versions of the Windows operating system, except when it encounters issues loading CLR 2.0. Windows 8 включает .NET Framework 4.5 с поддержкой CLR 4.5. Windows 8 includes the .NET Framework 4.5, which uses CLR 4.5. Но Windows 8 не включает .NET Framework 2.0, 3.0 или 3.5 с поддержкой CLR 2.0. However, Windows 8 does not include the .NET Framework 2.0, 3.0, or 3.5, which all use CLR 2.0. В результате приложения, зависящие от CLR 2.0, по умолчанию не будут работать в Windows 8. As a result, applications that depend on CLR 2.0 do not run on Windows 8 by default. Вместо этого выводится следующее диалоговое окно, позволяющее установить платформу .NET Framework 3.5. Instead, they display the following dialog box to enable users to install the .NET Framework 3.5. Пользователи также могут включить платформу .NET Framework 3.5 из панели управления. Users can also enable the .NET Framework 3.5 in Control Panel. Обе возможности рассматриваются в статье Установка платформы .NET Framework 3.5 в Windows 10, Windows 8.1 и Windows 8. Both options are discussed in the article Install the .NET Framework 3.5 on Windows 10, Windows 8.1, and Windows 8.

.NET Framework 4.5 заменяет .NET Framework 4 (среда CLR 4) на компьютере пользователя. The .NET Framework 4.5 replaces the .NET Framework 4 (CLR 4) on the user’s computer. Поэтому приложения .NET Framework 4 без проблем выполняются в Windows 8 без отображения этого диалогового окна. Therefore, .NET Framework 4 applications run seamlessly, without displaying this dialog box, on Windows 8.

В случае установки .NET Framework 3.5 пользователи могут запускать на своих компьютерах Windows 8 приложения, которые зависят от .NET Framework 2.0, 3.0 или 3.5. When the .NET Framework 3.5 is installed, users can run applications that depend on the .NET Framework 2.0, 3.0, or 3.5 on their Windows 8 computers. Они также могут запускать приложения платформы .NET Framework 1.0 и 1.1, если эти приложения не настроены явным образом для запуска только на платформе .NET Framework 1.0 или 1.1. They can also run .NET Framework 1.0 and 1.1 applications, provided that those applications are not explicitly configured to run only on the .NET Framework 1.0 or 1.1. См. раздел Миграция с платформы .NET Framework 1.1. See Migrating from the .NET Framework 1.1.

Начиная с .NET Framework 4.5 ведение журналов активации среды CLR было улучшено для включения записей журнала, которые регистрируют, когда и почему было отображено сообщение об ошибке инициализации. Starting with the .NET Framework 4.5, CLR activation logging has been improved to include log entries that record when and why the initialization error message is displayed. Дополнительные сведения см. в разделе Практическое руководство. Отладка проблем при активации среды CLR. For more information, see How to: Debug CLR Activation Issues.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Net framework 4 client profile для windows 7
  • Nero создание загрузочного диска windows 7
  • Neosmart windows 10 rollback utility как запустить
  • Neodrive rocket launcher windows 64 driver
  • Need windows 7 service pack 1 platform update h1z1