Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Building Web Parts With VS 2003

  Asked By: Miguel    Date: Apr 28    Category: Sharepoint    Views: 1224

I tried to follow Scott Hillier's Microsoft SharePoint: Building Office 2003
Solutions to create a web part in VS.Net 2003 and it tells me it can't find
the SharePoint Assemblies. I have copied the .dlls to my pc. How do I get
Visual Studio to see them?

Share: 

 

12 Answers Found

 
Answer #1    Answered By: Jorge Cole     Answered On: Apr 28

Right click on References in the Solution Explorer and choose Add
Reference...

If Microsoft Windows SharePoint Services is installed locally, scroll to
the bottom of the .NET tab, select it, and click OK.

If not (which I suspect), browse to the location of the DLL using the
Browse button and then click OK.

In both cases, Microsoft.SharePoint should be added to the project
references.

 
Answer #2    Answered By: Rodolfo Tate     Answered On: Apr 28

Checkout the "Developer's Introduction to web  Parts", an excellent deep introduction @ msdn.microsoft.com/.../...t_northwindwebparts.asp.

 
Answer #3    Answered By: Jesus Foster     Answered On: Apr 28

Now when I build the solution I get three errors:

The dependency 'Microsoft.SharePoint.Dsp' could not be found.
The dependency 'Microsoft.SharePoint.Library' could not be found.
The dependency 'Microsoft.SharePoint.Security' could not be found.

 
Answer #4    Answered By: Alfredo May     Answered On: Apr 28

According to the SDK:
The Microsoft.SharePoint.Dsp Namespace "provides the base class for the
data retrieval service adapters used in Microsoft Windows SharePoint
Services." This Namespace is included in the
Microsoft.SharePoint.Dsp.dll

The Microsoft.SharePoint.Library Namespace include types and members
that "support Microsoft Windows SharePoint Services and are not intended
to be used directly from your code." This Namespace is included in the
Microsoft.SharePoint.Library.dll

The Microsoft.SharePoint.Security Namespace "provides a set of code
access permission and attribute classes designed to protect a specific
set of resources and operations, such as access to the Windows
SharePoint Services object model, the ability to do unsafe saving on
HTTP Gets, and enabling point-to-point Web Part connections. This
Namespace is included in the Microsoft.SharePoint.Security.dll


I'm not sure what you are trying to do in your code (these are
relatively unusual dependencies), but I suspect that the compiler is
looking for the following statements at the top of your Web Part code:

C#
Using Microsoft.SharePoint.Dsp
Using Microsoft.SharePoint.Library
Using Microsoft.SharePoint.Security

VB.NET
Using Microsoft.SharePoint.Dsp
Using Microsoft.SharePoint.Library
Using Microsoft.SharePoint.Security

You may very well need to reference the DLLs too.

 
Answer #5    Answered By: Preston Moreno     Answered On: Apr 28

Of course the C# entries should be followed by semicolons...

C#
Using Microsoft.SharePoint.Dsp;
Using Microsoft.SharePoint.Library;
Using Microsoft.SharePoint.Security;

 
Answer #6    Answered By: Rickey Strickland     Answered On: Apr 28

I added the 'using...' and got:

C:\Program Files\Microsoft
SDK\Samples\security\PasswordFilters\PassFilt\WebPartLibrary4\PageView2.cs(11):
The type or namespace name 'Security' does not exist in the class or
namespace 'Microsoft.SharePoint' (are you missing an assembly reference?)
The dependency 'Microsoft.SharePoint.Dsp' could not be found.
The dependency 'Microsoft.SharePoint.Library' could not be found.
The dependency 'Microsoft.SharePoint.Security' could not be found.

the webpart I'm am trying to create is a pageviewer taken from the book:

----------- code begins below this line ------------
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Dsp;
using Microsoft.SharePoint.Library;
using Microsoft.SharePoint.Security;
namespace SpsPageView2
{
[DefaultProperty("URL"),
ToolboxData("<{0}:Container runat=server></{0}:Containder>"),
XmlRoot(Namespace="SpsPageView2")]
public class Container : Microsoft.SharePoint.WebPartPages.WebPart
{
private string url="";
private int pageHeght = 400;
[Browsable(true),Category("Miscellaneous"),DefaultValue(""),
WebPartStorage(Storage.Personal),
FriendlyName("URL"),
Description("The address of the page to display.")]
public string URL
{
get
{
return url;
}
set
{
url = value;
}
}
[Browsable(true),Category("Miscellaneous"),
DefaultValue(400),
WebPartStorage(Storage.Personal),
FriendlyName("Page Height"),Description("The height of the page in
pixels.")]
public int PageHeight
{
get
{
return PageHeight;
}
set
{
PageHeight = value;
}
}

protected override void RenderWebPart(HtmlTextWriter output)
{
output.Write("<div><iframe height='" + PageHeight +"' width='100%' src='"
+URL + "'></iframe></div>");
}
}
}

 
Answer #7    Answered By: Jonathan Thompson     Answered On: Apr 28

There isn't anything in this Web Part that would require these
Namespaces. The code you sent simply has two public properties and a
simple override of the RenderWebPart method.

I'll create a replacement part real quick and post it here later today.

 
Answer #8    Answered By: Taylor Mills     Answered On: Apr 28

I've attached an unsigned VS.NET Web Part project (MyPageViewer.csproj +
files) and CAB project (MyPageViewerCab.vdproj + files) that I used to
create and deploy a version of the PageViewerPart Web Part that displays
the Google home page (by default) in a scrollable Iframe. It also allows
the user to set the Web Part to any URL and height using a custom Web
Part properties.

I tried to stay as close to the observable code design that you
originally sent including the use of a PageHeight. However, I would
probably use the built-in Web Part Tool Part to dictate how high the
IFrame would render rather than creating a new custom Web Part property.

I've also converted the code to genuine "server control logic" (rather
than the "string output logic" that the original code used), moved the
control instantiation, initialization, and insertion of the controls
into CreateChildControls (where it should be done), and added my
standard RenderWebPart method. My RenderWebPart method outputs each
control added to the collection in CreateChildControls as it iterates
thru class control collection and handles all error scenarios. If a Web
Part results in an error, the entire Web Part page can bomb.

 
Answer #9    Answered By: Angel Jordan     Answered On: Apr 28

I was just trying to follow the book step by step. I need to learn
how to create a webpart so I can do some custom processing that the folks in
change want.

 
Answer #10    Answered By: Darrell Peters     Answered On: Apr 28

I built you solution and it still gave me:
------ Build started: Project: MyPageViewer, Configuration: Debug
.NET ------
Preparing resources...
Updating references...
The dependency 'Microsoft.SharePoint.Security' could not be found.
The dependency 'Microsoft.SharePoint.Dsp' could not be found.
The dependency 'Microsoft.SharePoint.Library' could not be found.
Performing main compilation...

Build complete -- 0 errors, 0 warnings

Building satellite assemblies...

------ Starting pre-build validation for project 'MyPageViewerCab' ------

------ Pre-build validation for project 'MyPageViewerCab' completed ------

------ Build started: Project: MyPageViewerCab, Configuration: Debug ------

Building file '..\..\..\..\..\cab\MyPageViewer.cab'...
Packaging file 'C:\SharePointDev\MyPageViewer\obj\Debug\MyPageViewer.dll'...
Packaging file 'C:\SharePointDev\MyPageViewer\PageViewerPart.dwp'...
Packaging file 'C:\SharePointDev\MyPageViewer\Manifest.xml'...
---------------------- Done ----------------------

Build: 2 succeeded, 0 failed, 0 skipped

???

I installed the .cab on the portal server and tried the webpart. It worked
except I don't know why the iframe that contains the google page does not
fill the webpart. It is only take up about 20% of the top area where I
placed it. It has vertical and horizonal scroll bars.

 
Answer #11    Answered By: Lester Casey     Answered On: Apr 28

I'm not sure why you are getting the dependency messages in your
compilation output. The important message is, of course, is "Build: 2
succeeded".

Glad the Web Part is working. Not sure why you are getting space issues.
As you might imagine, I didn't spend much time trouble shooting the Web
Part I wrote.

FWIW, the text that follows shows in my VS.NET Output window:
------ Build started: Project: MyPageViewer, Configuration: Debug .NET
------

Preparing resources...
Updating references...
Performing main compilation...

Build complete -- 0 errors, 0 warnings
Building satellite assemblies...


------ Starting pre-build validation for project 'MyPageViewerCab'
------
------ Pre-build validation for project 'MyPageViewerCab' completed
------
------ Build started: Project: MyPageViewerCab, Configuration: Debug
------

Building file 'C:\cab\MyPageViewer.cab'...
Packaging file 'C:\Documents and Settings\tbleeker\My Documents\Visual
Studio Projects\MyPageViewer\Manifest.xml'...
Packaging file 'C:\Documents and Settings\tbleeker\My Documents\Visual
Studio Projects\MyPageViewer\obj\Debug\MyPageViewer.dll'...
Packaging file 'C:\Documents and Settings\tbleeker\My Documents\Visual
Studio Projects\MyPageViewer\PageViewerPart.dwp'...


---------------------- Done ----------------------

Build: 2 succeeded, 0 failed, 0 skipped

 
Answer #12    Answered By: Rudy Francis     Answered On: Apr 28

It must be something with my PC. I'm going to try it on another machine and
see if it makes a difference. Anyway thanks for giving me something I can
dig into.

 
Didn't find what you were looking for? Find more on Building Web Parts With VS 2003 Or get search suggestion and latest updates.




Tagged: