Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Build validation failed: object reference not set to instance of object (Read 3692 times)
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Build validation failed: object reference not set to instance of object
Feb 5th, 2016 at 3:23pm
Print Post  
I am getting a compile fail that I think is related to problems configuring the solution. The project (solution) is in the attached zip file. The verbose output is in output.txt.

I need to see a clear process for opening a .ino sketch and turning it into a solution and project that will compile properly. I suspect that the problem I am encountering may be due to my not doing things in the "proper order" because I don't know what that proper order is.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Build validation failed: object reference not set to instance of object
Reply #1 - Feb 5th, 2016 at 7:51pm
Print Post  
Do you use file,open,arduino project?
  
Back to top
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: Build validation failed: object reference not set to instance of object
Reply #2 - Feb 5th, 2016 at 10:36pm
Print Post  
Yes, then I click on the solution file. It has a project and solution file but I am not sure I created them in the proper order.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Build validation failed: object reference not set to instance of object
Reply #3 - Feb 5th, 2016 at 11:04pm
Print Post  
Hi Bob,

There is no order. As long as you have a C++ project with a name that matches the folder it is located in and there is also a .ino with the same name in the same folder then you have a valid Arduino/VisualMicro project. The Visual Micro "new project" and "open project" simple help you achieve this more easily.

Invalid source file

You should click the "Show all files" mini icon on the tool bar above the "Solution Explorer". Then you will more easily see missing files. I will try to add better messages if files are missing.

In your project called HC-SR04 you have two .ino files and two .h files.

The main source is HC-SR04.ino and you can see the source code for it when you edit it. 

The other .ino is called HC_SR04.ino and it does not exist. When you click to edit HC_SR04.ino you will see a visual studio error telling you it can't be found. Switching on all files also gives clearer indication in the solution explorer with a small yellow exclamation mark.


Potentially confusing LCD.h header file name

Another potential problem is that you have created a file called LCD.h. There is usually an Arduino library with a header called LCD.h This conflict will lead to issues either now or in the future.

Unless of course your plan is to use part of the LCD library but override the LCD.h I think that would still be an issue. 


How to include the arduino core and ensure single compilation of headers

You should use the Visual Micro "right click solution explorer project>add new" to add a new cpp and h to you project. You will see the visual micro icon against the visual micro "new" options. Doing so will allow you to see how to include the arduino core in your .h header files. For example I just created a cpp/h called "Test" and this is what Visual Micro put in the header. It includes the right arduino based on version and ensures the header is compiled just once.


Code
Select All
#ifndef _TEST_h
#define _TEST_h

#if defined(ARDUINO) && ARDUINO >= 100
	#include "arduino.h"
#else
	#include "WProgram.h"
#endif


//put your header code here


#endif
 



How to rename a project

Right click the "project_name.ino" and click "Rename". You should be prompted to rename the Arduino project which involves renaming the project, the containing folder and the .ino. The project at its new location is re-added to the solution. You can also do this manually, .sln files can be edited with notepad.
« Last Edit: Feb 5th, 2016 at 11:25pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint