Solusyon sa Problema: “FileNotFoundException” Sa My Tampok Tatanggap.

I was working on a feature last week that would add some event receivers to a specific list instance. (I-blog nang kaunti tungkol sa receiver na listahan dito).

Gamit ang command line, Maaari ko bang i-install ang tampok na walang error (ngunit tingnan sa ibaba para sa mga nakatagong error). When I tried to deploy the feature on the site, MOSS complained of a "FileNotFoundException" mali. This blog entry describes how I solved it.

Ito ang error na Moss ay nagpakita sa akin sa web browser:

Feature ‘b2cb42e3-4f0a-4380-aaba-1ef9cd526f20’ could not be installed because the loading of event receiver assembly "xyzzyFeatureReceiver_0" Nabigo ang pag-: System.IO.FileNotFoundException: Could not load file or assembly ‘xyzzyFeatureReceiver_0’ o isa sa mga dependency. Ang sistema ay hindi maaaring mahanap ang tinukoy na file.
Ang pangalan ng file: ‘xyzzyFeatureReceiver_0’
at System.Reflection.Assembly.nLoad(AssemblyName filename, String codebase, Katibayan assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Katibayan assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Katibayan assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
WRN: Assembly nagbubuklod na pag-log ay naka-OFF.
Upang paganahin ang assembly magbigkis pagkabigo na pag-log, itakda ang mga registry value [HKLM Software Microsoft Fusion!EnableLog] (DWORD) upang 1.
Nota: Mayroong ilang mga pagganap ng multa na nauugnay sa assembly na pag-log magbigkis pagkabigo.
Upang i-on ang tampok na ito off, alisin ang mga registry value [HKLM Software Microsoft Fusion!EnableLog].

I-troubleshoot ang mga isyu sa Windows SharePoint Serbisyo.

Alam ko kung paano i-sadya maging sanhi ang error na iyon: don’t install the assembly in the GAC. Pero, 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% komportable paggawa na dahil ako palaging naisip gacutil na umiral para sa isang dahilan … so I tried that. It made no difference.

Hinanap ko ang Internets at nahanap ang post na ito: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2243677&SiteID=1

Ang poster na nangyari sa ma-gamit ang parehong bit root ng code (mula sa Inside WSS aklat mula sa listahang ito) so that was a hopeful sign. Gayunman, ang mungkahi ng dekorasyon ang assembly na may isang [pagtitipon: ] 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.

Susunod, I went to the trouble of enabling the "assembly bind failure log" (ng pagsunod sa mga kapaki-pakinabang at tumpak na mga tagubilin na ibinigay) 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. Pero … hindi ito maghanap ng mga ito sa 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" para sa tampok b2cb42e3-4f0a-4380-aaba-1ef9cd526f20: System.ArgumentNullException: Halaga ay hindi maaaring maging null.
Pangalan ng parameter: uri
at System.Activator.CreateInstance(Uri ng uri, Boolean nonPublic)
at System.Activator.CreateInstance(Uri ng uri)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

I-troubleshoot ang mga isyu sa Windows SharePoint Serbisyo.

Oras para sa isang huling biyahe sa Internets!

Oras na ito mahanap ko out, predictably sapat, that MOSS issues this error because the assembly is not in GAC.

Gusto kong makakuha ng isang bagay na positibo out sa ito at subukan sa pakiramdam ng kaunti mapagmataas na aking nilikha ang Takas ng MSIL pagtitipon, but it’s not working. I’m just plain annoyed. I find myself muttering "chicken or the egg" sa ilalim ng aking hininga.

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" ngunit hindi mahanap ang isa).

I-install ko ang mga tampok at i-activate ito at … ito gumagana! Kaya, pagkatapos ng lahat na, I had to basically ‘reboot’ my project. Ito ay isa pang dahilan kung bakit ako mapoot mga computer.

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. For some reason, I did not use the -force option when I installed the new project. Oras na ito, Ginawa ko talaga, truly forget to copy this new project’s assembly into the GAC. Bilang isang resulta, I received that "FielNotFoundException" mali. Oras na ito, Ang nakuha ko ito mula sa stsadm, not when I tried to activate the feature via the web browser. Kaya, -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.

</dulo>

Technorati Tags: ,

3 ano sa tingin mo "Solusyon sa Problema: “FileNotFoundException” Sa My Tampok Tatanggap.

  1. Francisco

    Din, I had my 2 hours of hysteric nintendoSIXTYFOURRRR-in-a-bad-way moments when I renamed the Namespace on the Feature Receiver, to help track where yours or anyone else’s began.

    Sumagot
  2. Francisco

    The root of the problem lies on the deployed wsp in the sharepoint database. I read your post and while it does indeed fix the problem we have a huge solution with several projects and dozens of files so moving everything was not an option.

    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"
    at
    "Failed to create feature receiver object from assembly"

    Salamat!
    Francisco

    Sumagot
  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.

    Sumagot

Mag-iwan ng Sumagot sa Francisco Ikansela reply

Ang iyong email address ay hindi nai-publish. Mga kinakailangang patlang ay minarkahan *