Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to implement this web part concept provided by Microsoft in our SP2013 environment using VS2012.

MSDN SPDataQuery Class Example

I've created a solution in VS2012 and verified that the proper SafeControls are present in the Package Manifest. I even copied them into the web.config as well. The solution deploys and activates fine to the GAC. However whenever I insert it into a web part page, I keep getting the "A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe." error.

I have spent hours on Google, etc., and feel I've tried everything. I even rebuilt it to make sure I have not changed any names along the way.

Desperately need some help to get this working! Any suggestions are appreciated!

Thanks! Josh

share|improve this question
add comment

2 Answers

I realize that you said you hadn't changed the names of anything, but there is another place to check for possible incorrect references:

I ran into the "type is not registered as safe" problem too, and it had to do with me changing the namespace and name of the web part. I thought I had accounted for the changes everywhere, but then discovered that there is a hidden .spdata file for the web part (in the same directory) that also contains namespace and class references. It was referring to the old names.

Once I updated the .spdata file to use the correct namespace and class name, everything deployed and worked as intended. Note: Do not include the class name in the Namespace attribute... sounds obvious now, but I included the full [namespace].[class name] there, and couldn't figure out for the longest time why it still wasn't working.

Hope this helps someone.

share|improve this answer
add comment

Check your assembly version from GAC with the web.config entry and with control registered. If they are mismatched then you need update web.config with the latest version of your assembly. Or try using assembly binding redirect as

  <dependentAssembly>
        <assemblyIdentity name="AssemblyName"
                          publicKeyToken="32ab4ba45e0a69a1"
                          culture="neutral" />
        <bindingRedirect oldVersion="1.0.0.1"
                         newVersion="2.0.0.0"/>
     </dependentAssembly>
  </assemblyBinding>

Please let me know if that works or if you have same versions in all the places.

share|improve this answer
    
Thanks for the reply Shankar - my apologies if I'm missing anything as I'm new to web part development. I looked at the .dll properties in the GAC and the version and token matches that in the Web Config. –  Josh Apr 1 '13 at 13:47
    
I've also restarted IIS, retracted and re-deployed. –  Josh Apr 1 '13 at 14:45
    
Just to be more specific, here are the steps I've followed: 1 - created new farm solution in VS2012 2 - added web part (non visual) 3 - copied the MSDN code and revised the namespace to something more recognizable 4 - used VS2012's build and deploy feature 5 - added safecontrol to web.config to match the Package manifest with namespace as solution.webpartname and ensured that safe='true' is included. Like I said, I'm new to this, so I may have missed a step somewhere. THANKS AGAIN FOR YOUR HELP! –  Josh Apr 1 '13 at 14:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.