Solución para o problema: “FileNotFoundException” Co meu recurso Receiver.

I was working on a feature last week that would add some event receivers to a specific list instance. (Eu escribín un pouco sobre esta lista receptor aquí).

Usar a liña de comandos, Podería instalar o recurso sen erro (pero mira abaixo o erro oculto). When I tried to deploy the feature on the site, MOSS complained of a "FileNotFoundException" error. This blog entry describes how I solved it.

Este é o erro que Moss me mostrou o navegador web:

Feature ‘b2cb42e3-4f0a-4380-aaba-1ef9cd526f20’ could not be installed because the loading of event receiver assembly "xyzzyFeatureReceiver_0" fracasado: System.IO.FileNotFoundException: Could not load file or assembly ‘xyzzyFeatureReceiver_0’ ou unha das súas dependencias. O sistema non pode atopar o ficheiro especificado.
O nome do ficheiro: ‘xyzzyFeatureReceiver_0’
at System.Reflection.Assembly.nLoad(AssemblyName filename, Codebase cadea, AssemblySecurity evidencia, Asemblea locationHint, StackCrawlMark& apilar solo, Booleana throwOnFileNotFound, ForIntrospection Boolean)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, AssemblySecurity evidencia, StackCrawlMark& apilar solo, ForIntrospection Boolean)
at System.Reflection.Assembly.InternalLoad(Cordas assemblyString, AssemblySecurity evidencia, StackCrawlMark& apilar solo, ForIntrospection Boolean)
at System.Reflection.Assembly.Load(Cordas assemblyString)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
WRN: Rexistro de conexións de assembly está desactivado.
Para activar o rexistro de erros de assembly, definir o valor de rexistro [HKLM Software Microsoft Fusion!EnableLog] (DWORD) para 1.
Nota: Hai algunha perda de rendemento asociada ao rexistro de fallo de conexión de assembly.
Para desactivar este recurso, elimine o valor do Rexistro [HKLM Software Microsoft Fusion!EnableLog].

Solucionar problemas con Windows SharePoint Services.

Sei como facer que deliberadamente este erro: 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% cómodo facendo iso, porque eu sempre pensei que Gacutil existiu por unha razón … so I tried that. It made no difference.

Eu procurei as Internets e atopei este post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2243677&SiteID=1

O cartel pasou a ser co mesmo bit raíz do código (do libro WSS Dentro desta lista) so that was a hopeful sign. Con todo, a suxestión de decorar a montaxe cunha [montaxe: ] 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.

Seguinte, I went to the trouble of enabling the "assembly bind failure log" (seguindo as instrucións útiles e precisas proporcionadas) 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 … non vai buscalo no 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" ao recurso de b2cb42e3-4f0a-4380-aaba-1ef9cd526f20: System.ArgumentNullException: O valor non pode ser nulo.
O nome do parámetro: tipo
at System.Activator.CreateInstance(Tipo Tipo, Booleana nonPublic)
at System.Activator.CreateInstance(Tipo Tipo)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

Solucionar problemas con Windows SharePoint Services.

Tempo para unha última viaxe para as Internets!

Esta vez descubro, previsiblemente, that MOSS issues this error because the assembly is not in GAC.

Quero aproveitar algo positivo deste e tentar sentir algo orgulloso de que eu creei o Fugitivo de conxuntos MSIL, but it’s not working. I’m just plain annoyed. I find myself muttering "chicken or the egg" baixo a miña respiración.

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" pero non pode atopar un).

Eu instalar recurso e activa-lo e … funciona! Así, despois de todo isto, I had to basically ‘reboot’ my project. Esta é outra razón pola que eu odio ordenadores.

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. Por algunha razón, I did not use the -force option when I installed the new project. Este tempo, Eu fixen realmente, truly forget to copy this new project’s assembly into the GAC. Como resultado, I received that "FielNotFoundException" error. Este tempo, I got it from stsadm, not when I tried to activate the feature via the web browser. Así, -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.

</final>

3 pensamentos sobre "Solución para o problema: “FileNotFoundException” Co meu recurso Receiver.

  1. Francisco

    Tamén, Tiven a miña 2 horas de histérica nintendoSIXTYFOURRRR-in-a-bad-way momentos en que me renombrados o espazo de nomes no receptor de recursos, para axudar a pista onde o seu ou de calquera outra persoa comezou.

    Responder
  2. Francisco

    A raíz do problema está no WSP implantado na base de datos do SharePoint. Lin o seu post e, mentres el, de feito, resolver o problema temos unha solución enorme con varios proxectos e decenas de arquivos a mover todo non era unha opción.

    Non importa o que vostede actualizar o GAC ou a súa montaxe, o que está dando problema é a montaxe no WSP actual instalado no SharePoint.

    Pode facilmente notado que, ao intentar extraer soamente a solución (que é onde o erro). Everything happening on "Retracting Time" should be considered "deployed wsp"-only not the project itself.

    A miña solución foi:

    – Centro de administración: Cancelar solución
    – stsadm: deletesolution
    – Visual Studio => Proxecto => Paquete
    – stsadm: addsolution-file Project bin Debug Project.wsp
    – stsadm: deploysolution-name-allowgacdeployment forza project.wsp-inmediato
    – Visual Studio => Implantar

    Eu tamén borrar os cartafoles bin e depuración do proxecto antes de realizar deploy novo, pode non ter ningún efecto, pero paga a pena comentar.

    Isto funciona tanto para

    "Feature … Non se pode instalar porque a carga do módulo receptor evento"
    e
    "Failed to create feature receiver object from assembly"

    Grazas!
    Francisco

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

    Responder

Deixe unha resposta

Enderezo de correo electrónico non será publicado. Os campos obrigatorios están marcados *