Réiteach ar Fadhb: “FileNotFoundException” Le Mo Gné Glacadóir.

I was working on a feature last week that would add some event receivers to a specific list instance. (Blogged mé beagán faoi go glacadóir liosta anseo).

Ag baint úsáide as an líne ordaithe, Raibh mé in ann a shuiteáil an gné gan aon earráid (ach féach thíos le haghaidh an earráid i bhfolach). When I tried to deploy the feature on the site, MOSS complained of a "FileNotFoundException" earráid. This blog entry describes how I solved it.

This is the error that MOSS showed me in the web browser:

Feature ‘b2cb42e3-4f0a-4380-aaba-1ef9cd526f20’ could not be installed because the loading of event receiver assembly "xyzzyFeatureReceiver_0" failed: System.IO.FileNotFoundException: Could not load file or assembly ‘xyzzyFeatureReceiver_0’ nó ceann dá spleáchais. The system cannot find the file specified.
File name: ‘xyzzyFeatureReceiver_0’
at System.Reflection.Assembly.nLoad(AssemblyName ainm comhaid, Codebase Teaghrán, AssemblySecurity Fianaise, Tionól locationHint, StackCrawlMark& ithir Stack, Boole throwOnFileNotFound, ForIntrospection Boole)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, AssemblySecurity Fianaise, StackCrawlMark& ithir Stack, ForIntrospection Boole)
at System.Reflection.Assembly.InternalLoad(String assemblyString, AssemblySecurity Fianaise, StackCrawlMark& ithir Stack, ForIntrospection Boole)
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) go 1.
Tabhair faoi deara: 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].

Troubleshoot issues with Windows SharePoint Services.

I know how to deliberately cause that error: don’t install the assembly in the GAC. Ach, it was in the GAC. I normally install assemblies into the GAC by dragging them into the c:\windows\assembly folder using windows explorer. I’ve never felt 100% comfortable doing that because I always thought that gacutil existed for a reason … so I tried that. It made no difference.

I searched the Internets and found this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2243677&SiteID=1

The poster happened to be using the same root bit of code (from the Inside WSS book from this list) so that was a hopeful sign. Mar sin féin, the suggestion of decorating the assembly with an [assembly: ] directive didn’t make sense to me. I tried it anyway and I was right. It made no difference.

Then I noticed that my class definition was not public. I made it public and that made no difference.

Ar Aghaidh, I went to the trouble of enabling the "assembly bind failure log" (following the helpful and accurate instructions provided) and this is where things started to get interesting. That log shows me that the runtime is searching everywhere on that server for my assembly. It even appears to be searching for it in my medicine cabinet. Ach … it won’t search for it in the GAC.

I put on my winter jacket and go searching the Internets again and find that someone has had this problem too. The lengthy discussion in that posting peters off into nothing and I can’t find a solution.

I move my assembly into one of the places the log claims it’s searching and I make a little more progress. I’m rewarded with a new error in the browser when I try to activate the feature:

Failed to create feature receiver object from assembly "xyzzyFeatureReceiver_0", type "Conchango.xyzzyFeatureReceiver" for feature b2cb42e3-4f0a-4380-aaba-1ef9cd526f20: System.ArgumentNullException: Ní féidir luach a bheith ar neamhní.
Ainm Paraiméadar: cineál
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

Troubleshoot issues with Windows SharePoint Services.

Time for one last trip to the Internets!

This time I find out, predictably enough, that MOSS issues this error because the assembly is not in GAC.

Ba mhaith liom a fháil ar rud éigin as dhearfach seo agus iarracht a bhraitheann ar beag bródúil go chruthaigh mé an Teifeacha de tionóil MSIL, but it’s not working. I’m just plain annoyed. I find myself muttering "chicken or the egg" faoi ​​mo anáil.

I finally decide to punt. I create an entirely new project and copy/paste the code from the incredible-cloaked-from-the-GAC-assembly non-working project over to this new project. (I look for a build flag called something like "hide from assembly binding if installed in the GAC" ach ní féidir teacht ar aon).

Shuiteáil mé an gné agus a ghníomhachtú é agus … oibríonn sé! Mar sin,, tar éis an tsaoil go, I had to basically ‘reboot’ my project. This is another reason why I hate computers.

I did learn something useful from this. I had been installing features using the stsadm command line all day long and been using the "-force" option out of habit. Ar chúis éigin, I did not use the -force option when I installed the new project. An uair seo, Rinne mé i ndáiríre, truly forget to copy this new project’s assembly into the GAC. Mar thoradh air sin, I received that "FielNotFoundException" earráid. An uair seo, Fuair ​​mé é ó stsadm, not when I tried to activate the feature via the web browser. Mar sin,, -force actually plays two roles. It allows you to re-install an existing feature. It also allows you to install a buggy feature that cannot work at runtime by suppressing the error. It probably says as much in the help somewhere but I never noticed it.

</deireadh>

Clibeanna Technorati: ,

3 smaointe ar "Réiteach ar Fadhb: “FileNotFoundException” Le Mo Gné Glacadóir.

  1. Francisco

    Chomh maith leis sin, Bhí mé mo 2 uair an chloig de chuimhneacháin nintendoSIXTYFOURRRR-i-a-droch-bhealach hysteric nuair Athainmníodh mé an Namespace ar an Glacadóir Gné, chun cabhrú le súil nuair atá Thosaigh mise nó duine ar bith eile.

    Freagra
  2. Francisco

    Tá an fhréamh na faidhbe ar an WSP imscaradh sa bhunachar sonraí SharePoint. Léigh mé do phost agus cé nach é a shocrú go deimhin, ar an bhfadhb mór dúinn a réiteach ollmhór le roinnt tionscadail agus an iliomad comhaid nach raibh sin gach rud ag gluaiseacht rogha.

    No matter how much you update your GAC or your assembly, what is giving you trouble is the assembly in the current WSP installed on sharepoint.

    You can easily noticed that by trying to only retract the solution (which is where the error happens). Everything happening on "Retracting Time" should be considered "deployed wsp"-only not the project itself.

    My workaround was:

    – Central admin: Cancel solution
    – stsadm: deletesolution
    – Visual Studio => Project => Package
    – stsadm: addsolution -file Project\bin\Debug\Project.wsp
    – stsadm: deploysolution -name project.wsp -immediate -allowgacdeployment -force
    – Visual Studio => Deploy

    I also deleted the bin and debug folders from the project before running Deploy again, might not have any effect but worth commenting.

    This works for both

    "Feature … could not be installed because the loading of event receiver assembly"
    agus
    "Failed to create feature receiver object from assembly"

    Go raibh maith agat!
    Francisco

    Freagra
  3. Tom Clarkson

    Just spent a couple of hours trying to fix this same issue and found a better solution than simply recreating the project.

    It turned out that for some reason Visual Studio had set the build target to x86 instead of x64 or MSIL – the assembly was in the GAC, just not the same GAC that 64 bit SharePoint was looking in.

    Freagra

Leave a Reply

Ní thabharfar do sheoladh r-phoist a fhoilsiú. Réimsí riachtanacha atá marcáilte *