I was working on a feature last week that would add some event receivers to a specific list instance. (Ek blog 'n bietjie oor daardie lys ontvanger hier).
Met die opdrag, Ek kon die funksie met geen fout installeer (maar sien hieronder vir die verborge fout). When I tried to deploy the feature on the site, MOSS complained of a "FileNotFoundException" fout. This blog entry describes how I solved it.
Dit is die fout wat MOSS het vir my gewys in die webblaaier:
Feature ‘b2cb42e3-4f0a-4380-aaba-1ef9cd526f20’ could not be installed because the loading of event receiver assembly "xyzzyFeatureReceiver_0" misluk: System.IO.FileNotFoundException: Could not load file or assembly ‘xyzzyFeatureReceiver_0’ of een van sy afhanklikhede. Die stelsel kan nie vind die gekose lêer.
File name: ‘xyzzyFeatureReceiver_0’
at System.Reflection.Assembly.nLoad(AssemblyName lêernaam, String kodebasis, Getuienis assemblySecurity, Vergadering locationHint, StackCrawlMark& stackMark, Boole throwOnFileNotFound, Boole forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Getuienis assemblySecurity, StackCrawlMark& stackMark, Boole forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Getuienis assemblySecurity, StackCrawlMark& stackMark, Boole forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
WRN: Vergadering binding registrasie is afgeskakel.
Vergadering bind mislukking versuip in staat te stel om, stel die register waarde [HKLM Software Microsoft Fusion!EnableLog] (DWORD) aan 1.
Let daarop: Daar is 'n prestasie straf wat verband hou met die vergadering bind versuim om te meld.
Om hierdie funksie af te skakel, verwyder die register waarde [HKLM Software Microsoft Fusion!EnableLog].Oplos van probleme met kwessies met Windows SharePoint Services.
Ek weet hoe om doelbewus veroorsaak dat die fout: don’t install the assembly in the GAC. Maar, 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% gemaklik om dit te doen, want ek het nog altyd gedink dat gacutil bestaan vir 'n rede … so I tried that. It made no difference.
Ek het die Inter en het gevind dat hierdie post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2243677&SiteID=1
Die plakkaat gebeur te word met behulp van dieselfde wortel bietjie van die kode (van die binnekant van WSS boek van hierdie lys) so that was a hopeful sign. Egter, die voorstel van die versiering van die vergadering met 'n [vergadering: ] 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.
Volgende, I went to the trouble of enabling the "assembly bind failure log" (na aanleiding van die hulpvaardig en akkurate instruksies) 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. Maar … dit sal nie soek vir dit in die 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" funksie b2cb42e3-4f0a-4380-aaba-1ef9cd526f20: System.ArgumentNullException: Waarde kan nie nul wees.
Parameter naam: tipe
at System.Activator.CreateInstance(Tik, Boole nonPublic)
at System.Activator.CreateInstance(Tik)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()Oplos van probleme met kwessies met Windows SharePoint Services.
Tyd vir 'n laaste reis na die Inter!
Hierdie keer het ek uitvind, voorspelbaar genoeg, that MOSS issues this error because the assembly is not in GAC.
Ek wil iets positiefs uit te kry en probeer om te voel 'n bietjie trots op die feit dat ek geskep het Die Fugitive van MSIL gemeentes, but it’s not working. I’m just plain annoyed. I find myself muttering "chicken or the egg" onder my asem.
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" maar kan nie vind een).
Ek installering van die funksie en dit aktiveer en … dit werk! So, na al, I had to basically ‘reboot’ my project. Dit is 'n ander rede waarom ek haat rekenaars.
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. Vir een of ander rede, I did not use the -force option when I installed the new project. Hierdie keer, Ek het eintlik, truly forget to copy this new project’s assembly into the GAC. As 'n gevolg, I received that "FielNotFoundException" fout. Hierdie keer, Ek het dit van stsadm, not when I tried to activate the feature via the web browser. So, -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.
</einde>