none
Can't Activate Web Part ("Failed to instantiate file" error)

    Pertanyaan

  • I've got a web part that I'm trying to test in a single-server development VM environment.  It deploys fine, and shows up under my Site Collection Features, but when I try to activate it, I get this error:

    "Failed to instantiate file "InstallationMap.webpart" from module "InstallationMapWebPart": Source path "InstallationMap.webpart" not found.   at Microsoft.SharePoint.Library.SPRequestInternalClass.EnableModuleFromXml(String bstrFeatureDirectory, String bstrUrl, String bstrXML)
       at Microsoft.SharePoint.Library.SPRequest.EnableModuleFromXml(String bstrFeatureDirectory, String bstrUrl, String bstrXML)"

    My environment is:

    Windows Server 2003 x64 (fully patched), MOSS 2007 Standard (build 12.0.0.6608), and SQL Server 2005 (fully patched).

    I used WSPBuilder and I'm trying to do it as a bin deployment rather than GAC.  I checked and the web part file is located in the feature folder.  I'm not sure why it can't find it there.  After some googling, I've found other answers to similar problems, but none of those seem to apply in this case.

    Manifest.xml

    <?xml version="1.0"?>
    <!-- Solution created by WSPBuilder. 6/21/2012 2:39:21 PM  -->
    <Solution SolutionId="555b8473-f5b2-4d05-891c-ce09bcc4716e" xmlns="http://schemas.microsoft.com/sharepoint/">
      <Assemblies>
        <Assembly Location="InstallationMapWebPart.dll" DeploymentTarget="WebApplication">
          <SafeControls>
            <SafeControl Assembly="InstallationMapWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01ca2278eac9ed50" Namespace="InstallationMapWebPart.UI.WebControls.WebParts" TypeName="*" Safe="True" />
          </SafeControls>
        </Assembly>
      </Assemblies>
      <TemplateFiles>
        <TemplateFile Location="LAYOUTS\InstallationMapWebPart\Silverlight.js" />
        <TemplateFile Location="LAYOUTS\InstallationMapWebPart\SLInstallationMap.xap" />
        <TemplateFile Location="LAYOUTS\InstallationMapWebPart\SPSilverlight.js" />
      </TemplateFiles>
      <CodeAccessSecurity>
        <PolicyItem>
          <PermissionSet class="NamedPermissionSet" version="1" Description="WSPBuilder generated permissionSet" Name="InstallationMapWebPart689e157e-f9b7-46b0-824d-429fe2499ef9">
            <IPermission class="AspNetHostingPermission" version="1" Level="Medium" />
    <IPermission class="SecurityPermission" version="1" Flags="Assertion, Execution, ControlThread, ControlPrincipal, RemotingConfiguration" />
    <IPermission class="SharePointPermission" version="1" ObjectModel="True" />
    <IPermission class="EnvironmentPermission" version="1" Read="TEMP;TMP;USERNAME;OS;COMPUTERNAME" />
    <IPermission class="PrintingPermission" version="1" Level="DefaultPrinting" />
    <IPermission class="WebPartPermission" version="1" Connections="True" />
    <IPermission class="FileIOPermission" version="1" Read="$AppDir$" Write="$AppDir$" Append="$AppDir$" PathDiscovery="$AppDir$" />
    <IPermission class="WebPermission" version="1"><ConnectAccess><URI uri="$OriginHost$" /></ConnectAccess></IPermission>
    <IPermission class="IsolatedStorageFilePermission" version="1" Allowed="AssemblyIsolationByUser" UserQuota="9223372036854775807" />
    <IPermission class="DnsPermission" version="1" Unrestricted="true" />
    <IPermission class="SmtpPermission" version="1" Access="Connect" />
    <IPermission class="SqlClientPermission" version="1" Unrestricted="true" />
    </PermissionSet>
          <Assemblies>
            <Assembly Name="InstallationMapWebPart" Version="1.0.0.0" PublicKeyBlob="0024000004800000940000000602000000240000525341310004000001000100A5E1D878842DD9DEB6B7DB0560EFEFB43DF84F1102E84A176BFE5E92C6C66E19607770CAF4A0371444C57D233744B85A32C93685BDDC00F88211D6D882550FE9F286BEAE4B047D44453C4E8D8B1105AB798C960BC143E0A4C8178058D9346D7301F20BF41C9196BC36D06637DFD3C095CFABD5FABE43E90E2A533F75043CE9CE" />
          </Assemblies>
        </PolicyItem>
      </CodeAccessSecurity>
      <FeatureManifests>
        <FeatureManifest Location="InstallationMapWebPart\feature.xml" />
      </FeatureManifests>
    </Solution>

    Elements.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <Module Name="InstallationMapWebPart" Url="_catalogs/wp" RootWebOnly="TRUE">
        <File Url="InstallationMap.webpart" Type="GhostableInLibrary">
          <Property Name="Group" Value="MyGroup"></Property>
          <Property Name="QuickAddGroups" Value="MyGroup" />
        </File>
      </Module>
    </Elements>

    Feature.xml

    <?xml version="1.0" encoding="utf-8"?>
    <Feature  Id="0B7C5735-18D4-4D84-B1E4-234070A19CA2"
              Title="InstallationMapWebPart"
              Description="Map control used to display Installation locations."
              Version="1.0.0.0"
              Hidden="FALSE"
              Scope="Site"
              DefaultResourceFile="core"
              ReceiverAssembly="InstallationMapWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=580acf16e5a44281"
              ReceiverClass="InstallationMapWebPart.EventHandlers.Features.InstallationMapReceiver"
              xmlns="http://schemas.microsoft.com/sharepoint/">
      <ElementManifests>
        <ElementManifest Location="elements.xml"/>
        <ElementFile Location="InstallationMapWebPart.webpart" />
      </ElementManifests>
    </Feature>

    09 Juli 2012 4:45

Jawaban

  • Could you please check the assembly is well registered as a safe control in the site web.config file?

    What is the namespace of the event receiver class? Please check this namespace is the same than the one registered as safe control.


    Cordialement/Regards,

    Ludovic Caffin
    .NET/SharePoint Consultant for A3IS.

    11 Juli 2012 6:00

Semua Balasan

  • Hi,

    So this should work and it doesn't... all the files are well deployed on the destination folder.

    I noticed in your feature.xml :

    <ElementFile Location="InstallationMapWebPart.webpart" />

    But the real file name is :

    <File Url="InstallationMap.webpart" Type="GhostableInLibrary">

    But I am not sure this is the cause of the error.

    When I don't find why a such issue is happening , I usually prefer to just try a different way.

    I suggest you to add your ".webpart" file in a sub folder, to add a "path" attribute in your module file and test it.


    Cordialement/Regards,

    Ludovic Caffin
    .NET/SharePoint Consultant for A3IS.



    09 Juli 2012 8:47
  • Hi,

    First the files being deployed with this solution manifest are:

      <Assembly Location="InstallationMapWebPart.dll" DeploymentTarget="WebApplication">
      <TemplateFiles>
       
    <TemplateFile Location="LAYOUTS\InstallationMapWebPart\Silverlight.js" />
       
    <TemplateFile Location="LAYOUTS\InstallationMapWebPart\SLInstallationMap.xap" />
       
    <TemplateFile Location="LAYOUTS\InstallationMapWebPart\SPSilverlight.js" />
     
    </TemplateFiles>
      <FeatureManifest Location="InstallationMapWebPart\feature.xml" />

    What I dont see is the following in the solution manifest are the following files; How are they being deployed?

        <Resource Location="InstallationMapWebPart\elements.xml" />

        <Resource Location="InstallationMapWebPart\InstallationMapWebPart.webpart" />

    Next and as I placed them above since your Feature.xml has the element manifest elements.xml and the element file InstallationMapWebPart.webpart in the root of the feature both files should be in the root of the feature and not a subfolder, The largest difference besides location when working with assemblies deployed to the BIN is the PublicKeyBlob. The PublicBlobkey is used to determine the CAS entry...

    -Ivan


    Ivan Sanders My LinkedIn Profile, My Blog, @iasanders.


    09 Juli 2012 10:16
  • Hi KLilley,

    Please try by specifying the below attribute in the File tag of the Elements.xml

    Path="InstallationMap.webpart"

    OR add the attribute path="" in the Module tag of the Elements.xml.

    Path=""

    and in your Features.xml file, remove the below element or correct it to Location = "InstallationMap.webpart"

     <ElementFile Location="InstallationMapWebPart.webpart" />

    I have added it below for your reference.

    Elements.xml

    <?xml version="1.0" encoding="utf-8" ?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="InstallationMapWebPart" Url="_catalogs/wp" Path="" RootWebOnly="TRUE">

    OR <File Path="InstallationMap.webpart" Url="InstallationMap.webpart" Type="GhostableInLibrary">

    Thanks & Regards,

    Kalai.

    09 Juli 2012 18:17
  • Well, I did apparently have the incorrect file name in my Feature.xml.  I changed that, and now I get a different error when trying to activate, because it can't find the event receiver assembly:

    "Feature '0B7C5735-18D4-4D84-B1E4-234070A19CA2' could not be installed because the loading of event receiver assembly "InstallationMapWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=580acf16e5a44281" failed: System.IO.FileNotFoundException: Could not load file or assembly 'InstallationMapWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=580acf16e5a44281" or one of its dependencies.  The system cannot find the file specified."

    I did verify that the InstallationMapWebPart.dll file was properly installed in the bin folder for the site.  Am I missing something in the XML files that specifies where to look for the assembly?

    10 Juli 2012 20:02
  • Could you please check the assembly is well registered as a safe control in the site web.config file?

    What is the namespace of the event receiver class? Please check this namespace is the same than the one registered as safe control.


    Cordialement/Regards,

    Ludovic Caffin
    .NET/SharePoint Consultant for A3IS.

    11 Juli 2012 6:00
  • Could you please check the assembly is well registered as a safe control in the site web.config file?

    What is the namespace of the event receiver class? Please check this namespace is the same than the one registered as safe control.


    Cordialement/Regards,

    Ludovic Caffin
    .NET/SharePoint Consultant for A3IS.


    Good catch.  Just checked and the namespace for the event receiver class is different than the one for the webpart class.  Only the webpart namespace has a safecontrols entry though.  I'll fix and try again.
    11 Juli 2012 15:21
  • Hi,

    First the files being deployed with this solution manifest are:

      <Assembly Location="InstallationMapWebPart.dll" DeploymentTarget="WebApplication">
      <TemplateFiles>
       
    <TemplateFile Location="LAYOUTS\InstallationMapWebPart\Silverlight.js" />
       
    <TemplateFile Location="LAYOUTS\InstallationMapWebPart\SLInstallationMap.xap" />
       
    <TemplateFile Location="LAYOUTS\InstallationMapWebPart\SPSilverlight.js" />
     
    </TemplateFiles>
      <FeatureManifest Location="InstallationMapWebPart\feature.xml" />

    What I dont see is the following in the solution manifest are the following files; How are they being deployed?

        <Resource Location="InstallationMapWebPart\elements.xml" />

        <Resource Location="InstallationMapWebPart\InstallationMapWebPart.webpart" />

    Next and as I placed them above since your Feature.xml has the element manifest elements.xml and the element file InstallationMapWebPart.webpart in the root of the feature both files should be in the root of the feature and not a subfolder, The largest difference besides location when working with assemblies deployed to the BIN is the PublicKeyBlob. The PublicBlobkey is used to determine the CAS entry...

    -Ivan


    Ivan Sanders My LinkedIn Profile, My Blog, @iasanders.


    Ok, after having tried the other recommendations here, I'm still running into the error that I mention in my July 10 reply.

    I didn't realize that the two files you mention needed to be set up in the manifest.xml file. I believe that WSPBuilder creates that file, correct?

    Both files are in my solution under the \12\Template\Features\InstallationMapWebPart folder, so they do get put in the root of the InstallationMapWebPart folder under the Features folder when I deploy the solution.  I'm still not sure why it doesn't find it.

    Is there something else I need to add to the elements or feature files that WSPBuilder needs in order to create the manifest properly?  I thought the assembly location element covered that and it looks correct as far as I can tell.

    At this point, should I start a new thread?


    17 Juli 2012 16:16
  • According to your July 11th reply, have you tried registering the event receiver assembly as safe control?

    Can you share your updated Manifest, feature and element xmls?

    Thanks & Regards,

    Kalai.

    18 Juli 2012 5:05
  • Here's the updated files:

    Manifest.xml

    <?xml version="1.0"?>
    <!-- Solution created by WSPBuilder. 7/17/2012 11:10:15 AM  -->
    <Solution SolutionId="555b8473-f5b2-4d05-891c-ce09bcc4716e" xmlns="http://schemas.microsoft.com/sharepoint/">
      <Assemblies>
        <Assembly Location="InstallationMapWebPart.dll" DeploymentTarget="WebApplication">
          <SafeControls>
            <SafeControl Assembly="InstallationMapWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01ca2278eac9ed50" Namespace="InstallationMapWebPart" TypeName="*" Safe="True" />
          </SafeControls>
        </Assembly>
      </Assemblies>
      <TemplateFiles>
        <TemplateFile Location="LAYOUTS\InstallationMapWebPart\Silverlight.js" />
        <TemplateFile Location="LAYOUTS\InstallationMapWebPart\SLInstallationMap.xap" />
        <TemplateFile Location="LAYOUTS\InstallationMapWebPart\SPSilverlight.js" />
      </TemplateFiles>
      <CodeAccessSecurity>
        <PolicyItem>
          <PermissionSet class="NamedPermissionSet" version="1" Description="WSPBuilder generated permissionSet" Name="InstallationMapWebPart1cac4579-22e4-4483-ab8b-473de27d179e">
            <IPermission class="AspNetHostingPermission" version="1" Level="Medium" />
    <IPermission class="SecurityPermission" version="1" Flags="Assertion, Execution, ControlThread, ControlPrincipal, RemotingConfiguration" />
    <IPermission class="SharePointPermission" version="1" ObjectModel="True" />
    <IPermission class="EnvironmentPermission" version="1" Read="TEMP;TMP;USERNAME;OS;COMPUTERNAME" />
    <IPermission class="PrintingPermission" version="1" Level="DefaultPrinting" />
    <IPermission class="WebPartPermission" version="1" Connections="True" />
    <IPermission class="FileIOPermission" version="1" Read="$AppDir$" Write="$AppDir$" Append="$AppDir$" PathDiscovery="$AppDir$" />
    <IPermission class="WebPermission" version="1"><ConnectAccess><URI uri="$OriginHost$" /></ConnectAccess></IPermission>
    <IPermission class="IsolatedStorageFilePermission" version="1" Allowed="AssemblyIsolationByUser" UserQuota="9223372036854775807" />
    <IPermission class="DnsPermission" version="1" Unrestricted="true" />
    <IPermission class="SmtpPermission" version="1" Access="Connect" />
    <IPermission class="SqlClientPermission" version="1" Unrestricted="true" />
    </PermissionSet>
          <Assemblies>
            <Assembly Name="InstallationMapWebPart" Version="1.0.0.0" PublicKeyBlob="0024000004800000940000000602000000240000525341310004000001000100A5E1D878842DD9DEB6B7DB0560EFEFB43DF84F1102E84A176BFE5E92C6C66E19607770CAF4A0371444C57D233744B85A32C93685BDDC00F88211D6D882550FE9F286BEAE4B047D44453C4E8D8B1105AB798C960BC143E0A4C8178058D9346D7301F20BF41C9196BC36D06637DFD3C095CFABD5FABE43E90E2A533F75043CE9CE" />
          </Assemblies>
        </PolicyItem>
      </CodeAccessSecurity>
      <FeatureManifests>
        <FeatureManifest Location="InstallationMapWebPart\feature.xml" />
      </FeatureManifests>
    </Solution>

    Elements.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <Module Name="InstallationMapWebPart" Url="_catalogs/wp" Path="" RootWebOnly="TRUE">
        <File Url="InstallationMapWebPart.webpart" Type="GhostableInLibrary">
          <Property Name="Group" Value="MyGroup"></Property>
          <Property Name="QuickAddGroups" Value="MyGroup" />
        </File>
      </Module>
    </Elements>

    Feature.xml

    <?xml version="1.0" encoding="utf-8"?>
    <Feature  Id="0B7C5735-18D4-4D84-B1E4-234070A19CA2"
              Title="InstallationMapWebPart"
              Description="Map control used to display Installation locations."
              Version="1.0.0.0"
              Hidden="FALSE"
              Scope="Site"
              DefaultResourceFile="core"
              ReceiverAssembly="InstallationMapWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=580acf16e5a44281"
              ReceiverClass="InstallationMapWebPart.EventHandlers.Features.InstallationMapReceiver"
              xmlns="http://schemas.microsoft.com/sharepoint/">
      <ElementManifests>
        <ElementManifest Location="elements.xml"/>
        <ElementFile Location="InstallationMapWebPart.webpart" />
      </ElementManifests>
    </Feature>

    The assembly is registered as a safecontrol as well:

    <SafeControl Assembly="InstallationMapWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01ca2278eac9ed50" Namespace="InstallationMapWebPart" TypeName="*" Safe="True" />

    Any ideas about what else I can try?  It looks like all the files are in the correct place.  It just can't seem to find the receiver assembly for some reason.

    Thanks!


    • Diedit oleh KLilley 19 Juli 2012 16:30
    19 Juli 2012 16:28
  • Hi,

    PublicKeyToken specified in the "ReceiverAssembly" and the assembly registered as SafeControl is different. Can you check by modifying this?

    ReceiverAssembly="InstallationMapWebPart, ...., PublicKeyToken=580acf16e5a44281"
    <SafeControl Assembly="InstallationMapWebPart,.., PublicKeyToken=01ca2278eac9ed50" Namespace="InstallationMapWebPart" TypeName="*" Safe="True" />

    Thanks & Regards,

    Kalai.

    20 Juli 2012 2:10