Ошибка визуал студио

This repo is the home of the official Visual Studio, Visual Studio for Mac, Visual Studio Subscriptions, and Scripting Technologies documentation for Microsoft. - visualstudio-docs/troubleshooting-...
title description ms.date ms.custom ms.topic helpviewer_keywords ms.assetid author ms.author manager ms.workload ms.prod ms.technology

Troubleshoot installation or upgrades

Sometimes, things can go wrong. If your Visual Studio installation or upgrade fails, this page can help.

1/6/2023

vs-acquisition

troubleshooting

{{PLACEHOLDER}}

{{PLACEHOLDER}}

556EDD3F-E365-43EE-B3DD-03AA4353F75B

anandmeg

meghaanand

jmartens

multiple

visual-studio-windows

vs-installation

Troubleshoot Visual Studio installation and upgrades

[!INCLUDE Visual Studio]

[!TIP]
Having a problem installing? We can help. We offer an installation chat (English only) support option.

This troubleshooting guide includes step-by-step instructions that should resolve most installation issues.

Online installations / updates

The following possible resolutions apply to a typical online installation. Try them in order.

1. Check whether the problem is a known issue

The first thing to check is whether or not the issue you are encountering is a known issue with the Visual Studio Installer that Microsoft is working on fixing.

::: moniker range=»vs-2019″

To see if there’s a workaround for your problem, check the Known Issues section of our release notes.

::: moniker-end

::: moniker range=»>=vs-2022″

To see if there’s a workaround for your problem, check the Known Issues section of our release notes.

::: moniker-end

2. Try repairing Visual Studio

Next, try to repair your installation. This solution fixes many common update issues. To learn how to repair, see Repair Visual Studio.

3. See what the developer community says about the error.

If repairing didn’t fix the issue, search for your error message in the Visual Studio Developer Community. Other members of the community might have found a solution or workaround to your problem.

4. Delete the installer folder (update issues)

If you encountered an issue when updating, try deleting the Visual Studio Installer folder, and then rerunning the installation bootstrapper can solve certain update failures. Doing so reinstalls the Visual Studio Installer files and resets the installation metadata.

::: moniker range=»<vs-2022″

  1. Close the Visual Studio Installer.
  2. Delete the Visual Studio Installer installation directory. Typically, the directory is C:Program Files (x86)Microsoft Visual StudioInstaller.
  3. Run the Visual Studio bootstrapper. The Visual Studio bootstrapper is a light-weight executable that initiates the install of the Visual Studio Installer and then the Visual Studio product itself. You might find the bootstrapper in your Downloads folder with a file name that follows a vs_[Visual Studio edition]__*.exe pattern. If you don’t find that application, you can download the bootstrapper by going to the Visual Studio older downloads page and clicking Download for your edition of Visual Studio. Then, run the executable to reset your installation metadata.
  4. Try to install or update Visual Studio again. If the Installer continues to fail, proceed to the Report a problem step.

::: moniker-end

::: moniker range=»=vs-2022″

  1. Close the Visual Studio Installer.
  2. Delete the Visual Studio Installer folder. Typically, the folder path is C:Program Files (x86)Microsoft Visual StudioInstaller.
  3. Run the Visual Studio Installer bootstrapper. You might find the bootstrapper in your Downloads folder with a file name that matches a vs_[Visual Studio edition]__*.exe pattern. Or, you can download the bootstrapper for your edition of Visual Studio from the Visual Studio downloads page. Then, run the executable to reset your installation metadata.
  4. Try to install or update Visual Studio again. If the Visual Studio Installer continues to fail, proceed to the Report a problem step.

::: moniker-end

5. Report the problem to support

In some situations, such as when there are corrupted files, issues might require case-by-case troubleshooting. To help us help you, follow these steps:

::: moniker range=»vs-2019″

  1. Collect your setup logs. See How to get the Visual Studio installation logs for details.
  2. Open the Visual Studio Installer, and then click Report a problem to open the Visual Studio Feedback tool.
    Screenshot showing the Provide feedback button in the Visual Studio Installer.
  3. Give your problem report a title, and provide relevant details. Click Next to go to the Attachments section, and then attach the generated log file (typically, the file is at %TEMP%vslogs.zip).
  4. Click Next to review your problem report, and then click Submit.

::: moniker-end

::: moniker range=»>=vs-2022″

  1. Collect your setup logs. See How to get the Visual Studio installation logs for details.
  2. Open the Visual Studio Installer, and then choose Report a problem to open the Visual Studio Feedback tool.
    Screenshot showing the Provide feedback button in the Visual Studio Installer.
  3. Give your problem report a title, and provide the relevant details. The most recent setup log for the Visual Studio Installer is automatically added to the Additional attachments section of your problem report.
  4. Choose Submit.

::: moniker-end

6. Remove all Visual Studio installation files

As a last resort, you can remove all Visual Studio installation files and product information:

  1. Follow the steps in this article: Remove Visual Studio page.
  2. Rerun the Visual Studio Installer bootstrapper. You might find the bootstrapper in your Downloads folder with a file name that matches a vs_[Visual Studio edition]__*.exe pattern. Or, you can download the bootstrapper for your edition of Visual Studio from the Visual Studio downloads page.
  3. Try to reinstall Visual Studio.

::: moniker range=»>=vs-2022″

7. Rollback to a previous install

[!IMPORTANT]
Before you try to rollback, learn more about the rollback feature in Visual Studio.

Rollback may be disabled or your rollback attempt may be undone if you’re in an organization that has security compliance or software updating requirements. Contact your IT Administrator for further details.

If none of the previous steps helped you successfully upgrade Visual Studio, you can try to rollback to your previously installed version. Since Visual Studio 2022 version 17.4, you can rollback to your previously installed version if:

  • You haven’t installed from a layout.
  • Your original version was on the Current channel version 17.1.7 or higher, or on the 17.0 Fall 2021 LTSC channel 17.0.10 or higher.

You can rollback to your previously installed version by using the Visual Studio Installer or by using the command line.

To rollback using the Visual Studio Installer:

  1. Launch the Visual Studio Installer on your computer.
  2. In the installer, look for the edition of Visual Studio that you installed.
  3. Choose More.
  4. Choose Rollback to previous version.
    :::image type=»content» source=»media/vs-2022/rollback-from-previous-version.png» alt-text=»Screenshot of the Rollback to previous version option.»:::
  5. Select OK to confirm your choice.

8. Contact our live chat

If none of the previous steps help you successfully install or upgrade Visual Studio, contact us by using our live chat support option (English only) for further assistance.

::: moniker-end

::: moniker range=»vs-2019″

7. Contact our live chat

If none of the previous steps help you successfully install or upgrade Visual Studio, contact us by using our live chat support option (English only) for further assistance.

::: moniker-end

Network layout or offline installations

To resolve issues with a network installation, see Error Codes or Troubleshoot network-related errors when you install or use Visual Studio.

Administrator Updates

Administrator updates may not be applied correctly due to a variety of situations. Refer to the Administrator updates troubleshooting error codes for further information.

Collect installation logs for Microsoft Support

If you contact Microsoft Support, you might be asked to collect setup logs by using the Microsoft Visual Studio and .NET Framework log collection tool. The log collection tool collects setup logs from all components installed by Visual Studio, including .NET Framework, Windows SDK, and SQL Server. It also collects computer information, a Windows Installer inventory, and Windows event log information for the Visual Studio Installer, Windows Installer, and System Restore.

To collect the logs:

  1. Download the tool.

  2. Open an administrative command prompt.

  3. Run Collect.exe in the folder where you saved the tool.

    The tool must be run under the same user account that the failed installation was run under. If you are running the tool from a different user account, set the –user:<name> option to specify the user account under which the failed installation was run. Run Collect.exe -? from an administrator command prompt for additional options and usage information.

The tool generates a vslogs.zip file in your %TEMP% folder, typically at C:UsersYourNameAppDataLocalTempvslogs.zip.

Problems installing WebView2

If your organization’s Group policies block the installation of the WebView2 component, you won’t be able to install Visual Studio since the installer requires WebView2 to be installed. If this happens, check these policies:

  • If the Microsoft Edge ‘Install (WebView)’ is configured, it determines whether WebView2 can be installed.
  • If the Microsoft Edge ‘Install (WebView)’ policy is not configured, the Microsoft Edge ‘InstallDefault’ policy determines whether WebView2 can be installed.

[!Warning]
If neither policy is configured, WebView2 installation is allowed by your organization.

We are currently evaluating the new Visual Studio 2015 and encountered a strange problem with IntelliSense. When I compiled our main solution with the new studio the build succeeds, but nevertheless 6 errors are shown.

I discovered that it’s not a real error, but only an intellisense error. The code is definitely correct and everything compiled successfully. The code however is marked red and errors show up in the error list.

All 6 errors have the same origin. It’s a simple constructor call. Strange enough, but there are also some occurrences of the exact same constructor without any errors.

The error message:

Code: CS1729
Message: '<the class>' does not contain a constructor that takes that many arguments.
Project: <the project name>
File: <the path to the file>

The new studio was installed on a freshly installed Windows 7 without any legacy software (no VS13).

I’ve already tried to clear the caches, deleted the suo file, deleted bin and obj directories, cleaned and rebuilt the solution etc. But nothing worked.

Can anyone explain that behavior to me?

Karel Kral's user avatar

Karel Kral

5,1166 gold badges40 silver badges48 bronze badges

asked Aug 11, 2015 at 13:49

Ash's user avatar

8

I had thousands of intellisense errors and 0 build errors. After deleting .suo file and restarting VS intellisense errors are gone.

Suo file is located relatively to source in:
.vsSolutionNamev14.suo

According to comment: Beware that *.suo is a hidden file.

Edit: According to comments, VS2017 has the same issue, so you can use similar solution: Delete .vsSolutionNamev15.suo

VS2019 still has this issue. Delete .vsSolutionNamev17.suo

If deleting .suo still does solve your problem, then delete also all bin and obj directories in every project in the solution.

answered Nov 2, 2015 at 12:30

Karel Kral's user avatar

Karel KralKarel Kral

5,1166 gold badges40 silver badges48 bronze badges

9

Also had this problem with a migrated project, so I referenced the Microsoft.CSharp dll. In some projects I needed to remove and add again the Reference in the project.

answered Sep 15, 2015 at 12:40

Guilherme de Jesus Santos's user avatar

7

Ran into similar issue in Visual Studio 2017 ASP.Net Core Project. Following steps did the trick for me

  1. Perform Clean Solution
  2. Close VS
  3. Delete .suo file & Delete bin/obj directories
  4. Reopen VS

answered Apr 1, 2017 at 21:24

Naren's user avatar

NarenNaren

77714 silver badges12 bronze badges

2

Similar problem as others, but different resolution. Posting in case I can help someone else.

Running Visual Studio 2017 15.5.2. I use Git and frequently switch branches. Several weeks ago, I started having editors show me errors (all related to types it could not find even though references were valid). Compile worked great. I confirmed the same issue in VS 2017 15.6 Preview (Jan 6, 2018). I would try to delete cache, SUO files, or bin/obj folders and no impact. At first it would appear to work. Reopen Visual Studio and everything would look good. Use «Rebuild Solution» and the IntelliSense errors would returns. I even tried uninstall/reinstall of Visual Studio.

I had the same issue on two machines, both with same version of Visual Studio.

By looking at the errors about missing types, they all appeared to come from two referenced projects. One of those references was a shared project used by just about every other project in the solution, but one of them was a small project without many references. It just so happens that the small project was also referenced by my larger shared project. In Visual Studio, I unloaded the small project and reloaded it. The errors went away! They errors did not come back on Rebuild Solution.

I then switched Git branches and the errors all came back. Fortunately I repeated the above steps of unloading/reloading the small project and the errors went away.

Every time I switch Git branches, the errors come back until I repeat that process. There are zero changes between the Git branches for the smaller project that I unload/reload. Unclear why that sequence is fixing my issue.

answered Jan 6, 2018 at 17:39

HgCoder's user avatar

HgCoderHgCoder

1,2439 silver badges14 bronze badges

2

Also had this problem (the title, not the specific error message), as well as squiggly lines in the editor. The first squiggly line is under the first #include statement, which names a precompiled header. Intellisense fails to include the precompiled header, but doesn’t list that as an error; instead it lists errors further down the file, on code that (very rightfully) relies on declarations in the precompiled header.

The reason Intellisense doesn’t find the precompiled header in my environment is that the header named is not an actual file. It doesn’t have to be in any other VC or gcc version I used, nor in the 2015 compiler, as long as the precompiled header settings are correctly configured. Apparently not any more for Intellisense. I’m not entirely sure it was different in 2013, maybe I just never noticed.

In the unlikely case that this would be the problem reported here, the solution is simple: create a small file with the pretend-name of the precompiled header, as specified in #include directives, and let that file include the actual name of the precompiled header.

If you wonder… why this distinction between the precompiled header name in the ‘#include’ statement and the actual filename of the precompiled header? Precisely because it guarantees that precompiled header settings are correctly configured. Wherever a precompiled header is «#included», there is no file around that could be included. Either an actually precompiled (binary) version of the actual header is read, or the compilation fails. Obviously, a disadvantage is that it confuses people reading the code, not just Intellisense.

answered Sep 15, 2015 at 20:55

Stein's user avatar

SteinStein

1,48923 silver badges30 bronze badges

Visual Studio 2017
I have deleted «.suo» file from location .vsSolutionNamev15.suo
And then restarted Visual studio. This worked for me.

answered Sep 10, 2018 at 14:46

Saurabh Raoot's user avatar

Saurabh RaootSaurabh Raoot

1,1733 gold badges24 silver badges30 bronze badges

Today I’ve had similar problem with MSVC++ 2015. I almost gave up and decided to go on without IDE hints, but suddenly I’ve noticed that stdafx.h of the project i had problems with doesn’t contain any standard library headers. I’ve speculated that inclusion of all standard headers used in the project in stdafx.h might boost up compilation speed, however doing so fixed Intellisense errors as well.

answered Jan 22, 2017 at 19:40

Minor Threat's user avatar

Minor ThreatMinor Threat

2,0051 gold badge17 silver badges31 bronze badges

In Visual Studio 2019 the problem is with changing branches with Git when there are NuGet packages installed in the project. What I did to solve this:

  1. Clean Solution
  2. Close Visual Studio
  3. Delete the packages folder
  4. Open Visual Studio
  5. Go to Package Manager
  6. Restore all packages
  7. Recompile
  8. If roslyn is missing, close and open Visual Studio, then recompile.

answered Mar 16, 2020 at 15:28

Daniel Lobo's user avatar

Daniel LoboDaniel Lobo

2,1351 gold badge12 silver badges6 bronze badges

I had multiple stdfax.h in Additional Include Directories. Make sure the stdafx.h you intended is first in your path.

answered May 30, 2017 at 14:56

I had a similar issue with different Visual Studio versions.

Deleting the .suo or .vs folder did not help for me.

The Solution for me was, that I had the Extension StopOnFirstBuildError active. After turning off «Stop build on first error» in the build menu, and after the solution was fully built, the errors shown by Intellisense went away.

answered Mar 13, 2018 at 7:34

Fabian's user avatar

FabianFabian

1,0009 silver badges14 bronze badges

I was seeing the intellisearch errors only when publishing a website. (ASP/C# site, VS 2017). They broke the publish. Site ran fine locally.

Cleared the errors by unchecking the setting to pre-compile, and it published fine.
Publish -> Setting -> File Publish Options -> Precompile during publishing

answered May 10, 2018 at 18:02

Rahn's user avatar

RahnRahn

5085 silver badges11 bronze badges

I had this issue with a reference to another project. Removing and re-adding the project reference worked for me.

answered Oct 8, 2021 at 18:50

Chris's user avatar

ChrisChris

2,1191 gold badge22 silver badges36 bronze badges

We are currently evaluating the new Visual Studio 2015 and encountered a strange problem with IntelliSense. When I compiled our main solution with the new studio the build succeeds, but nevertheless 6 errors are shown.

I discovered that it’s not a real error, but only an intellisense error. The code is definitely correct and everything compiled successfully. The code however is marked red and errors show up in the error list.

All 6 errors have the same origin. It’s a simple constructor call. Strange enough, but there are also some occurrences of the exact same constructor without any errors.

The error message:

Code: CS1729
Message: '<the class>' does not contain a constructor that takes that many arguments.
Project: <the project name>
File: <the path to the file>

The new studio was installed on a freshly installed Windows 7 without any legacy software (no VS13).

I’ve already tried to clear the caches, deleted the suo file, deleted bin and obj directories, cleaned and rebuilt the solution etc. But nothing worked.

Can anyone explain that behavior to me?

Karel Kral's user avatar

Karel Kral

5,1166 gold badges40 silver badges48 bronze badges

asked Aug 11, 2015 at 13:49

Ash's user avatar

8

I had thousands of intellisense errors and 0 build errors. After deleting .suo file and restarting VS intellisense errors are gone.

Suo file is located relatively to source in:
.vsSolutionNamev14.suo

According to comment: Beware that *.suo is a hidden file.

Edit: According to comments, VS2017 has the same issue, so you can use similar solution: Delete .vsSolutionNamev15.suo

VS2019 still has this issue. Delete .vsSolutionNamev17.suo

If deleting .suo still does solve your problem, then delete also all bin and obj directories in every project in the solution.

answered Nov 2, 2015 at 12:30

Karel Kral's user avatar

Karel KralKarel Kral

5,1166 gold badges40 silver badges48 bronze badges

9

Also had this problem with a migrated project, so I referenced the Microsoft.CSharp dll. In some projects I needed to remove and add again the Reference in the project.

answered Sep 15, 2015 at 12:40

Guilherme de Jesus Santos's user avatar

7

Ran into similar issue in Visual Studio 2017 ASP.Net Core Project. Following steps did the trick for me

  1. Perform Clean Solution
  2. Close VS
  3. Delete .suo file & Delete bin/obj directories
  4. Reopen VS

answered Apr 1, 2017 at 21:24

Naren's user avatar

NarenNaren

77714 silver badges12 bronze badges

2

Similar problem as others, but different resolution. Posting in case I can help someone else.

Running Visual Studio 2017 15.5.2. I use Git and frequently switch branches. Several weeks ago, I started having editors show me errors (all related to types it could not find even though references were valid). Compile worked great. I confirmed the same issue in VS 2017 15.6 Preview (Jan 6, 2018). I would try to delete cache, SUO files, or bin/obj folders and no impact. At first it would appear to work. Reopen Visual Studio and everything would look good. Use «Rebuild Solution» and the IntelliSense errors would returns. I even tried uninstall/reinstall of Visual Studio.

I had the same issue on two machines, both with same version of Visual Studio.

By looking at the errors about missing types, they all appeared to come from two referenced projects. One of those references was a shared project used by just about every other project in the solution, but one of them was a small project without many references. It just so happens that the small project was also referenced by my larger shared project. In Visual Studio, I unloaded the small project and reloaded it. The errors went away! They errors did not come back on Rebuild Solution.

I then switched Git branches and the errors all came back. Fortunately I repeated the above steps of unloading/reloading the small project and the errors went away.

Every time I switch Git branches, the errors come back until I repeat that process. There are zero changes between the Git branches for the smaller project that I unload/reload. Unclear why that sequence is fixing my issue.

answered Jan 6, 2018 at 17:39

HgCoder's user avatar

HgCoderHgCoder

1,2439 silver badges14 bronze badges

2

Also had this problem (the title, not the specific error message), as well as squiggly lines in the editor. The first squiggly line is under the first #include statement, which names a precompiled header. Intellisense fails to include the precompiled header, but doesn’t list that as an error; instead it lists errors further down the file, on code that (very rightfully) relies on declarations in the precompiled header.

The reason Intellisense doesn’t find the precompiled header in my environment is that the header named is not an actual file. It doesn’t have to be in any other VC or gcc version I used, nor in the 2015 compiler, as long as the precompiled header settings are correctly configured. Apparently not any more for Intellisense. I’m not entirely sure it was different in 2013, maybe I just never noticed.

In the unlikely case that this would be the problem reported here, the solution is simple: create a small file with the pretend-name of the precompiled header, as specified in #include directives, and let that file include the actual name of the precompiled header.

If you wonder… why this distinction between the precompiled header name in the ‘#include’ statement and the actual filename of the precompiled header? Precisely because it guarantees that precompiled header settings are correctly configured. Wherever a precompiled header is «#included», there is no file around that could be included. Either an actually precompiled (binary) version of the actual header is read, or the compilation fails. Obviously, a disadvantage is that it confuses people reading the code, not just Intellisense.

answered Sep 15, 2015 at 20:55

Stein's user avatar

SteinStein

1,48923 silver badges30 bronze badges

Visual Studio 2017
I have deleted «.suo» file from location .vsSolutionNamev15.suo
And then restarted Visual studio. This worked for me.

answered Sep 10, 2018 at 14:46

Saurabh Raoot's user avatar

Saurabh RaootSaurabh Raoot

1,1733 gold badges24 silver badges30 bronze badges

Today I’ve had similar problem with MSVC++ 2015. I almost gave up and decided to go on without IDE hints, but suddenly I’ve noticed that stdafx.h of the project i had problems with doesn’t contain any standard library headers. I’ve speculated that inclusion of all standard headers used in the project in stdafx.h might boost up compilation speed, however doing so fixed Intellisense errors as well.

answered Jan 22, 2017 at 19:40

Minor Threat's user avatar

Minor ThreatMinor Threat

2,0051 gold badge17 silver badges31 bronze badges

In Visual Studio 2019 the problem is with changing branches with Git when there are NuGet packages installed in the project. What I did to solve this:

  1. Clean Solution
  2. Close Visual Studio
  3. Delete the packages folder
  4. Open Visual Studio
  5. Go to Package Manager
  6. Restore all packages
  7. Recompile
  8. If roslyn is missing, close and open Visual Studio, then recompile.

answered Mar 16, 2020 at 15:28

Daniel Lobo's user avatar

Daniel LoboDaniel Lobo

2,1351 gold badge12 silver badges6 bronze badges

I had multiple stdfax.h in Additional Include Directories. Make sure the stdafx.h you intended is first in your path.

answered May 30, 2017 at 14:56

I had a similar issue with different Visual Studio versions.

Deleting the .suo or .vs folder did not help for me.

The Solution for me was, that I had the Extension StopOnFirstBuildError active. After turning off «Stop build on first error» in the build menu, and after the solution was fully built, the errors shown by Intellisense went away.

answered Mar 13, 2018 at 7:34

Fabian's user avatar

FabianFabian

1,0009 silver badges14 bronze badges

I was seeing the intellisearch errors only when publishing a website. (ASP/C# site, VS 2017). They broke the publish. Site ran fine locally.

Cleared the errors by unchecking the setting to pre-compile, and it published fine.
Publish -> Setting -> File Publish Options -> Precompile during publishing

answered May 10, 2018 at 18:02

Rahn's user avatar

RahnRahn

5085 silver badges11 bronze badges

I had this issue with a reference to another project. Removing and re-adding the project reference worked for me.

answered Oct 8, 2021 at 18:50

Chris's user avatar

ChrisChris

2,1191 gold badge22 silver badges36 bronze badges

Время прочтения
5 мин

Просмотры 24K

Это был чудесный летний день. За окном сияли тучки, нежными голосами пели вороны, на автомойке весело пачкали шампунем чью-то машину, за стеной тихо скрёбся перфоратор — в общем, идиллия.

Ничего не предвещало беды ровно до того момента, как я запустил только что собранную в режиме релиза программу, чтобы проверить изменения до того, как передать их в отдел тестирования.

Предыстория

Компания у нас существует относительно давно, и основной продукт уже старше некоторых сотрудников компании, так что древнего кода хватает. Тем не менее, мы стараемся держаться в современном русле, Modern C++ активно используется, поэтому около года назад основной проект был переведён на VC2015. Это был отдельный цирк с конями, бубнами, блэкджеком и валерьянкой. Вспомогательный код переводится по мере того, как появляется время и желание. В данном случае, я решил перевести на VC2015 один из таких вспомогательных проектов, который очень активно используется нашей техподдержкой.

Я был уверен, что уже знаю подводные камни такого перехода, и что задача займёт не более часа работы.

Внешне программа проста: она показывает список строк, взятых из разных таблиц базы данных. Когда пользователь выделяет какую-либо строку, заголовки столбцов списка меняются на названия столбцов в соответствующей таблице.

И тут я замечаю, что этого не происходит.

In Vivo

Проверяю несколько раз, воспроизводимость стопроцентная. Собираю проект с нуля, запускаю, проверяю. Нуль на массу.

Это было странно, потому что я совершенно точно помню, что столбцы во время отладки переключались правильно, это было частью тест-кейса. Дабы убедиться в собственной вменяемости, запускаю Debug-версию и вижу, что столбцы переключаются. Также убеждаюсь, что ошибка появляется, как только я включаю любую оптимизацию.

Какой прекрасный денёк.

Функция обновления заголовков сама по себе довольно простая. Сначала она считает некий condition, а затем работает примерно вот такой код:

int flag = !application->settings.showsize; // showsize имеет тип BYTE
int first = columnData - flag;
int last = ALL_COLUMNS - flag;
if (condition)
{
    for (int i = first; i < last; i++)
    {
        listctrl.SetColumn(i, "Какой-то текст");
    }
}
else
{
    for (int i = first; i < last; i++)
    {
        listctrl.SetColumn(i, "Какой-то другой текст");
    }
}

Прошу не кидаться урановыми тапками, я уже говорил, что код довольно старый.

Таким образом, при любом раскладе хоть что-нибудь, но должно было происходить. Более того, отладчик, добираясь до этого кода, просто перепрыгивает на конец функции. Открываю дизассемблер и вижу, что весь этот кусок кода (и ещё десяток строк перед ним) в листинге просто отсутствует. Разумеется, оптимизированный код иногда выглядит покруче любого спагетти- и даже валенки-кода. Но в данном случае нигде с самого начала функции нет даже намёка на какие-либо переходы куда-либо ещё. В листинге виден расчёт условия, и сразу после него — выход.

Я начинаю понимать, что ошибка гораздо более интересная, чем казалось в начале, и зову нашего спеца, который в компании занимается ситуациями вида «всякая неведомая хрень», и которого обедом не корми — дай найти какой-нибудь баг в винде. Иллюзий на тему «в компиляторах ошибок не бывает» мы не питаем, однако опыт подсказывает, что 99,99% «ошибок в компиляторах» сводятся к кривым рукам разработчиков программ.

In vitro

Когда ошибка возникает только в оптимизированном коде, это может означать, что мы где-то наткнулись на неизвестное нам UB, и первым кандидатом становится строка

int flag = !application->settings.showsize;

Очень быстро выясняется, что проблема действительно где-то тут, но «не все так однозначно». Стоило заменить выражение на константу, другую переменную, поставить тернарный оператор вместо отрицания или хотя бы поместить структуру на стек, как код волшебным образом появлялся в листинге.

За неимением лучших идей, вытаскиваем эту функцию в отдельный чистый проект и безжалостно выкидываем всё лишнее. Тут же выясняем, что шаманство со структурами и указателями можно заменить на обычный volatile:

#include <stdio.h>
int main()
{
    volatile int someVar = 1;
    const int indexOffset = someVar ? 0 : 1;    // Цикл выбрасывается
    // const int indexOffset = !someVar;        // Цикл выбрасывается
    // const int indexOffset = 0;               // Всё хорошо
    // const int indexOffset = 1;               // Всё хорошо
    // const int indexOffset = someVar;         // Всё хорошо
    // const int indexOffset = someVar + 1;     // Всё хорошо
    for (int i = 1 - indexOffset; i < 2 - indexOffset; ++i)
    {
        printf("Test passedn");
    }
    return 1;
}

Здесь мы были немало удивлены, поскольку в оригинальном коде замена отрицания на тернарный оператор в строке

int flag = !application->settings.showsize;

возвращала кусок кода на место, а для volatile это уже не работало.

Сомнений в том, что мы наткнулись на ошибку в компиляторе, почти не оставалось, однако казалось невероятным, что в десятках мегабайт кода не нашлось похожего куска.

Расследование

Тут стоит отметить, что основная программа сейчас собирается в vs2015 Update 2, поскольку на программу, собранную в Update 3, внезапно стал ругаться антивирус, причём именно тот, который мы устанавливаем клиентам, и могло получиться… некрасиво. Однако у некоторых разработчиков, включая меня, установлен Update 3. Мы проверили на нескольких разных компьютерах и версиях VS, и получилось, что ошибка присутствует только в Update 3. Позднее окажется, что правильнее было написать «начиная с Update 3».

Гугл ясно дал понять, что он не при делах, так что следующим логичным шагом было написание
вопроса на StackOverflow. Надо сказать, отправить на StackOverflow вопрос, начинающийся с фразы «Мы тут ошибку в компиляторе нашли» — это всё равно, что порезать себе руку и прыгнуть в бассейн с акулами, но в данном случае акулы оказались сытыми и доброжелательными. Буквально через несколько минут тестовый пример ещё больше упростили, подсказали инструмент, который позволял посмотреть результат трансляции этого кода разными компиляторами, и, что ещё важнее, прозвучала волшебная фраза «new SSA optimizer introduced in VS2015 Update 3». Там же упоминался волшебный ключик -d2SSAOptimizer-, отключающий новый оптимизатор.

На этот раз гугление привело нас в блог Introducing a new, advanced Visual C++ code optimizer разработчика из Visual C++ Optimizer team с его координатами и предложением отправлять ему сообщения об ошибках, чем мы и воспользовались. И буквально через 10-15 минут получили следующий ответ:

Да, это определённо ошибка в самом SSA-оптимизаторе — обычно большинство ошибок, о которых нам сообщают, как об ошибках оптимизатора, находятся в других местах и иногда проявляются спустя 20 лет только сейчас.

Ошибка в небольшой оптимизации, которая пытается удалить сравнения вида (a — Const1) CMP (a — Const2), если не происходит переполнения. Ошибка возникает из-за того, что в вашем коде есть выражение (1 — indexOffset) CMP (2 — indexOffset), и, хоть вычитание, разумеется, некоммутативно, оптимизатор этого не учитывает и обрабатывает (1 — indexOffset), как будто это (indexOffset — 1).

Исправление для этой ошибки будет опубликовано в следующем большом обновлении для VS2017. До этого времени хорошим решением может стать отключение SSA-оптимизатора для этой функции, если это не вызовет сильного замедления. Это можно сделать с помощью #pragma optimize(«», off): msdn.microsoft.com/en-us/library/chh3fb0k.aspx

Оригинал

Yes, this is indeed a bug in the SSA Optimizer itself — usually most bugs reported as being in the new optimizer are in other parts, sometimes exposed now after 20 years.

It’s in a small opt. that tries to remove a comparison looking like (a — Const1) CMP (a — Const2), if there is no overflow. The issue is that your code has (1 — indexOffset) CMP (2 — indexOffset) and subtraction is not commutative, of course — but the optimizer code disregards that and handles (1 — indexOffset) as if it’s (indexOffset — 1).

A fix for this issue will be released in the next larger update for VS2017. Until then, disabling the SSA Optimizer would be a decent workaround. Disabling optimizations for only this function may be a better approach if it doesn’t slow down things too much. This can be done with #pragma optimize(«», off): msdn.microsoft.com/en-us/library/chh3fb0k.aspx

Эпилог

Как показало расследование, на текущий момент этой ошибке подвержены все компиляторы VC++, начиная с версии 2015 Update 3 и заканчивая самыми современными версиями. Пока неизвестно, когда будет выпущено исправление, так что если вы обнаружите, что из вашей программы чудесным образом пропадают куски кода, проверьте, может быть новый оптимизатор решил, что этот код ему нужнее, чем вам?

Несколько разочаровывает, что исправление будет выпущено только для VS2017, тем не менее, теперь мы знаем, что с этим делать.

Какой прекрасный денёк!

Спасибо Codeguard за помощь в поиске этой ошибки.

I am getting an «Unknown Error» (shown below) alert when I try to launch Visual Studio 2017 Community after successful installation.

enter image description here

UPDATE: After Force uninstall & reinstallation

enter image description here

Wai Ha Lee's user avatar

Wai Ha Lee

8,41977 gold badges60 silver badges90 bronze badges

asked Mar 10, 2017 at 11:47

Ajay Jadhav's user avatar

10

remove this folder (or similar):

%LocalAppData%MicrosoftVisualStudio15.0_db2a872f

  • folder name 15.0_db2a872f could be different in your machine eg. 15.0_XXXXXXX
  • found in the vs startup log that processing of Progression_NativePackage_Component_x86.pkgdef bailed out, indicating an inconsistent extension installation

Sreekumar P's user avatar

Sreekumar P

5,82211 gold badges57 silver badges81 bronze badges

answered Mar 14, 2017 at 15:12

niclar's user avatar

niclarniclar

9526 silver badges2 bronze badges

7

I only had to rename(if you wan’t to back it up)/delete the following file:

privateregistry.bin

or

privateregistry.user.bin

depending on Visual Studio version.

%LocalAppData%MicrosoftVisualStudio15.0_********privateregistry.bin

%LocalAppData%MicrosoftVisualStudio15.0_********privateregistry.user.bin

After restarting Visual Studio 2017 you may need to activate Tools or Extensions again.

Community's user avatar

answered Mar 26, 2017 at 13:54

Bruno Bieri's user avatar

Bruno BieriBruno Bieri

9,55311 gold badges61 silver badges89 bronze badges

7

Please check if the machine has Symantec Workspace Virtualization Agent installed. Removing the product from addremove programs fixed the unknown error while launching VS 2017.

Here is the detail of the product.
Product code: {785F9A4D-D113-43B3-AA1D-77AD777F0A2F}
Package code: {32DB9767-3EF7-465A-ADF2-7ECFD25ABC12}
Install date: 2015.05.21
Version: 6.4.1266
Publisher: Symantec

answered Mar 23, 2017 at 15:22

rathish rk's user avatar

rathish rkrathish rk

4144 silver badges8 bronze badges

I ran it as Admin and it somehow booted up just fine after that. I was getting the same error even after making sure that all packages and SDKs were installed until I ran it as admin.

Basically, just go to the shortcut in Start or to the .exe in the files, then right click it and run as Admin or change it in the properties. Tbh, it seems like a temporary fix and I’d actually like to know the real source of the problem, but for now, I don’t have to reinstall and repair over and over.

Same version: Visual Studio Community 2017 installed using the launcher

answered Mar 13, 2017 at 13:11

Sorral's user avatar

3

I have a same problem after update VS 2017 Enterprise to the build 26228.9.

Repair installation doesn’t fix anything. Still I got «Unknown error» message immediately after start VS2017.

Fixing is possible by removing this folder:

"C:UsersUSER_NAMEAppDataLocalMicrosoftVisualStudio15.0_xxxxxxx"

where xxxxxxxx is some hexadecimal number.

BUT AFTER THAT YOU LOSE ALL SETTINGS that you done on your installation of VS 2017 (except product license key appliance).

Sorry that I must say this, but:

Maybe will be better stuck on the VS2015 for now. Because MS still not has really fully functional build of VS for now.

VS 2017 is still ready for first experimenting only and not for real work.

It is same story like a was when VS2015 has been published. (after several days stop working).

Neil's user avatar

Neil

14k3 gold badges28 silver badges50 bronze badges

answered Mar 16, 2017 at 14:33

Poke's user avatar

0

I fixed it the same way as niclar by deleting folder 15_.*. It does however appear that renaming privateregistry.bin has same effect with less trouble.

As mentioned by Torbjorn, ReSharper and other Extensions can mess up, however no reinstall required.

Merely go to Tools > Extensions and Updates… > Scroll through list of Installed Extensions > Enable those that should be enabled.

answered Apr 11, 2017 at 7:21

Emil L.'s user avatar

I have a side by side installation with VS2015. After opening and closing VS2015 once, VS2017 ist starting again normally. Strange but helped in my case.

answered May 15, 2017 at 8:17

martinoss's user avatar

martinossmartinoss

5,0482 gold badges45 silver badges50 bronze badges

I only needed to delete or rename ApplicationPrivateSettings.lock within C:users{your username}AppDataLocalMicrosoftVisualStudio15.0_c31ecfb9 folder.

answered Jun 8, 2017 at 16:56

Nick Painter's user avatar

I was experiencing this issue with Visual Studio Professional
when not running as administrator. (It worked Ok as administrator)
I used Niclar’s solution of deleting the folders.

answered Jul 17, 2017 at 21:14

Kirsten's user avatar

KirstenKirsten

14.3k38 gold badges166 silver badges295 bronze badges

I found same issue after installing the extension and removing the folder «C:UsersUSER_NAMEAppDataLocalMicrosoftVisualStudio15.0_xxxxxxx» solved my problem.

answered Sep 2, 2019 at 5:19

Roh8Stha's user avatar

1

you can rename the Solution Name and reopen the Project it solved for me after repairing the VS Installation

answered May 20, 2020 at 22:44

Mohamed Farrag's user avatar

I am getting an «Unknown Error» (shown below) alert when I try to launch Visual Studio 2017 Community after successful installation.

enter image description here

UPDATE: After Force uninstall & reinstallation

enter image description here

Wai Ha Lee's user avatar

Wai Ha Lee

8,41977 gold badges60 silver badges90 bronze badges

asked Mar 10, 2017 at 11:47

Ajay Jadhav's user avatar

10

remove this folder (or similar):

%LocalAppData%MicrosoftVisualStudio15.0_db2a872f

  • folder name 15.0_db2a872f could be different in your machine eg. 15.0_XXXXXXX
  • found in the vs startup log that processing of Progression_NativePackage_Component_x86.pkgdef bailed out, indicating an inconsistent extension installation

Sreekumar P's user avatar

Sreekumar P

5,82211 gold badges57 silver badges81 bronze badges

answered Mar 14, 2017 at 15:12

niclar's user avatar

niclarniclar

9526 silver badges2 bronze badges

7

I only had to rename(if you wan’t to back it up)/delete the following file:

privateregistry.bin

or

privateregistry.user.bin

depending on Visual Studio version.

%LocalAppData%MicrosoftVisualStudio15.0_********privateregistry.bin

%LocalAppData%MicrosoftVisualStudio15.0_********privateregistry.user.bin

After restarting Visual Studio 2017 you may need to activate Tools or Extensions again.

Community's user avatar

answered Mar 26, 2017 at 13:54

Bruno Bieri's user avatar

Bruno BieriBruno Bieri

9,55311 gold badges61 silver badges89 bronze badges

7

Please check if the machine has Symantec Workspace Virtualization Agent installed. Removing the product from addremove programs fixed the unknown error while launching VS 2017.

Here is the detail of the product.
Product code: {785F9A4D-D113-43B3-AA1D-77AD777F0A2F}
Package code: {32DB9767-3EF7-465A-ADF2-7ECFD25ABC12}
Install date: 2015.05.21
Version: 6.4.1266
Publisher: Symantec

answered Mar 23, 2017 at 15:22

rathish rk's user avatar

rathish rkrathish rk

4144 silver badges8 bronze badges

I ran it as Admin and it somehow booted up just fine after that. I was getting the same error even after making sure that all packages and SDKs were installed until I ran it as admin.

Basically, just go to the shortcut in Start or to the .exe in the files, then right click it and run as Admin or change it in the properties. Tbh, it seems like a temporary fix and I’d actually like to know the real source of the problem, but for now, I don’t have to reinstall and repair over and over.

Same version: Visual Studio Community 2017 installed using the launcher

answered Mar 13, 2017 at 13:11

Sorral's user avatar

3

I have a same problem after update VS 2017 Enterprise to the build 26228.9.

Repair installation doesn’t fix anything. Still I got «Unknown error» message immediately after start VS2017.

Fixing is possible by removing this folder:

"C:UsersUSER_NAMEAppDataLocalMicrosoftVisualStudio15.0_xxxxxxx"

where xxxxxxxx is some hexadecimal number.

BUT AFTER THAT YOU LOSE ALL SETTINGS that you done on your installation of VS 2017 (except product license key appliance).

Sorry that I must say this, but:

Maybe will be better stuck on the VS2015 for now. Because MS still not has really fully functional build of VS for now.

VS 2017 is still ready for first experimenting only and not for real work.

It is same story like a was when VS2015 has been published. (after several days stop working).

Neil's user avatar

Neil

14k3 gold badges28 silver badges50 bronze badges

answered Mar 16, 2017 at 14:33

Poke's user avatar

0

I fixed it the same way as niclar by deleting folder 15_.*. It does however appear that renaming privateregistry.bin has same effect with less trouble.

As mentioned by Torbjorn, ReSharper and other Extensions can mess up, however no reinstall required.

Merely go to Tools > Extensions and Updates… > Scroll through list of Installed Extensions > Enable those that should be enabled.

answered Apr 11, 2017 at 7:21

Emil L.'s user avatar

I have a side by side installation with VS2015. After opening and closing VS2015 once, VS2017 ist starting again normally. Strange but helped in my case.

answered May 15, 2017 at 8:17

martinoss's user avatar

martinossmartinoss

5,0482 gold badges45 silver badges50 bronze badges

I only needed to delete or rename ApplicationPrivateSettings.lock within C:users{your username}AppDataLocalMicrosoftVisualStudio15.0_c31ecfb9 folder.

answered Jun 8, 2017 at 16:56

Nick Painter's user avatar

I was experiencing this issue with Visual Studio Professional
when not running as administrator. (It worked Ok as administrator)
I used Niclar’s solution of deleting the folders.

answered Jul 17, 2017 at 21:14

Kirsten's user avatar

KirstenKirsten

14.3k38 gold badges166 silver badges295 bronze badges

I found same issue after installing the extension and removing the folder «C:UsersUSER_NAMEAppDataLocalMicrosoftVisualStudio15.0_xxxxxxx» solved my problem.

answered Sep 2, 2019 at 5:19

Roh8Stha's user avatar

1

you can rename the Solution Name and reopen the Project it solved for me after repairing the VS Installation

answered May 20, 2020 at 22:44

Mohamed Farrag's user avatar

Понравилась статья? Поделить с друзьями:
  • Ошибка вебасто s90
  • Ошибка вентилятора печки xerox 3100 mfp
  • Ошибка вебасто h87 неисправность
  • Ошибка вентилятора калина
  • Ошибка визуал c runtime error