Building and Deploying SharePoint 2010 Web Parts

I am building a web part and am not sure where to deploy it.  Initially I need it to available for pages within a site collection subsite. The site collection is also a sub site of a site collection.  So forgetting that I may want to use it in another sub site,  where do I deploy it and where can I deploy it?

Also,  the web part needs to use a class library for accessing some custom reusable functionality and I am not sure of all the required wiring.  I have strongly typed the DLL and have exercises it from a console application so I know it does perform the required functions as required.  Do I need to add a reference in Web Config for both the web part and this library for safe controls? etc.
LVL 1
Howard BashSenior Software EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
if this is a on-premise farm and you can install SharePoint solutions, your scenario looks like what is called a SharePoint farm solution.
A solution package is a CAB file with the extension .wsp and can contain different features (from event receiver, custom actions, site/web/list templates as well as web parts).
What version of Visual Studio are you using?

A quick first guide into SharePoint development can be found here:
https://msdn.microsoft.com/en-us/library/office/ff597540(v=office.14).aspx
Another sample is here:
http://www.informit.com/articles/article.aspx?p=1626325

HTH
Rainer
Howard BashSenior Software EngineerAuthor Commented:
Hi.

I am using VS2013 Pro with Update 4.
Howard BashSenior Software EngineerAuthor Commented:
I tried building a sample and it seemed to deploy but I don't see the web part when I try to add it to a page.  This is the Output window during the deploy command:

------ Build started: Project: MyWebParts, Configuration: Debug Any CPU ------
  MyWebParts -> C:\mycode\MyWebParts\MyWebParts\bin\Debug\MyWebParts.dll
  Successfully created package at: C:\mycode\MyWebParts\MyWebParts\bin\Debug\MyWebParts.wsp
------ Deploy started: Project: MyWebParts, Configuration: Debug Any CPU ------
Active Deployment Configuration: Default
  Skipping deployment step because a pre-deployment command is not specified.
  Skipping application pool recycle because no matching package on the server was found.
  Skipping package retraction because no matching package on the server was found.
  Add Solution:
  Could not load file or assembly 'file:///C:\USERS\MyName\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\12.0\EXTENSIONS\3D1CWR3B.KNL\CKS.Dev12.Cmd.Imp.v4.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
  Adding solution 'MyWebParts.wsp'...
  Deploying solution 'MyWebParts.wsp'...
  Activate Features:
  Activating feature 'Feature1' ...
  Skipping deployment step because a post-deployment command is not specified.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Howard BashSenior Software EngineerAuthor Commented:
I tried the one of the sample projects from https://msdn.microsoft.com/en-us/library/office/ff728094(v=office.14).aspx.  The solution builds and deploys but the web part is missing in action.  Not clear at all why this is occurring.

Any thoughts on this would be greatly appreciated.
Rainer JeschorCommented:
Hi,
from your build log the build fails because the generated DLL seems to be build targeting .NET Framework version 4.5 or 4, but SharePoint 2010 solutions need .NET 3.5.
see https://msdn.microsoft.com/en-us/library/ee231582.aspx
Could you change the target framework version to 3.5?

The sample solution is another kind of solution called "Sandbox solution". For this to work a complete different part of SharePoint is responsible hence the question is if this part of the infrastructure is completely setup and configured?

HTH
Rainer

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Howard BashSenior Software EngineerAuthor Commented:
I'll try that in the morning.  I have to login and then access a VM to make that change.  Also,  the web part needs to use another DLL that I built for build some list objects for displaying.  I have built that and signed it testing it in a console application where it indeed works.  I am guessing that I need to also make sure that that "support" library is written in .Net 3.5 too?  Also,  do I need to add the safecontrol entries or does VS2013 do that for me (for the web part and the "support" library)?

Thanks.
Rainer JeschorCommented:
Hi,
as soon as the support DLL is part of the SharePoint solution and the DLL is signed, the savecontrol entries should be generated automatically.
And yes, SharePoint can only target 3.5 internally:
http://blogs.msdn.com/b/sharepointdev/archive/2011/07/14/net-framework-support-in-sharepoint-2010.aspx

If you need 4.0, then you will have to generate a custom web service (which runs in another app domain) which can then be a different framework version,

HTH
Rainer
Howard BashSenior Software EngineerAuthor Commented:
Since my solution involves two DLLS (the web part and the "support" library),  does this solution know to make two safecontrol entries?
Rainer JeschorCommented:
Yes :-)
Howard BashSenior Software EngineerAuthor Commented:
Hi,

Both DLLS show on their respective project properties that they are as follows:
The Web Part Project
Application Tab: .Net Framework 3.5, Output Type Class Library, Startup Object Not Set

The "Support Class Library"
Application Tab: .Net Framework 3.5, Output Type Class Library, Startup Object Not Set

Please advise...
Thanks,
Howard
Howard BashSenior Software EngineerAuthor Commented:
It has been suggested that the issue is caused by my needing DBA rights on the SQL database where the content is stored.  I am currently twisting my shorts attempting to get my rights elevated.  I'll let you know if indeed that is the cause of my deployment issue.

Thanks.
Howard BashSenior Software EngineerAuthor Commented:
In a ULS file I am seeing this error which seems like a clue:
Missing one or more of the following attributes from the root node in solution  mywebpar.wsp: assembly",type".
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.