35

When I build my solution with a bunch of cloud projects, I see one or more "Error: Object reference not set to an instance of an object" messages in the output. When I try to run one of the cloud projects, I get the popup "There were build errors. Do you want to continue and run the last successful build", but there are no errors in the Error List and the same "Error: Object ref..." errors in the output.

When I click package on my cloud project I get a messagebox with "Object reference not set to an instance of an object", also when I right click -> properties on the project reference under "Roles" in the cloud project.

If I use the command line to build my solution with msbuild, I don't get the error.

I tried restarting Visual Studio as well as my PC. I also tried reinstalling Azure Tools (2.1) and then Visual Studio.

My colleague is now getting the same problem on Visual Studio 2013 RC.

Has anyone had the same problem?

I've searched, but only found people with problems when publishing, where the solution is to package manually.

Matthijs Wessels
  • 6,530
  • 8
  • 60
  • 103
  • 1
    I've been getting the exact same problem since this morning. did you ever find a solution. One other thing I noticed is if I select the a role in the cloud project and click delete, it says "The service definition or service configuration is invalid - please fix these files to complete this operation" – Eoin Campbell Nov 21 '13 at 16:18
  • @EoinCampbell I have worked on another non-cloud project for a few weeks. After I came back to the cloud project, I didn't get the same problems anymore. The only thing I can think of that changed is that I installed Azure Tool 2.2 (we still use 2.1 in the projects though). – Matthijs Wessels Nov 22 '13 at 08:30
  • Thanks. I'd also updated to 2.2 in the past few days. turns out my problem was related to a missing diagnostics.wadcfg file which was marked as an ignored extension in our git-ignore file. cheers for the response. – Eoin Campbell Nov 22 '13 at 11:05
  • I'm on VS2013 and Azure Tools 2.2. This problem randomly started occurring today for me, and a reinstall of Azure Tools 2.2 fixed it. Thanks for pointing me in the right direction guys. – HaterTot Dec 03 '13 at 21:21
  • @HaterTot I also installed [this hotfix](http://blogs.msdn.com/b/cie/archive/2013/10/31/compute-emulator-invalid-access-to-memory-location.aspx). It fixes another bug where the emulator keeps crashing, but who knows, maybe it also fixes this bug. – Matthijs Wessels Dec 03 '13 at 22:08
  • 1
    I removed the project and then re-added and it seemed to clear it up. – user3232817 Feb 19 '14 at 13:35

11 Answers11

46

I had the same problem. Right click on the cloud service project, unload the project. Reload it again.

Siva
  • 469
  • 4
  • 2
  • 2
    This fixed my issue. Been battling with some nuget package installs/uninstalls and something must have been upset. – Phil Cooper Sep 09 '14 at 18:05
  • 1
    This actually worked for me as well! I have no idea what this accomplishes.. VS or tooling bug I assume? – jdraper3 Nov 14 '14 at 22:24
  • my god, this simple action fixes it! – bychance Mar 23 '15 at 02:37
  • Restarting Visual Studio also solved the problem for me - probably for the same reason. – RMD Mar 26 '15 at 14:59
  • Interesting. I had the same issue building whole solution (10 projects). Building projects separately one by one was without error. But I can't run it. I have tried to close and re-open a solution and restart VS, but without success. Unloading / reloading an Azure project solved it. VS is a great tool, but I really hate this issues with VS (all that restarts, closings and re-openings etc.). I didn't experience similar issues in Linux world. – David Ferenczy Rogožan Apr 28 '15 at 16:10
  • It fixed error on my Cordova Phonegap project in VS2015. – Marek Jan 17 '17 at 15:23
9

Try removing the role from the cloud project, re-build solution (if there are errors please post them), then add the role back into the cloud project and re-build.

ahmed.eltawil
  • 561
  • 4
  • 16
  • Thanks for the answer. I've remove and re-added it but not luck. If I build without the cloud project in the solution, it works. However, even if with the cloud project is in the solution and I select the web application and choose build, it also builds without errors. – Matthijs Wessels Oct 10 '13 at 20:59
  • Are you able to package one of the other cloud projects without errors? Is it only this one particular cloud project? – ahmed.eltawil Oct 14 '13 at 18:40
  • One of them actually. The others (about 6) give me the same error. Although the one that works fails sometimes as well. The only difference I can think of is that it's a much simpler web application (i.e. the home page). – Matthijs Wessels Oct 14 '13 at 19:59
3

I had a similar issue when a publish exited out and I started receiving the 'Object not found' error. VS2013 (in my case) was reporting that 'diagnostics.wadcfg' was missing and had unusually stored this into a different directory.

By going into the project file (.ccproj) and removing the erroneous entry from the 'Project\ItemGroup\Content Include "\diagnostics.wadcfg" and reloading the project - everything kicked back into life.

Failing that, check a working project file against the offending project file for inconsistencies.

SeanCocteau
  • 1,838
  • 19
  • 25
  • I think that also happened in my case, but correcting it didn't solve the problem. I even did a complete clean checkout and it wouldn't work on my machine while it worked on my colleage's – Matthijs Wessels Apr 02 '14 at 14:44
  • a diagnostics.wadcfg that was not checked in was the cause of the problem for me – wallismark Sep 08 '14 at 02:52
3

You don't have to remove your roles and add them back in again, which is really annoying because you have to preserve the contents of your cscfg and csdef files. Instead, close Visual Studio, delete the solution's .suo file and open the solution back up again.

Dustin Metzgar
  • 313
  • 2
  • 6
  • this actually worked for me. Removing the .suo file (which was huge btw) allowed me to open properties page for Azure project that was previously throwing "Object not set to a reference" error. – Roboblob Nov 20 '15 at 14:30
2

I wanted to let everyone know I was dealing with a very similar situation, albeit with a different version of the Azure SDK (1.8). I have many projects with Cloud Services that I have created built numerous times and then all of sudden could no longer open them. Attempting to open the Cloud Service configuration UI resulted in the “Object not set to a reference” error. I could open the actual XML file, but not the GUI interface.

I attempted to reinstall the 1.8 SDK and tools numerous times, as well as VS 2012 to no avail. I finally tried installing the latest SDK (2.2) and now I can open the projects. Not sure what changed in my system prior to this but glad I was finally able to open my projects again!

Bryan
  • 21
  • 1
1

I also had this error when building. Projects within the solution would build independently but building the entire solution failed.

I have learnt usually these types of issues are caused by invalid azure role or configuration files. In my case it turns out a .cscfg config file rename on another branch was merged with my branch but it didn't rename the file – therefore the .ccproj file in my branch was incorrectly referring to the new name but only the old filename existing in the solution. After manually editing the .ccproj with the new filename I closed/reopened the solution and things started working.

sham
  • 1,346
  • 1
  • 20
  • 28
0

I had a similar issue with VS2013 express after creating a view in my MVC project.

I reverted the project with git, but this did not solve the issue. I also checked the project out to a different location on my pc, but this did not solve the issue. I was able to check the project out on my laptop without seeing this issue.

In the end, I undinstalled VS2013 express and all of it's counterparts and re-installed. This solved the issue.

trees_are_great
  • 3,881
  • 3
  • 31
  • 62
0

I had this bug (but not using a cloud project). Turns out the character encoding that Perforce (P4V) was using was wrong, it should have been UTF-8. After changing to UTF-8 and re-syncing the code, Visual Studio was able to find and compile the project just fine.

0

Maybe a hint: I got the same error message, when compiling VS2013 Dot42 project - realized it was caused by assigning concrete value of some inner type (in my case Enum) to INullable variable:

private SomeClass.SomeEnum? _var1;
...
_var1 = SomeClass.SomeEnum.XY;    // causes compilation error

The solution was, not to use INullable:

private SomeClass.SomeEnum _var1;
Tono
  • 141
  • 2
  • 4
  • You probably mean [`Nullable`](http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx) instead of [`INullable`](http://msdn.microsoft.com/en-us/library/system.data.sqltypes.inullable(v=vs.110).aspx). Did this cause a compilation error or was there an “Object reference not set to an instance of an object” message in the build output? There shouldn't be any problem with assigning a non-nullable value to a `Nullable`. – Matthijs Wessels Oct 22 '14 at 08:45
  • Yes, sorry - when used Nullable, build output simply ends with: ... 4>C:\Program Files\dot42\Android\dot42.Common.targets(615,5): error : Object reference not set to an instance of an object. ========== Rebuild All: 3 succeeded, 1 failed, 0 skipped ========== – Tono Oct 22 '14 at 09:20
0

None of these answer helped me. I decided to reinstall the Azure tools, and noticed that I had more than one version installed. I uninstalled the old versions, reinstalled the latest version, and this fixed it for me.

Judah Gabriel Himango
  • 58,906
  • 38
  • 158
  • 212
0

I got the same message while publishing our project too, though in Visual Studio 2010.

For me, deleting all the files from bin folder worked.

AbdulRahman Ansari
  • 3,007
  • 1
  • 21
  • 29