1

When I'm deploying a Sharepoint Project from Visual Studio to my Sharepoint site, I met this error:

Error 3 Error occurred in deployment step 'Activate Features': Failed to load receiver assembly "ABCDEF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9a5a0fd37c05f19f" for feature "IEx.AboutIE" (ID: d24ee7c1-d532-47e4-bd41-76754cf61e11).: System.IO.FileNotFoundException: Could not load file or assembly 'ABCDEF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9a5a0fd37c05f19f' or one of its dependencies. The system cannot find the file specified. File name: 'ABCDEF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9a5a0fd37c05f19f' at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject() WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

I found out a solution to solve this problem. I added a new key.snk, replaced the old one in my project, and everything worked very well. But, after a while, I met this error again. All I can do was add a new key.snk again, and again, and again ... This solution was just a temporary solution.

What is the cause of this problem? How can I solve it permanently?

1 Answer 1

0

The cause of the problem is the way Visual Studio enourages you to deploy your package: with its built-in "F5"/"all-in-one" process.

When you install/deploy a package from VS, VS does trigger all actions: WSP installation and deployment, and then feature activation.
This means the feature is activated from inside the process "devenv.exe" (i.e. Visual Studio). Thus, your Feature Event Receiver (i.e. your DLL) is loaded inside Visual Studio process! But once a DLL (.NET assembly) is loaded in a process from the GAC (global repository for .NET DLLs) it's never reloaded.
So, you're always running the old version. That's always a problem since you want to debug the latest version of the ER code! And that may also fail with an error message such as yours when a class name is changed, or else.

So, to me, the solution is simple: never use Visual Studio "F5" to deploy your solution. Always package the WSP (aka "Publish" from VS2012), and then deploy (or Update-SPSolution) the WSP manually from PowerShell. Then deactivate/activate your feature from the UI (not from PowerShell itself since you'lle have the same problem in PowerShell as long as you don't restart the console).
This will work because after a solution retract/installation (or Update-SPSolution), app pool recycles, so when you reactivate the feature from the Web UI, the new version of the DLL is loaded by IIS.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.