Visual Studio 2010 Deployment Error

I recently started receiving the following error while deploying my SharePoint 2010 solution from Visual Studio:

Error    11    Error occurred in deployment step 'Add Solution': Failed to load receiver assembly…

After spending some time searching through my project, I finally decided to enable Assembly Bind Logging. Looking at the logs revealed this:

LOG: DisplayName = XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXX (Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/Extensions/Microsoft/SharePoint/
LOG: Initial PrivatePath = C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\SharePoint\VstspCache2584
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\SharePoint\vssphost4.exe.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Post-policy reference: XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXX
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

The key piece of information turned out to be the PrivatePath. It pointed me to vssphost4.exe which is the process that actually executes SharePoint commands. The commands are not executed directly from Visual Studio but rather this other 64-bit process. Vssphost4.exe was the source of the error. The solution? Kill that process and let Visual Studio spin up a new instance. My problem disappeared. Hopefully this will save someone else some head-scratching.

Incidentally, while searching for a solution, I came across this MSDN article on debugging extensions for SharePoint tools and vssphost4.exe.

5 comments:

André Rentes said...

Hi Steve,

This problem it's annoying and I tried your solution but didn't work..

my error is:

Error 1 Error occurred in deployment step 'Add Solution': Failed to load receiver assembly "SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483" for feature "SiteDefinitionProject2_Feature1" (ID: b5841cc1-aacf-4b34-91d3-c73ef6637ce4).: System.IO.FileNotFoundException: Could not load file or assembly 'SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483' or one of its dependencies. The system cannot find the file specified.
File name: 'SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

=== Pre-bind state information ===
LOG: User = PI-RENTES\Administrator
LOG: DisplayName = SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/Extensions/Microsoft/SharePoint/
LOG: Initial PrivatePath = C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\SharePoint\VstspCache5620
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\SharePoint\vssphost4.exe.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Post-policy reference: SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

0 0 SiteDefinitionProject2


I tried to kill the process, close VS2010, open again and deploy but the error persist...Some advice!?

Thanls in advanced

André Rentes said...

Hi Steve,

This problem it's annoying and I tried your solution but didn't work..

my error is:

Error 1 Error occurred in deployment step 'Add Solution': Failed to load receiver assembly "SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483" for feature "SiteDefinitionProject2_Feature1" (ID: b5841cc1-aacf-4b34-91d3-c73ef6637ce4).: System.IO.FileNotFoundException: Could not load file or assembly 'SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483' or one of its dependencies. The system cannot find the file specified.
File name: 'SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

=== Pre-bind state information ===
LOG: User = PI-RENTES\Administrator
LOG: DisplayName = SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/Extensions/Microsoft/SharePoint/
LOG: Initial PrivatePath = C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\SharePoint\VstspCache5620
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\SharePoint\vssphost4.exe.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Post-policy reference: SiteDefinitionProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a693a58979940483
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

0 0 SiteDefinitionProject2


I tried to kill the process, close VS2010, open again and deploy but the error persist...Some advice!?

Thanls in advanced

Peter Weissbrod said...

that did the trick for me, thank you

Tsvetelin Pavlov said...

Worked! Thanks!

Kelly Gault said...

Saved my day! Thanks