'Error when I click publish | "Object reference not set to an instance of an object"

I'm trying to publish the files of a project I just created in Visual Studio 2012.

When I click publish,

enter image description here

the following window is displayed

enter image description here

Already created a new web project (same type, asp.net mvc 4) and tried to make the same change and everything worked. Apparently this only occurs on this project!

Already closed the "VS" and opened again as I restarted the PC .. Any tips?



Solution 1:[1]

Do you have a <clear/> element in your <connectionStrings> element in your web.config? If so, delete it and you should be able to publish.

Solution 2:[2]

Also check your ProjectTypeGuids in your .csproj file. I had a similar problem, though not exactly the same, and the source was because other team members had opened the project in VS2012, while I was on VS2010. VS2012 forces you to transform an MVC2 site into an MVC3 site, which VS2010 then cannot handle when it comes to publishing.

Poor backwards compatibility if you ask me.

Solution 3:[3]

I also faced same issue while publishing our project in Visual Studio 2010.

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

Solution 4:[4]

For me, deleting the files with extension .pubxml & .pubxml.user from src folder is what fixed it. I had to re-configure publish settings afterwards. Bear in mind that you may have to delete them a couple of times and restart the IDE for this to work.

Solution 5:[5]

OK, I've just finished solving this problem. It's an error in the web.config. Checking the output it pointed to Microsoft.Meb.Publishing.targets, line 2309, as the source of the error. If you check that line by double clicking the output, it will show the ParameterizeTransformXml node. This makes the sustitutions between release/debug.config and the web.config published.

In our case a Merge on git caused the problem on the web.config file. But as JiffyLueb said, any other unexpected tag can cause the problem.

Solution 6:[6]

I have answered this question here. Basically, you need to repair your Visual Studio Installation.

Solution 7:[7]

For me it was the length of Directory on where the whole project sits.

I moved it into somewhere closer to root and it went ok

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JiffyLueb
Solution 2 Mick Byrne
Solution 3 AbdulRahman Ansari
Solution 4 Martin
Solution 5 Daniel Suárez
Solution 6 aks
Solution 7 Alexander Burias