8

I've got a solution where I've got worker role, some project library and cloud service. Sometimes I cannot build solution (without changing source code or anything).

Output windows shows:

1>Error: Object reference not set to an instance of an object. ========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========

When I try edit worker role properties in Cloud Service project, I got popup window "Object reference not set to an instance of an object".

When I try to remove worker from Cloud Service project, I got popup window

"Windows Azure Tools for Microsoft Visual Studio.

The service definition or the service configuration is invalid. Please fix the error(s) in the service definition (.csdef) or service configuration (.cscfg) files to perform this action."

I'm not sure if it is connected with build problem - but when build is working those problems also not exist, so I can assume that this is somehow connected.

This is strange because I can't figure why sometimes it's working and sometimes not.

Anybody?

pyskaty
  • 125
  • 1
  • 4
  • 3
    I ran into this issue just a few days ago. The solution was working perfectly fine and after a few hours (without any code change), I started to get this error. The way I solved this problem is by removing the cloud services project from the solution and adding them again. I still don't know why it failed in the 1st place and why my solution worked but it worked :). Do try it out and see if it solves your problem. – Gaurav Mantri Jul 30 '14 at 13:49
  • I did this same. I've got already few unloaded cloud service projects :) Still searching for a solution. – pyskaty Aug 06 '14 at 14:33
  • 2
    I have encountered the same sporadic issue also and I've found that if I edit the configuration of the service (`.cscfg`) outside of Visual Studio in order to force a reload, then the error is gone... It's only a workaround but it may help someone else – Yannick Blondeau Aug 19 '14 at 23:19

3 Answers3

13

I was able to fix this problem by unloading the Azure project and then reloading it.

  1. Right click the Azure project.
  2. Click "Unload Project".
  3. Right click Azure project again.
  4. Click "Reload Project".

Update

This just happened to me again and these steps were not enough, I had to close Visual Studio and open it again.

tkburbidge
  • 352
  • 5
  • 10
0

In my case, I go the same error after I migrated the solution from VS 2005 to vs 2013. The error is only coming when I build the website.

The only way the error was cleared when I run VS 2013 as Admin.

tarekahf
  • 738
  • 1
  • 16
  • 42
0

I fought with that same one last weekend, after upgrading from SDK 2.1 to 2.5. I found that something (possibly the Azure Caching package?) was occasionally adding an <Import moduleName="Diagnostics" /> to the .csdef file. This is invalid, because diagnostics are done a different way in SDK 2.5. Removing that line would usually get the build working again, but then it would randomly break again.

The only way I managed to fix it was to create a new Cloud project from scratch, re-add all my roles, and copy over the settings.

Brian Reischl
  • 7,216
  • 2
  • 35
  • 46