Complete SharePoint 2010 Farm on Local Machine

When I try to install a complete farm on a local machine with local SQL Server and no domain, I get some ugliness about needing a domain account to install a complete farm.

The good news is that there’s work arounds. There’s a couple of hacks described here described by our new best friend, Michael.

So, since we’re experts at PowerShell, I warm up to that option. But I’m not very comfortable with the details Michael provides so I go looking and find this from our new best friend, Marc. This is really a pretty good step by step of the end to end SPS 2010 install, the kind of thing that an SPFromScracth robot can really appreciate.

So we run:

New-SPConfigurationDatabase  

And then, after we troubleshoot a couple of errors, we also find this from our new best friend, TiPi.

TiPi’s gone to the trouble to address lot of questions alot of us have and he’s actually followed up to get some intelligent answers. Apparenly, the PowerShell command requires a little finesse including:

  • Run the SharePoint PowerShell console as Administrator (requires a right-click.)
  • Use the <Machine Name>\<User Name> format when prompted for your service account credentials.
  • If it errors, go into SQL Server Management Studio and, if it created them, delete the configuration database and the administration content database.
  • Restart the SharePoint PowerShell console if you get an error.

The guy, Paul, that answers TiPi’s questions is right, it might take a few tries and about an hour. But, it really is pretty cool when you go back to the configuration wizard and it finds your new configuraiton db all nice and pretty.

Thanks again you guys!

-robot

More on Microsoft's Virtual CDROM Player

You people are great.

First, when I needed to make an .ISO file act like a ROM disk drive, I found this that lets me assign it a drive letter.

  1. Download
  2. Unzip
  3. Run the .exe
  4. Select the driver
  5. Start the driver
  6. Pick a  drive letter
  7. Load the ISO

Done.

Then, I’m running it on Windows 2008R2 x64 and I get this ugliness:

The driver has been blocked from loading

Now my inner tech writer notices the passive voice that weakens the statement by replacing the real subject (what did the blocking) with the direct object (the driver) but then, I notice the author neglected to use proper punctuation; if we don’t know the rules of punctuation, we’ll never get the benefits of active voice.

All the same, I search google for the error message and find this page from our new best friend, Lou. In his blog, A Thump to the Brain, he explains that the tool works in WinXP Compatibility mode, whatever that is.

Right click on the .exe and select the compatability tab. Check the Run this Program option, select WinXP SP2 and click OK.

Then run the .exe, intstall the driver, start the driver, create the drive letter and mount the .iso.

Very cool and all for free. You guys are great!

-robot

Access Databases in SharePoint

So when you’ve installed the SharePoint Server 2010 (SPS) you get a load of new templates including web daytabase templates:

  • Assets Web Database
  • Charitable Contributions Web Database
  • Contacts Web Database
  • Issues Web Database
  • Project Web Database

We’ll need to figure out how these guys work.

When I create a new site using one of these templates, I expect that I’ll get that silly “Creating Site” pinwheel but, instead, I get a page that says:

Preparing Site:
Someone has recently made changes to this site and
the site is being updated. If the site remains offline
for an extended period of time, contact a site owner.

And since, this page never goes away, even after an hour and a hundred refreshes, no Bevis, it’s always going to be the same. And, as usual, Since I’m the site owner, again, I’m stuck totally dependent on my SharePoint community friends. At lease it doesn’t invite me to “Troubleshoot Problems with SharePoint Server.”

Lucky for us, our new best friend Marc gives us a clue here.  He says we need:

  • An Access Service Application
  • An Access Database Server
  • To enable session state.

I’m a little confused on the first two. For the last one, Marc is kind enough to provide the PowerShell command:

enable-spSessionStateService
–DataBaseName <SomeNewDatabaseName>

So I go into Central Admin and find Application Management and click on Manage Service Applications. Here we can configure all our service applications and the Access service allows us to throttle all kinds of Access activity.

If we try Application Managment | Manage Services on Server we can see that our Access service is stopped and we can start it there.

So now I can get my web database site built using the projects web database template where I get a cool little grid view thing. I can create projects, users, customers and, on projects, I can create tasks.

But on the Report Center, I can select a report and get a pinwheel but then I get this curious error page:

Report Center Error

Report Center: File Not Found Error

 We can take that coorelation ID to our ULS Error Tool we talked about here. But we better be careful because it’s from an unknown publisher. Once it opens, we simply filter for the coorelation id.

Well that didn’t work. Seems like the doggone thing is moving so quick, Ihave to go File | Abort Load. Then I can find my correlation ID in the correlation column and then filter for that value and I find five rows, including one that says:

Name=Request (GET:http://MyServer:80/MySite/Projects/
AccessServices/Reports/ActiveTasks.aspx)

I can try that page but I get a similar error without all the surrounding folderall.

Then the next error says:

System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.ReportingServices.SharePoint.UI.WebParts, Version=10.0.0.0,
Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its
dependencies. The system cannot find the file specified.

Somehow, I ended up here and worked these mods and then everything’s blown up; I get a white screen with:

An unexpected error has occurred.

I revert the chages and no luck. Dog…

I open my Hyper-V manager and roll back to this afternoon.

Sweet, back in business. We’ll have to look at this more in detail later.

-robot

SharePoint Community Report

Here’s a couple of  items that you could find interesting:

First, there’s Understanding SharePoint Jounal and their SP 2010 Workflow package. It’s only $14.95 and I’m sure you could tell your boss that the decimal point is a typo and put it down as $1495 on your expense report. Take the week off and hang out at the house and then show up next week as the workflow expert.

The second item is Axceler’s SP 2010 Admin Webinar.  They’ve got a “Top Nine” list that you can use to drive any number of disucussions about your (customer’s) SharePoint operation. In the past, I’ve gotten a big kick out of TopFive.Com’s daily Top Five List and I’ve worked with AIIM.Org on their Top Eight topics so this is a first for me and Top Nines. All the same, If you stick around, I’m sure you’ll find me plagerizing Axceler’s bulletpoints soon.

Next, there’s your Visio stencils for SharePoint diagrams, you know the cool ones with the sites and subsites and all the little lists and library icons. Those you can get here from the SharePointSherpa.com.

Then there’s this explanation from our new best friend Chakka  on how this cool tool from MSDN works. Of course none of us have ever been frustrated by the difficulties associated with SharePoint Logs so none of us will be interested in this.

Then, our new best friend, Todd, has outlined the SPS 2010 site templates here. This is a great outline of the 2010 resources we’ll need to know going forward.

Finally, there’s our new favorite They Might Be Giants song, My Experimental Film (thanks to Rock 88 WKNC.Org) It’s not really SharePoint but I’ve had some expiremental SharePoint installs in the past that might have developed along similar lines.

Check those out and let us know what you think.

-robot

Visual Studio 2010 Team Explorer

Visual Studio Team Foundation Server (TFS) is the tool of choice for the large scale development shop. We’ve covered the TFS install before but our note are probably obsolete by now with the onset of the VS2010 product line.

So, while we’ll have to wait to revisit the TFS install, we can look at the client side solution now because VS2010 Team Explorer (VSTE) is a free download from Microsoft  available here.  Also, of course, our friends in Redmond provide bulletproof support and guidance for all their products and they provide alot of that help here, and then they provide this installation guide, too.  Bou know how robots like doing things from scratch around here so let’s give it a go.

First, the download is a .iso file and it’s 311 Mb so that will give us enought time for lunch. And since it’s a .iso, we’ll need an ISO mount solution like the one Microsoft let loose in the wild that you can get here.

This is a .zip file with three files, a readme, a .sys driver and a .exe. You run the .exe, point it to the .sys driver and then mount your .iso with a drive letter. Pretty cool, lightweigh and easy.

Once I mount the .iso, I navigate to the mounted drive and find setup.exe and run it. The Setup wizard opens. I leave the Send Information.. option checked and click Next.

I agree to the license tems and click Next.

I accept the default install location and click Install.

Setup starts to run and installs about 10 components including VC9 and 10 Runtimes, .Net 4.0 Fx, the multi-targeting pack, the VS2010 Shell in “integrated mode,” the TFS object model, VSTE2010, SQLServer CLR types, management objects and the help viewer. Check, check, check… check.

Click Finish and I’m done. That was too easy!

-robot

Commerce Server 2007 Install

Now we’ve got this Commerce Server 2007 solution in our development environment that the team has been working on for about twenty years. And today, I hear “We’re done, here’s the code.”

And that’s it.

So, disregarding the pipeline management issues, it looks like we have to make Commerce Server 2007 run from scratch and I’m the robot that gets to do it.

So, using my free VMWare Player on my Dell Latitude 6510, I create a new virtual machine and point it to my Windows Server 2K3 Standard Edition install disk. I tell the wizard to give it a 40Gb hard drive, enter the product key and it’s off to the races with the blue Windows Setup screen.

That runs for enough time to go get more coffee. Then it reboots into a semi-GUI Windows install environment: Collecting Information, Dynamic Update, then Preparing Installation. Here it barfed complaining about the product key I entered. I double checked my dyslexia medicine and, yes I am up to date, no typos, no nothing. I entered it again and same problem. Then I entered my Win2K3 Enterprise Key and that seemed to work. Weird.

Then, this is funny, during the “Installing Windows” process is says “Completeing Installation.”  Then it moves to “Finalizing Installation.” Obviously it’s got to complete the installation before it can initialize the finalize installation process. At some point it will have to start adding start menu items and, when it’s done it will have to stop adding start menu items. It probably won’t tell anything about the stop menu items.

The installation complete and the machine reboots and wants me to log in as “Administrator”. With no password, I just click OK.

The VMWare player wants to update itself and it want me to turn up the hardware acceleration on the Display Properties | Settings | Advanced | Troubleshoot all the way to full. No problem but it wants to restart.

Before I restart, I go ahead with the Post-Setup Security Updates.  This reminds me of two things. One, it’s way cool the way the VMWare Player just falls right into your host network. And, two, the default install leaves IE Enhanced Security Mode enabled. In Server 2003 IE Enhanced Seurity is a Windows Component you disable in Add\Remove Programs in Control Panel.

Then I’ve got to install an ActiveX Control to get the Windows Update site to work and I tell it to install the updater and select the Express option and turn on Automatic Updates.

This finds that I need to update to Service Pack 2 so I click Install Updates, accept the terms and click Install.

That takes about forty-five minutes and then wants to restart. So I let it.

When it comes back up, it wants me to Activate Windows so I do. When I check Windows Update again, it wants to install a bunch of more updates so I click Okay, agree to the terms and it says it’s got 89 updates to download and install. Might be a good time for lunch.

With Windows up to speed, I’m going to go ahead rename my computer to MSCS01 foregoing the ugly name that the VMWare Player dreamed up. That takes a reboot.

Then I’ll refer to the MS Commerce Server Quick Start Guide and double check my Windows components. It says I need:

  • Accessories and Utilities
  • Indexing Service
  • Application Server – Including:
    • ASP.Net
    • Network DTC Access
    • IIS – Including:
      • Common Files
      • Documentation (optional)
      • IIS Snap-In
      • IIS Manager
      • WWW Service – Including:
        • Active Server Pages
        • WebDav Publishishing
        • WWW Service

And I’m going to uncheck the IE Enhanced Security Mode and add the SMTP server for good measure. I click Next and I need my Win2K3 installation CD again. The wizard completes and I click Finish.

At this point, my default web site should work so I open IE8 and, after the IE8 Pest bothers me about a tour of IE8, I point it to http://localhost and I get the Under Construction page. Perfect.

I’m also going to need a user account to login to SQL Server with so I’m creating a new user and putting him in the local administrator group,

I insert the SQL Server install disk and it brings up the Install Wizard. I accept the terms and click Next. It installs the prerequisite setup support files. I click Next.

The wazard runs the configuration check which cries about minimum hardware requirements. This is where I check the VMWare Settings and see my VM has only 348Mb RAM.

I have to power down the VM to change it so down it goes. On the way down, it wants to install updates so I let it.

Before restarting it, I edit the VM settings and give it 2Gb RAM. That should do. I click Play Virtual Machine.

When it comes back up, I reinsert the SQL Server install disk and the wizard starts. I click Install Server Components..

I accept the license terms and click Next. It copies the Setup Support files and then I click Next.

Welcom to the Wizard.. Next.

Config Check, all good.. Next.

Enter my product key.. Next.

On Select Components, I check everything and click Advanced. under Documentation.. I deselect the sample dbs and code and Books online and click Next

I opt for the default instance and click Next.

I opt for the domain user account and enter my user created earlier, the password and the computer name as the domain and click Next.

I select Mixed Mode authentication, enter an sa password and click Next.

I opt for the default collation settings and click Next. Now I don’t know how many of you knew this but the CS Install Quick Start guide says:

Commerce Server databases require collation settings that are
not case-sensitive.

I had a Microsoft guy tell me once that you gotta be nuts changing from default collation settings so I don’t. Partly because of what he said and partly because I’ve never felt a need.

I opt for the default Reporting Server options and click Next.

I opt to send nothing to Microsoft and click Next and then Install.

So the SQL Server install runs…

and runs..

and runs…

It’s got this nice little progress interface and it’s rolling through the files but it runs for ever. My boss is saying the the IO from the VMWare Player to DVD drive is known to be slow so you might get a little better performance from a different VM solution. Regardless, I started this install yesterday and hope to finish today.

When it’s done, I got a nice column of green checkmarks on rows of items that all say Setup finished.

I click Next and then Finish.

I reboot the server a couple of times and occasionally it cries for an update.

The boss says the SQL Server configuration requires only TCP\IP so I disable the others in the Configuration Manager’s Client Protocols node. Then on services, I set the SQL Server Browser Service on Automatic and start it. We won’t need the Agent but I start it and stop it all the same just to make sure it works.

Referring back to the Quick Start Guide, it tells me to install .Net 2.0 by running:

c:\Windows\Microsoft.NET\Framework\2.0.50727\aspnet_regiis.exe -i

This runs to problem. Then it tells me to go here and download a hotfix:

http://go.microsoft.com/fwlink/?linkid=63706

This is a CAB file download specificaly for Server 2003 x32 English.  The Quick Start Guide has links to other versions. I copy it onto my server and double-click the KB13393.exe file which extracts the file from the .CAB file where I can double-click it again. It asks for permsission to run and then gives me a license agreement which I accept. It runs for a minute and then tells me it’s been sucessfully installed.

The Quick Start Guide does not tell me what to do with the other .exe files in my .CAB file. So I leave them alone. Also, there’s a couple of other steps to follow for Servefr 2008, Vista and XP that I’m ignoring.

It wants me to create a user for the Commerce Server services. I create the RunTimeUser account as directed.

The Commerce Server install is the base and SP2. I unzip the base install and click setup.exe and then the Install Microsoft Commerce Server 2007 link. The product key is embedded in this install; I click Next, accept the license terms and click Next again.

On the Component Installation page, I’m going to uncheck the Direct Mailer, the Health Monitoring Server and the Volume Shadow Copy Writer Service. I can’t check the Project Creation Wizard because I don’t have Visual Studio installed except the Premier Partner Edition that came with SQL Server. I click Next.

On the Redistributable Prerequisites page, it leave it set to automatically install the MS Document Explorer 2005 from the CAB file I downloaded earlier and click Next and then Install.

The installation take just a minute and you want to cleak the check from the Launch box before clicking Finish.

Then, there’s some ambiguity about what to install next. The Quick Start Guide says install the Business Management Applications and then SP2. The install page calls it the Business User Applications. I click that link accept the license terms, check all the components and click Install. That takes just a second and I click Finish.

Then I doulble-click the SP2 install. I get a welcome screen and I click Next, accept the license terms and Next again.

That opens the Configuration Wizard. I click Next.

I leave the database server and database name alone and allow for Windows Authentication and click Next and Next again and then Finish and then Finish again.

Oddly, that leaves the Upgrade Wizard on the screen.  I click Next and then Next again and then Finish.

Before I proceed, and since I want my site to have a real name other than localhost, I’m going to add a couple of host headers to my hosts file and create a new IIS website for the new application. In my hosts file, I’m going to add:

127.0.0.1       MySite.MyComputer.Local
127.0.0.1       MySite.MyFirm.Com

Then, in IIS, I’m going to right click on Web Sites and select New | Web Site and complete the wizard naming it MySite and mapping the new site to a folder under inetpub\wwwroot named MySite. Then, I’ll go into the site properties to add the second host header. So now, from a browser on the server, I can browse to MySite.MyComputer.Local and land on default.htm in my MySite folder. I do this because I like to leave my default web site intact except for some clever mods to the under construction page. This allows me to troubleshoot my app and IIS separately.

At this point, the Quick Starg Guide says to unpack the site and then configure security, including the certificate and SSL configuration. The site we want to unpack is not the starter site but rather the CSharp. Commerce Server sites are packed into a .pup file so the site we want is CSharp.pup which was copied into:

c:\Prgram Files\Microsoft Commerce Server 2007\Pup Packages

The Quick Start Guide covers this pretty good. Run the site packager by selecting the Commerce Server 2007 | Tools | Site Packager option from the Start | All Programs menu. We want to select Unpack from a Package File and click Next.

Point the packager to the .pup file and dot the Custom Unpack option. In our case, we need to forego the Quick Unpack option because we want to use the custom IIS web site.

We’ll accept the Create a new site option and click Next again. Here, we’ll change the name to MySite and click Next. We’ll leave all the resources in the right side box and click Next again. Since this is the first time through, we’ll add the two new global resources for CS Authentication and Progiles and click Next.

We’ll accept the default connection strings and click Next again. We’ll leave all the applications checked to upack them all and click Next

On the Select IIS Computers, Web Sites and Paths page, we’ll change each application’s web site to MySite and click Next. Here, the wizard will start to run saying it’s Unpacking… and showing you files as they unpack. Then, it will stop and ask you to confirm default settings for the Profiling System resource. I just clicked Next and got a second page of settings and clicked OK this time. It runs some more and then gives you a dialog box where it tells you it’s configured the various connection strings to use Windows authentication. This means we’ll have some additional security steps to provide the right permissions but that’s all covered in the Quick Start guide. I just Clicked OK.

Finally, the unpacking is complete and you get to see the databases and site it created. Conveniently, it drops the Pup.log right in your C:\ root folder. I clicked Finish.

At this point, I would expect to see some kind of CSharp site at my designated local host header htt://MySite.MyComputer.Local but I don’t. What I do see is the Default.htm that I added to the web site’s home directory that just says “Welcome to MySite.MyComputer.Local.”  The Quick Start guide continues with some security settings so let’s look at those before we dig any deeper.

First, we add our run time user and grant Write permission to:

\inetpub\wwwroot\MySite\CatalogWebService\CatalogAuthorizationStore.xml

Then, we do the same for:

\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

And:

C:\WINDOWS\Temp

Then we run the Authorization Manager snap-in, azman.msc, to edit web service .xml files. We right click on the root node and select Open Authorization Store. Then browsing out to the web site folders and opening the *AuthorizationStore.xml files. Once open in the Authorization Manager, we traverse down the tree to the *Administrator role and add the run time user to the role.

Next, we grant database permissions to our run time user and, since we’re on Server 2003, we’ll have to grant database permissions to the ASP.Net process. This means going into SQL Server Management Studio and moving down the database tree to the Security node, right-clicking on Logins and selecting New Login.

We add the run time user and then, on the User Mapping tab, we map it to database user and add roles as follows:

<Server>_Admin Database:          admin_reader_role
<Server>_CatalogScratch Database: db_datareader
                                  db_datawriter
                                  db_ddladmin
MySite_marketing Database:        db_ddladmin
                                  mktg_MarketingService_role
                                  mktg_promoCodeGenerator_role
                                  mktg_runtime_role
                                  mktg_staging_role
MySite_MarketingLists             db_datareader
                                  db_owner

MySite_ProductCatalog             ctlg_CatalogReaderRole
                                  ctlg_CatalogWriterRole
                                  db_datareader
                                  db_datawriter
                                  db_ddladmin
                                  db_securityadmin
                                  Inventory_ReaderRole
                                  Inventory_RuntimeRole
                                  Inventory_WriterRole
MySite_Profiles                   Profile_Reader
                                  Profile_Runtime
                                  Profile_Schema_Manager
                                  Profile_Schema_Reader
MySite_TransactionConfig          Orders_Management
                                  Orders_Runtime
MySite_Transactions               Orders_Management
                                  Orders_Runtime

Next, we create and install a temporary SSL certificate.  This requires downloading the IIS 6 Resource Kit from:

http://go.microsoft.com/fwlink/?linkid=59276

Install it and then run the SelfSSL program. This install takes just a second and then it’s Start | Programs | IIS Resources | SelfSSL and you get a little command window. You’ll need the Site ID. Lucky for us, our new best friend, Scott, explains here that you can find the Site ID in the web site property’s log file folder name. Also, since nothing ever gets done in seven days, I’m running the certificate out to 700 days. So my command line looks like this:

C:\Program Files\IIS Resources\SelfSSL>selfssl.exe /T
/N:CN=MyComputer /K:1024 /V:700 /S:40485460 /P:443

The command returns a success statement.

Finally, we grant permissions to the IIS worker process groups. This means we go into IIS and create a new application pool and assign it the run time user ID and enter the password. Then we add our run time user to the IIS_WPG group in Computer Management. Then, for each of our applications under our web site in IIS, we have to select our new application pool on the Virtual Directory tab and, when we’re done, run an IISReset.

 

 

 

 

 

 

Debugging Web Parts

So we have a to do list that includes looking at Kerberos for CRM and SharePoint v4 as well as another that includes getting the BDC ADF File Builder to run.

But for now, we’ve had a new project dropped on us that includes reworking a web part project that never really got finished. It’s a WSS 3.0 solution so let’s see what we can do with it.

First, I have the solution file: MyProject.sln and MyProject.sou.

In Visual Studio 2008, I select Open from the File menu and select Project\Solution. In the Open Project dialog box, I navigate out to my  project folder and select MyProject.sln.

The project opens in the solution explorer. Now we have our friend, Carsten’s WSPBuilder installed in the VS environment so, when I right-click on the project, I get a WSPBuilder | Deploy option. That makes the machine run and I get a little text in the output window that ends with Done.

Now, since I’m working directly on my SharePoint server and this web part has already been deployed and is visible on a team site, I can pretty much hack it up and redepoy it and my hack will appear on the screen.

For example, I have a MyWebPartToolPane.cs file that’s got code that looks like this: 

namespace CmsFtpPublishing32bit.WebPartCode
{
    public class MyWebPart : System.Web.UI.WebControls.WebParts.EditorPart
    {

In here, we’re creating a bunch of controls and structuring them in the tool pane with alot of these:

 
 

Controls.Add(new LiteralControl("<br/>"));
Controls.Add(new LiteralControl("<div class=\"UserSectionTitle\">These Settings</div>"));
Controls.Add(new LiteralControl("These Settings<br/>"));
Controls.Add(TheseSettings);
Controls.Add(new LiteralControl("<br/><br/><div class=\"UserDottedLine\"></div>"));

Here is where we can add “Hello World” and see it in our tool pane. First, we have to do a WSPBuilder | Deploy again. Then browse to the page with the web part and open the tool pane.

Next we’ll attach the debugger to it and break into the code at runtime. Event though it was written in 2006, our new best friend, George, outlines, in this post, the process of attaching the VS debugger to your w3wp.exe process to hit your breakpoints.

hth

-robot

SPN = Service Principal Name

This is an issue we’ve looked at before, and may again, where services have to be properly identified in order to be shared across computers. For SharePoint, we installed Kerberos authentication which relies on Service Principal Names (SPNs). Here is a great description of how this works.

hth

-robot

MOSS 2007 BDC Effort

We’ve seen this work before so, you’d think…

But, so it goes with SharePoint sometimes.

I found this great piece from our new friend Tobias that helps with the Application Definition Designer. Everything goes according to plan until I get to the BDC Web Parts. We’ll cover all this, but, for now, what’s happening is that, in my Business Data Type Picker dialog box, I get: There are no Business Data Types loaded in the Catalog.

Of course, I can look at my BDC and see that’s not true. So I went looking and found Ulysses’ post here and followed along. When he gets to the SSO configuration in Central Admin, I get an error:

Single sign-on cannot be configured from this server. To configure single sign-on, go to the computer running the single sign-on service and specify these settings locally.

Obviously a complication that Ulysses had not anticipated so I went off looking again and found Robert’s MOSSSSOSSxS (I love my job! The last four = “Setup Step by Step”)

His steps are:

  1. Set up the service account; I’ll use my MOSS_DBAccess account.
  2. Create SSO Groups;
  3. Configure the SSO Service in the Windows Services MMC.
  4. Configure SQL Server Permissions.
  5. Configure SSO in Central Admin.
  6. Manage the Encryption Key; huh?
  7. Manage EAD setting; Enterprise Application Definitions.

So, it’s early yet; maybe we can make some progress.

-robot

SharePoint Foundation 2010 Web Parts – The Way Things Should Have Been

Have you ever uttered an obscenity when you tried to build a web part for SharePoint 2007? How about for SharePoint 2003? Wasn’t that just ridiculous? Well on first review, your vocabulary may be taking a turn for the better; This really is easy.

The one thing that hasn’t gotten any better is the propensity for the providers of “How-To” guides at Microsoft to booger things up while we struggle with these new concepts.

For example, anybody that can make heads or tails out of this ought to work for the Franklin Mint. As I read it, the file names vary from step to step and the code includes the fancy left and right side quotation marks that blow up your .cs pages. So I went looking for another one.

Then I found this one that was much better but still has at least one “gotcha.” It seems that the author neglected to properly modify his name space in his sample code and that will blow up your build. This gives us a good chance to try to figure our what his or her  problem is.

Recall that we’re running SharePoint Foundation on Windows 7 x64 VM, per our recent posts, and that we’ve installed VS2010 from the 90 day trial download version.

First, like I said, the create\build\deploy steps are a snap. In VS 2010, it’s File | New | Project and under the C# projects, select the SharePoint 2010 node, select the Visual Web Part and click OK. One thing to think about is where you put the solution. In Windows 7, if you put it in the C:\Sample Web Parts folder, you’ll have to do a silly Run As Administrator tap dance later to delete it. I chose to create and use a folder under my user name folder next to My Documents and check the Create directory for solution option. Then click OK.

Then, you get one of the cool new parts, it asks you for the site where you want to deploy\debug your web part. I created a blank sample site and used it. My Deploy as a Sandboxed Solution option was greyed out; not sure what to make of that. I just clicked Finish.

So my solution gets built and I’ve got a bunch of files and since I didn’t change the name in the previous step, in Solution Explorer, I’ve got a VisualWebPart1 node. I see it have a VisualWebPart1UserControl.ascx file under it which has a VisualWebPart1UserControl.ascx.cs file under it which has a VisualWebPart1UserControl.ascx.design file under it. Pretty Deep, no?.

Okay, on the .ascx file, right click and select View Design. The design page and the tool box open. In the toolbox, find the TreeView control under the Navigation section (Very Visio-like toolbox) and drag one onto the design. When the treeview control is selected in the design pane, its properties will show up in the properties pane at the bottom right of the VS workspace. Find the ID property and set it to siteStructure and then click Save. So far, so good.

Then we have to code the .cs page to populate the tree when the page loads. The guy\gal that wrote the post (here‘s another link to it)  just gives us the code with a convenient Copy Code link. Click the link. Back in your project, right click the .ascx.cs file and select view code. Click in the code somewhere and press CTRL-A | CTRL-V.

Notice the red squiggleys in two palces, both under the word siteStructure? Believe me, these guys get paid way more than me so they ought to know better.

Here’s the problem. The dude\dudette was obviously on his way back to Seattle back from Burning Man when he wrote this and he had Bonneville on his mind and wrote that into his namespace. Now I probably don’t understand namespaces as well as some of you, but I know:

BonnevilleTestBed.Bonneville <>VisualWebPartProject1.VisualWebPart1

The left side of that equation is the namespace cited in the .cs code we copied from the guy’s article. In addition, the code tries to build a partial class called:

BonnevilleUserControl

The left side of that equation is the namespace cited in the .cs code we copied from the guy’s article. If you right click on the .ascx.designer.cs page and select View Code, you’ll see that what we really need is a namespace called VisualWebPartProject1.VisualWebPart1 and a partial class named VisualWebpart1UserControl.

Copy those names from the .designer.cs page to the .ascx.cs page overwriting the silly Bonneville stuff. The red squiggleys go away. Press f5.

My Sample site comes up and sits there like it’s a SharePoint site which, of course it is, but it’s not doing anything. But, I can select Edit Page from the Site Actions menu and click Add a Web Part. In the Categories picker on the left, I select Custom and there’s my VisualWebPart1. I select it and the click Add and then click the Stop Editing button on the ribbon.

Since I used a blank site, there’s nothing under my Sample Site node but, as I add lists, libraries and subsites, they fall into my tree view just fine.

Now all we need to do it build a solution we can add to our SharePoint sites for real, not just in our debugger mode.

There’s a great expository on the process here written by our new best friend, Eric, at BinaryWave.com. He explains the advantages of the new process and an introduction to the steps we’ll take to deploy our new web part to a production farm.

Eric brings up a couple of great, new points, the first of which is conflict resolution. These are issues that arise when, for example, I deploy MyWebPart as a feature in a site where you’ve already deployed your MyWebPart. Conflict, Ouch! Let’s ignore this for now with a promise to explore these conflict resolution properties later.

Second, Eric tells us we’re really dealing with SPI’s (SharePoint Items.) These are the components that will be mashed into a solution for deployment. In our case we have one, VisualWebPart1. Eric tells us:

By default, all SPI’s in the project which are included in a Feature, along with any mapped folders, will be automatically added to the package.

That should work for us now since what we want is a package with our web part in it that we can add to our production environment. Where we’re headed is a file called package.package. See why I love this job? As we may already know, the steps are to bundle our SPI’s into a package, deploy the package as a solution on our target location and activate the features that bring our SPI’s to life while, at the same time, avoiding any conflict nastiness.

At this point Eric strays off into other objectives as we go looking for someone more on point, like our new best friend Belajar, here. He says right-click on our project name and select Package. I get a status bar indication that Package Succeeded and I get a VisualWebPartProject1.wsp in my project’s bin\debug folder.

So with the .wsp in hand, we need only to load it into our production portal. The best source for this info is our new best friend, ICC, who feeds us, here, the PowerShell routines that get this done for us.

I do the add-spsolution and that works fine.

Then, I try the install-spsolution and I get this silly error:

PS> install-spsolution -identity visualwebpartproject1.wsp -webapplication http://Jeffery -GACDeployment
Install-SPSolution : Admin SVC must be running in order to create deployment timer job.

That is where we go look at our Windows services and find the SharePoint 2010 Administration Service and start it. I recall setting it to Manual Start previously to conserve resources on the “Production” box. Then I have to go look in Central Administration to find the timer job that started but never ended. It’s in the list under Central Admin | Monitoring | Check job status. Now the status page is nice but with the way it pages, it’s kind of clumsy so I click on Job Definitions and found the VisualWebPartProject1 job and opened it and selected Delete. Then I went back to PowerShell and ran my install again. When it returns a PS prompt, I know something worked.

So I create a web part page to add my new web part to and it’s not there. Rats.

This leads me to the Web Part Gallery. It’s not there either.  More Rats.

Now this part is tricky. Notice, on the Web Part Gallery, up on the ribbon, you get a Library Tools set with a Documents and a Library option. Clicking on Documents we get a New Document option. Click it Baby!

 At the very bottom of the list, there’s our VisualWebProject1.VisualWebPart1.VisualWebPart1 web part. Drop an X in the box and click Populate Gallery back at the top of the page. That takes us back to the gallery with our new web part sitting there with a little SharePoint New flag next to it.

Go back to the web part page and click on the Add Web Part link. In the Miscellaneous group, we get the VisualWebPart1 option. Select it and click Add. Click the red X to stop editing and reload the page.

That has got to be the prettiest web part I have ever seen.

This is also where we’ll start our “Yay, It’s Friday” celebration. Have you seen Hoops and Yoyo’s “I Don’t Care Friday” routine?

-robot