Question

Urto on Sun, 26 Aug 2018 08:59:51


I've decided to start learning C++ and since I'm already familiar with Visual Studio 2017 for sake of C#, I decided to stick with it for C++.

Unfortunately, every single project I make fails to build with the output window displaying:

1>------ Build started: Project: TestTwo, Configuration: Debug Win32 ------
1>Object reference not set to an instance of an object.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This particular project began as an Empty C++ Project, and is a basic "Hello World" program.
Below is the entirety of the code, which is all contained in the Main.cpp file, the only file in the entire solution aside from the default external dependencies.

#include <iostream>

int main()
{
	std::cout << "Hello World!" << std::endl;
	std::cin.get();
}
It's not this project alone, either. Even if I make a new console project and make no edits whatsoever to the project, I get the same error.

The error list is completely empty as well, offering no greater insight as to what the issue is. At this point, I've been banging my head against this for hours and am completely stumped. Any help would be appreciated.




Replies

WayneAKing on Sun, 26 Aug 2018 09:22:14


I've decided to start learning C++ and since I'm already familiar with Visual Studio 2017 for sake of C#, I decided to stick with it for C++.

Unfortunately, every single project I make fails to build with the output window displaying:

1>------ Build started: Project: TestTwo, Configuration: Debug Win32 ------
1>Object reference not set to an instance of an object.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


What components did you install for C++ in VS?

Note that there is a forum for install issues:

Visual Studio Setup and Installation
https://social.msdn.microsoft.com/Forums/en-US/vssetup/threads

- Wayne

Urto on Sun, 26 Aug 2018 09:58:03


JIT debugger
VC++ 2017 15.8 v14.15 latest v141 tools
C++ profiling tools
Windows 10 SDK (10.0.17134.0)
Visual C++ tools for CMake
Visual C++ ATL for x86 and x64
Test Adapter for Boost.Test
Test Adapter for Google Test
Visual C++ MFC for x86 and x64
C++/CLI support
Incredibuild - Build Acceleration
Windows 10 SDK (16299) for Desktop C++

I have also tried installing and uninstalling the two Windows SDKs in various combinations for fear they were contradicting in some way.

I'm entirely new to C++ so I'm not really sure if this is me installing wrong? Will gladly move forums if necessary.

Jack Zhang - AAA on Wed, 12 Sep 2018 08:18:57


Hi,

Have you met any error when you install the Desktop development with C++?

I suggest you download the Microsoft Visual C++ Redistributable packages for Visual Studio 2017, and install it.

Best Wishes,

Jack Zhang

DasNeo on Wed, 12 Sep 2018 09:04:01


Hey,

I have the same error. It started for me a few hours ago. (worked yesterday)

As I don't really know what to do about this please tell me what information you need in order to help.

Redist is already installed.

Thanks,

André.

Edit:

I found a solution for the error:

C:\Users\{user}\AppData\Local\Microsoft\VisualStudio\{version}\ComponentModelCache

Just delete the folder ComponentModelCache.

Found here: https://stackoverflow.com/questions/34084003/visual-studio-2015-error-object-reference-not-set-to-an-instance-of-an-object#comment58856322_34085345



Menox1981 on Thu, 06 Jun 2019 19:31:35


Thanks for this.  It fixed my problem.  I have a solution with many projects and every one was failing with this error.  I followed your instructions and everything is building again.

Thanks!!!