ridermansb
ridermansb

Reputation: 11059

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?

Upvotes: 5

Views: 7601

Answers (8)

ulebule
ulebule

Reputation: 1

I had similar problem. File *.pubxml in PublishProfiles folder had saved properties for publish method. There was WebPublishMethod FileSystem and publishUrl tag was some non-existing folder on my computer (it exist's on my other computer).

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>c:\temp\someFolder</publishUrl>  // this folder didn't exist on my computer
    <DeleteExistingFiles>True</DeleteExistingFiles>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
  </PropertyGroup>
</Project>

Upvotes: 0

Alexander Burias
Alexander Burias

Reputation: 343

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

Upvotes: 0

aks
aks

Reputation: 526

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

Upvotes: 1

Daniel Su&#225;rez
Daniel Su&#225;rez

Reputation: 109

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.

Upvotes: 0

Martin
Martin

Reputation: 1

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.

Upvotes: 0

AbdulRahman Ansari
AbdulRahman Ansari

Reputation: 3057

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

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

Upvotes: 0

Mick Byrne
Mick Byrne

Reputation: 14484

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.

Upvotes: 1

JiffyLueb
JiffyLueb

Reputation: 436

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.

Upvotes: 0

Related Questions