“Object reference not set to an instance of an obj

2019-02-02 06:49发布

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.

11条回答
够拽才男人
2楼-- · 2019-02-02 07:14

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.

查看更多
Ridiculous、
3楼-- · 2019-02-02 07:16

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.

查看更多
该账号已被封号
4楼-- · 2019-02-02 07:20

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.

查看更多
时光不老,我们不散
5楼-- · 2019-02-02 07:21

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.

查看更多
Viruses.
6楼-- · 2019-02-02 07:23

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

查看更多
登录 后发表回答