I was working on a feature last week that would add some event receivers to a specific list instance. (Я пісаў трохі аб гэтым спісе прымачом тут).
Выкарыстанне каманднага радка, Я магу ўсталяваць кампанент без памылкі (але гл ніжэй для схаванай памылцы). When I tried to deploy the feature on the site, MOSS complained of a "FileNotFoundException" памылка. This blog entry describes how I solved it.
Гэта памылка, якая паказала мне MOSS ў вэб-браўзэры:
Feature ‘b2cb42e3-4f0a-4380-aaba-1ef9cd526f20’ could not be installed because the loading of event receiver assembly "xyzzyFeatureReceiver_0" не ўдалося: System.IO.FileNotFoundException: Could not load file or assembly ‘xyzzyFeatureReceiver_0’ або адзін з залежных ад. The system cannot find the file specified. File name: ‘xyzzyFeatureReceiver_0’ at System.Reflection.Assembly.nLoad(AssemblyName імя_файла, Струнны CODEBASE, Доказы assemblySecurity, Асамблея locationHint, StackCrawlMark& стэк глебы, Булевы throwOnFileNotFound, Булевы forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Доказы assemblySecurity, StackCrawlMark& стэк глебы, Булевы forIntrospection) at System.Reflection.Assembly.InternalLoad(String assemblyString, Доказы assemblySecurity, StackCrawlMark& стэк глебы, Булевы 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) да 1. Увага: 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. Але, 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. Аднак, 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.
Наступны, I went to the trouble of enabling the "assembly bind failure log" (пасля карыснымі і дакладнымі інструкцыямі) 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. Але … ён не будзе шукаць яго ў 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" для мастацкіх b2cb42e3-4f0a-4380-ааба-1ef9cd526f20: System.ArgumentNullException: Значэнне не можа быць пустым. Найменне параметра: тып at System.Activator.CreateInstance(Тып Тып, Булевы непублічнай) at System.Activator.CreateInstance(Тып Тып) at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
Troubleshoot issues with Windows SharePoint Services.
|
Час для адной апошняй паездкі ў інтэрнэце!
На гэты раз я даведаюся,, дастаткова прадказальна, that MOSS issues this error because the assembly is not in GAC.
Я хачу атрымаць нешта станоўчае з гэтага і спрабуюць адчуваць сябе крыху ганаруся тым, што я стварыў Уцякач з MSIL зборкі, but it’s not working. I’m just plain annoyed. I find myself muttering "chicken or the egg" пад нос.
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" але не магу знайсці адну).
Я ўсталяваць функцыю і актываваць яго і … гэта працуе! Так, пасля ўсяго, што, I had to basically ‘reboot’ my project. Гэта яшчэ адна прычына, чаму я ненавіджу кампутары.
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. Па некаторых прычынах, I did not use the -force option when I installed the new project. На гэты раз, Я зрабіў на самай справе, truly forget to copy this new project’s assembly into the GAC. У выніку, I received that "FielNotFoundException" памылка. На гэты раз, Я атрымаў яго ад Stsadm, not when I tried to activate the feature via the web browser. Так, -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.
</канец>