Scenario:
Trying to deploy a SharePoint 2010 solution from Visual Studio 2012 you get this error:
Error occurred in deployment step 'Recycle IIS Application Pool': Exception has been thrown by the target of an invocation.
Output:
------ Deploy started: Project: Helpers, Configuration: Debug Any CPU ------
Deployment was not performed for this project because it is a dependent project.
------ Deploy started: Project: SiteColumns, Configuration: Debug Any CPU ------
Active Deployment Configuration: No Activation
Run Pre-Deployment Command:
Skipping deployment step because a pre-deployment command is not specified.
Recycle IIS Application Pool:
Error occurred in deployment step 'Recycle IIS Application Pool': Exception has been thrown by the target of an invocation.
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Deploy: 1 succeeded, 1 failed, 0 skipped ==========
Background:
I am referencing some DLL files located in the "..\..\Binaries\Sharepoint" custom folder (this section in the *.csproj was generated by Visual Studio when I added references through the UI):
<ItemGroup> <Reference Include="Microsoft.SharePoint.Linq, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL"> <HintPath>..\..\Binaries\SharePoint\Microsoft.SharePoint.Linq.dll</HintPath> </Reference> <Reference Include="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL"> <HintPath>..\..\Binaries\SharePoint\Microsoft.SharePoint.Publishing.dll</HintPath> </Reference> ... </ItemGroup>
Fix:
I removed the highlighted parts of the *.csproj above (version, culture, public key token and processor architecture), ending up with this:
<ItemGroup> <Reference Include="Microsoft.SharePoint.Linq"> <HintPath>..\..\Binaries\SharePoint\Microsoft.SharePoint.Linq.dll</HintPath> </Reference> <Reference Include="Microsoft.SharePoint.Publishing"> <HintPath>..\..\Binaries\SharePoint\Microsoft.SharePoint.Publishing.dll</HintPath> </Reference> ... </ItemGroup>
Along with the above solution we must consider other scenarios as well!
http://praveenbattula.blogspot.in/2013/07/error-occurred-in-deployment-step.html
This worked for me. Do you know why the app pool exception was thrown? I have done the fix above and I tried to put back the deleted lines and re-deploy. That worked. Thanks!
This was a long time ago but I think you have different versions of linq and/or publishing dlls installed on your server versus your development machine.