views:

1090

answers:

5

I am working with a project generated by the VS2008 Sharepoint template (VSeWSS). Currently, when working in the ASCX files that I have, IntelliSense does not recognize the imported namespaces. I'm uncertain what to do to address this.

Note: Per edit below, importing SharePoint.WebPartPages works fine, it's just SharePoint.WebControls that doesn't.

The project does build without error and deploys correctly. Removing the <%@Register Tagprefix="SharePoint"... line results in the expected "Unknown server tag 'SharePoint:SPGridView'" error once deployed.

I have found similar questions (ex. Unrecognized Tag Prefix or Device Filter in Visual Studio 2008) however, the question and its answers refer only to web projects. In particular they speak of a web.config file. Something that is not created as part of the SharePoint template.

Suggested solutions and reasons they didn't work:

  • Create a web.config file -- File does not exist in this type of project
  • Add a reference to the dll -- No apparent effect

Further directions or suggestions on fixing this would be welcome.

<%@ Control Language="C#" AutoEventWireup="true"
   Inherits="HelloWorld1.UserTableDoom, HelloWorld1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2ace7ea1e94310d3" %>
<%@ Register Tagprefix="SharePoint" 
   Namespace="Microsoft.SharePoint.WebControls"
   Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<SharePoint:SPGridView ID='fooGrid' runat='server'
   AutoGenerateColumns='false'
   DataKeyNames='user_id'
   DataSourceID='foo'>
...
</SharePoint:SPGridView>

Edit: Interestingly enough, I can add the WebPartPages namespace and I it works correctly in IntelliSense.

I have also noted that when creating an entirely new solution and placing the ASCX file in it. The problem still exists. The SharePoint.WebPartPages works but SharePoint.WebControls does not.

<%@ Register Tagprefix="WebPartPages"
   Namespace="Microsoft.SharePoint.WebPartPages"
   Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<WebPartPages:...>  -- works correctly.
+1  A: 

I'm using the same code you have to display an SPGridView, however have no problems with Intellisense. It does put strange formatting over the word SharePoint in Microsoft.SharePoint.WebControls but works fine apart from that:

<%@ Control Language="C#" AutoEventWireup="true" Inherits="QueryDemo.QueryDemoControl, QueryDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5434e690be8749f6" %>
<%@ Register Tagprefix="WebControls" Namespace="System.Web.UI.WebControls" Assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<SharePoint:SPGridView
    id="queryGrid"
    runat="server"
    DataSourceId="queryData"
    AutoGenerateColumns="false"
    width="100%"
    AllowSorting="True">
      <AlternatingRowStyle CssClass="ms-alternating"/>
</SharePoint:SPGridView>

Ensure that you have a reference to Microsoft.SharePoint in the Visual Studio project and try executing the code. If the grid displays then the problem must lie with Intellisense.

Alex Angas
The page does execute correctly. There is a reference to the library in the References section of the project. I am unaccustomed to VS :/.
Danny
Unfortunately I do not know much about VS's work-flow. But, the particular file is an ascx with which I am loading into my web-part.
Danny
@Danny: Maybe it has something to do with the project type. Have you tried setting up a web application project and copying the ASCX in there?
Alex Angas
@Alex: I have recreated the file in another web site solution and it does not function here either. `Microsoft.SharePoint.WebControls` simply does not seem to work. `WebPartPages` does.
Danny
@Danny: Try downloading the source to my CodePlex project http://spquerydemo.codeplex.com. That uses the SPGridView in a user control, within a web application. It might help to diagnose the problem. If you want to try e-mailing your .ascx file, use the contact link on http://www.codeplex.com/site/users/view/arangas or DM me your address on Twitter @alexangas, and I'll reply with my address.
Alex Angas
@ALex: Opening the `12/TEMPLATE/CONTORLTEMPLATES/QueryDemo/QueryDemoControl.ascx` file gives the usual errors I have encountered within my own applications. `WebControls` exist and is recognized, `SharePoint` is not. There has got to be something I'm missing here.
Danny
@Danny: Must be an environment-specific thing. Not sure how much more I can help without seeing your machine. Maybe there is a Visual Studio or SharePoint install problem? Perhaps nothing to do with SharePoint at all?
Alex Angas
A: 

Try installing Visual Studio Service Packs.

GWLlosa
SP1 is installed.
Danny
A: 

Try running the following:

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv -resetsettings

You may have to run as admin for maximum effect.

GWLlosa
A: 

Did you manage to solve the problem? I've encountered exactly the same problem. I have Sharepoint installed on my local machine (64 bit, not a server) with the mamboo solutions tool. Maybe that can be a problem?

Rene
I have not fixed it. However, I haven't run GWLlosa's suggestion yet. I put aside the VS project for awhile. I should have time tomorrow to try it. In response to your question however, I do not use the bamboo solutions stuff.
Danny
A: 

Hi, we have still exact the same problems with intellisense.

All other namespace like Microsoft.SharePoint.WebPartPages or ajax are working fine, only the sharepoint webcontrol prefix (Microsoft.SharePoint.WebControls) is not working with intellisense.

I run the command from GWLlosa, but the problem still exists.

Then I download the source code from Dani's project and looked to the QueryDemoControl.ascx. There's also the same problem. The Intellisense for Microsoft.SharePoint.WebControls is not working, the other namesspaces are working fine.

Has anyone another idea to solve this?

Thanks a lot, Arne

Arne