Thursday, June 30, 2011

'Activate Features' failed while deploying SharePoint Solution from VS.NET 2010

If you had encountered the following error "Error occurred in deployment step 'Activate Features': Attempted to perform an unauthorized operation." while trying to deploy a visual webpart from VS.NET 2010 to a SharePoint 2010 site. This is because, the windows user account on which the "VS.NET 2010" is running on (even though you might be running VS.NET as adminstrator), doesn't have "Site collection administrator" privileges on the site, to which you are trying to deploy the Visual webpart.

When I encountered this error, the user which i had logged into windows is the same account as the SharePoint farm account; but this account wasn't added to  "Site collection admin" group for the site to which I was trying to deploy to. 


Here is the log from my VS.NET 2010 output window


------ Build started: Project: MyVisualWebPart001, Configuration: Debug Any CPU ------
  MyVisualWebPart001 -> E:\SP2010Prjs\MyVisualWebPart001\MyVisualWebPart001\bin\Debug\MyVisualWebPart001.dll
  Successfully created package at: E:\SP2010Prjs\MyVisualWebPart001\MyVisualWebPart001\bin\Debug\MyVisualWebPart001.wsp
------ Deploy started: Project: MyVisualWebPart001, Configuration: Debug Any CPU ------
Active Deployment Configuration: Default
Run Pre-Deployment Command:
  Skipping deployment step because a pre-deployment command is not specified.
Recycle IIS Application Pool:
  Skipping application pool recycle because no matching package on the server was found.
Retract Solution:
  Skipping package retraction because no matching package on the server was found.
Add Solution:
  Adding solution 'MyVisualWebPart001.wsp'...
  Deploying solution 'MyVisualWebPart001.wsp'...
Activate Features:
  Activating feature 'Feature1' ...
Error occurred in deployment step 'Activate Features': Attempted to perform an unauthorized operation.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========


If you were to analyze the logs, you could find that the solution was successfully deployed to farm. Only the activation part did fail, because the user which I had logged into windows didn't have "Site Collection Admin" privilege. While trying to resolve this, I ended up with two solutions to this error.


Solution 1:
1. Add the windows username with which you had logged into the machine as "Site Collection Administrator". Here are the steps to get that done

a) Open Central Admin

b) Select "Application Management" from the left menu

c) Click the link titled "Change site collection administrators" listed under " Site Collections"

d) Select your site from the drop down

e) In the "Secondary site collection administrator: " textbox key in the logged in windows username and click OK

f) Now goto VS.NET 2010 and select "Deploy Solution" from the "Build" menu. This time your visual webpart will be deployed to the farm and will be activated without any errors at the site collection level.

Solution 2:
1.Here I am not going to alter any permissions; instead the deployed feature (Visual Webpart) is going to be activated manually. So here's how

a) Open Central Admin

b) Select "System Settings" from the left menu

c) Under "Farm Management" click "Manage farm solutions".

d) In this page make sure you visual webpart name is listed and the status is shown as "deployed". This means the solution was sucessfully deployed at the farm level.

e) Next we are going to activate the deployed solution at the site level. This is the point where VS.NET reported the error.

f) Open you Sharepoint site to which you were trying to deploy the solution against.

g) Select "Site Action" -> "Site Settings"

h) Under "Site Collection Administration" category, click "Site collection features"

i) Locate the name of your visual webpart(name of the solution or feature).

j) Click the "Activate" button next to the feature name, that's it.

k) Now you should be able to add the webpart to a page of your choice.


Next, the problem you could likely to face while trying to retract this solution from the site is that. An error can come up, if the windows user under which VS.NET is executing is not a "Site Collection Admin" for that specific site. So we will see how to retract a solution the manual way.
  1. Open the site to which you had deployed the feature\solution to.
  2. Select "Site Action" -> "Site Settings"
  3. Under "  Site Collection Administration" category, click "Site collection features"
  4. Find the name of the feature\solution you wish to deactivate and click the deactivate button against the name.
  5. Open Central Admin
  6. Select "System Settings" from the left menu
  7. Under "Farm Management" click "Manage farm solutions".
  8. In this page locate the name of the feature\solution you wish to retract
  9. Click the name of the feature\solution
  10. Now you should see, three menus on to the top of the page with the titles "Deploy Solution", "Retract Solution", "Back to Solutions"
  11. Click the link "Retract Solution", in the next page leave all option as it is, if you want to retract from all web applications. In case if you want to retract this feature only from a specific webapplication select the web application from the drop-down.
  12. Click OK
  13. It may take some time for the retraction process to complete.
  14. Once the solution is sucessfully retracted, you should see the text "Not Deployed" in the status column for that feature\solution.
  15. If you wish to completely takeout that specific feature\solution. Then click the name of that feature\solution and in the next page select "Remove Solution" from the top three links.

Whats next after MVP?

I happened to meet an a guy who was an MVP in SharePoint, naturally that made me to get to know more on the MVP program and its benefits. During the talk, he was mentioning about his acquaintance who is a Microsoft Regional Director. Initially I was under that impression that the person he was referring to is an Microsoft employee, but later only I did realize the fact that 'Microsoft Regional Director' is a title awarded by Microsoft for those, whose contributions had inspired and had made a positive impact on the technical community at large through delivering speeches and presentations at major events like PDC, TechED, MIX etc. The crux with 'Microsoft Regional Directors' is that, they are the champions of Microsoft technologies and above the MVP's.

I think you must have heard about this guy 'Scott Hanselman'. He is a popular figure in Microsoft community programmes, who was conferred with Microsoft Regional Director status.

While searching on this elite Microsoft programme, I came to stumble upon some links that sheds some light on 'Microsoft Regional Director' (RD) programme, here are they. 


Microsoft Regional Directors site. Here in this site, RD's from all around the world are listed by their names. I came to see that N.America happened to be region with the most number of RD's. Here's some more titles which you might see occasionally with professionals evangelizing Microsoft products\services.



Wednesday, June 29, 2011

My New Dell XPS

Thank God, finally the long wait is over and my new Dell XPS got delivered a day late. This was the first time in my life I had placed an order this big through an e-commerce site; i.e. through the Dell online store. Initially I was hesitant to place an order online, especially because of the security and reliability issues which were being reported by most daily's with respect to e-com businesses. This made to pull back from placing an order online. But after making some visits to some of the prominent laptop dealers in and around the city. I came to conclude that, they could only provide me with pre-configured ones (the customization's they could offer were limited to components like RAM, Outer cover [Skin] and Video cards), but not customized versions which I was  looking for. This made me to go back to square, the Dell online store.

After visiting the Dell online store, I was quite surprised the number of options for one to choose from, in terms of components and accessories; not only that, one could see in real time, on how much each component you add or takeout is going to cost you at the end. Finally I built my customized Dell XPS laptop configuration in Dell Online store with all these components and accessories.
  • Intel Core i7 2630QM - 2.00 to 2.90 Ghz
  • 8GB Dual Channel DDR3 SDRAM at 1333Mhz
  • 500 GB HDD (7200 RPM)
  • 16x DVD+/-RW
  • Wireless LAN - WiFi
  • WiFi and Bluetooth
  • Integrated Gigabit ethernet 10/100/1000
  • Camera: 2.0MP HD with single digital mic (H.264)
  • JBL 2.0 Designed n Certified Speakers
  • Bluetooth v3.0
  • All together 3 USB ports 
  • 1 USB 3.0 port
  • 1 eSATA/powershare combo
  • HDMI 1.4
  • Small DVI Port
  • 9 in 1 card reader
  • NVIDIA 1GB Graphics card
  • 15.6-inch HD (720p) WLED Display
  • Windows 7 Home Premium 64-Bit
  • 6-cell Lithium Ion Primary Battery

After booting up the laptop, which was itself was noticeably fast, after which I was guided through a wizard to fill in details like TimeZone, DateTime, User Account creation blah blah etc. Once the desktop was up, I was surprised to see the number of gadgets running on there, to me it seemed like a kiosk kinda screen. So what's next?, I fired up the task manager to see whether the number of processor cores they(Intel) had promised were there or not. Seeing the Performance tab of the task manager, my eyes almost popped out seeing the number of cores shown there. See it for yourself.


Literally I counted with my fingers on the columns\cells shown as cores. All together there were eight; Wow how did this happen, I thought Core i7 was just quad core processor, so how on earth they moved from quad to octal, when was this announced? After a brief search on this my Wow effect bursted into laughter. The eight core what I saw in the task manager was the hyper threading in action, which means  each core runs two threads, that why its showing eight cores. The hyper threading(HT) feature was re-introduced back with iCore series. Before this, it was newly introduced with Pentium 4 processors, a feature that made one physical CPU work as two logical CPUs. 

I though it would be better to show off my 'Windows Experience Index'. The components which didn't perform up to Microsoft exceptions where the Graphics Card and definitely the storage. I now feel like I should have gone for the SSD, but hearing the costs made be pull back its best suited for the deep pocket professionals. So here's my index of 5.9 not that bad, isn't it. 





So let me talk about features I liked the most with my Dell XPS 15.

The overall build quality is good with backcover built out of silver anodized aluminum, which makes it standout from the crowd. When turned on the XPS logo glows giving out a cool white ambient feel, which definitely will catch others eye. The frame surrounding the screen are built from high quality plastic. I would appreciate the jet black used for the frame around the display, as I felt like this will help to concentrate on the matter without any color distractions. 


Aesthetics
The moment I powered my new Dell XPS, the status lights located just next to the power button started glowing in a synchronized fashion giving a feel of festive season, during the booting process, which actually was doing the Power On Self Test routine.


WiFi
The next thing I liked the most was the placement of WiFi enabler button along with the function keys, now I just have to toggle the function(fn) key along with the function key for WiFi, previously with my Lenovo thinkpad, I had find that on\off swtich located by the side of the laptop to enable or disable the Wifi and Bluetooth access, which was a bit awkward to locate.


Touchpad
Coming to the touchpad, I really love the different options provided; including multi touch capability to zoom-in and zoom-out images by merely moving you fingers from inside out and vice verse. You could even rotate images by moving your fingers in a circular motion on the touchpad, there's still lot many patterns in the manual which came along with, which I need to go through.


Speakers
If you are a music enthusiast, the powerful JBL speakers is going to keep your ears tuned to the music flowing from these small yet powerful speakers even in the middle of a crowd. If I were to compare the speakers which came with Lenovo Thinkpad, its now where near by in terms of loudness and sharpness. The output from JBL is powerful enough to reach out to a distance of 15 to 20 yards without considerable degradation in quality. If you want to listen to those favorite tracks  without invading others privacy, there's an option to plug in your head set including mic just next to the optical drive, which I am yet to explore.


Extended Function Keys
Dell had integrated more set of functionalities to the existing set function keys by integrating features like "Multimedia Function Keys", "Contrast Control", "Display Switch", "Enable\Disable WiFi", "Enable\Disable Touchpad" so using the function keys with the "Fn" key combination will make the functions keys to execute those extended functions. 



There's a lot more to jot down regarding the features I liked the most and I hate(not a quite good design) the most. I will be updating this post soon, so watch out for more.


Monday, June 27, 2011

BOOTMGR is Missing

Today I was playing around with "Disk Management" where I came to see a system reserved partition with 100MB marked as active. This partition didn't contain the OS at all, so without any second thoughts I made the active partition as C:\ from the existing system reserved partition. After I re-booted I was dumb folded seeing this error, which means I had stepped off on the wrong foot. 


So how to get my OS back? after going through stacks of DVD's, Luckily I got my Windows 7 installation disk. I loaded the disk and re-booted. 
  • In the initial screen I selected "English" as the language of choice and clicked next.

  • In the next screen I selected "repair your computer" (a link on the left bottom) which showed up a window with a progress bar, trying to find my existing Win7 OS. After some nail biting moments the "Repair process" showed up my existing OS in the list, thank God; before that I was thinking about installing all those softwares and drivers which is going eat my whole day.

  • After selecting my OS, I clicked Next which brought up a "System Recovery" window.

  • Under "System Recovery" window, I selected "Startup Repair" which kicked started the repair process. Finally it showed a message that the repair ws complete. When went through the log files, the last entry was "Fixed missing\corrupted boot loader". Yes that's what I was expecting. I restarted the machine and to my disbelief the system did boot into my OS. WOW that did brought a great relief to me.
I was using this repair wizard for the first time in life as never before I had a chance like this as most of the time, my system had crashed to the extent of where chances of recover were lame. But this time it was different, seems like I had started to play safe, at least for the repair wizard to get my system on track.

Installing SharePoint Server 2010

Hi folks, this time I thought of writing down my SharePoint 2010 Server installation experience, as for me it was a kind of Herculean task which took an entire day to get this thing up and running. During the installation process, I came to face lots and lots of glitches and hurdles that, at some point of time I was on the brink of giving up and thought of passing it on to some one who is good at it. But my instinct and passion pulled me from giving up and kept me trying until the result was achieved. For this, I did spend a whole long day and finally, I came to see light at the end of the tunnel, which I would say that, it was a moment of ecstasy filled with pride and joy on successfully completing on what ever I had started off with.

I will list down the steps and points, which I came to learn while installing SharePoint Server 2010. Following is a high level view of the steps involved, if you were to start from scratch.
  1. Windows Server 2008 R2 installation
  2. NIC Configuration, Domain Creation
  3. Installing features in Windows Server 2008 R2 using Server Manager
  4. Active Directory
  5. AD user creation
  6. Firewall configuration
  7. SQL Server 2005\2008 Installation and Configuration
  8. SharePoint Server 2010 Installation and configuration
  9. IE configuration 
  10. VS.NET 2010 Installation Professional
  11. Microsoft Office 2010 Professional Plus Installation
Before starting off with the installation, here's a couple of prerequisites\checks to be done.
  1. You need to have a system at least with the following hardware configuration or more.
    a) Dual Core with 2+ Ghz (Recommended Quad Core with 3 GHz)
    b) 6GB RAM (Recommended DDR3 8GB RAM)

    c) 500 GB HDD 7500 RPM (Recommended Solid State Drive, as this could dramatically improve the system performance.)

  2. Software requirements
    a) Make sure the software installations for Server OS, SQL Server are of 64-bit editions.(except for VS.NET 2010 and Office 2010).
    b) You need to have Windows Server 2008 SP2, in case if you are not having the Windows Server 2008 R2 release.
    c) You need to have SQL Server 2008 SP2, in case if you are not having the Windows Server 2008 R2 release.


  3. Download this document(from SharePoint-Tutorial.NET) and take a print of that or you could open a copy of this in a near by system or laptop to refer during installation. This is pretty good document which covers installation & configuration of Win2008 R2, SQL Server 2008 R2 and SharePoint Server. (I wished I had this document while I was installing SharePoint)
I had installed and configured all of the applications on a single workstation, while in the document, they are using two workstations one for SharePoint and the other for SQL Server. If you have the luxury of getting two workstations for your disposal then go for that, else no problem in installing both on the same server. The advantage with installing SQL Server on a different server will help you to gain some performance by offloading the SQL Services to another machine.


Lessons Learnt
  1. After installing SQL Server turn off all firewall policies and disable firewall.  Now try connecting to the database from SQL Server Management Studio, if the connection is established thank god, you had cleared one hurdle. For me, the firewall created a hell lot of problems while installing SharePoint. During installation, I was at the step where I had to fill in SQL Server end point details for creating the SharePoint configuration database. But what ever I do, SharePoint was reporting that it cannot connect\find to SQL Server.

  2. Make sure you install all of the following pre-requisite components before SharePoint 2010 Server  installation, else you will end up with "Correlation ID" errors, which is hard to track like what went wrong. The difficult thing with the following components are, at times these components are not packaged with SharePoint, instead you had to download all these yourself.
    a) ADOMD.NET
    b) DOTNET 3.5 SP1
    c) Microsoft Office 2010 Filter pack (64-bit)
    d) Microsoft Sync Framework v1.0 (x64)
    e) MSChart
    f) SpeechPlatformRuntime(x64)
    g) Windows Identity  Foundation

  3. Once all the installation and configuration is complete, apply the following settings in Internet Explorer. This will help you to pass the credentials of your choice instead of passing the credentials of the logged in username.
    a) Open IE
    b) Open Tools-> Internet Options
    c) Click "Security" tab.
    d) Select "Local Intranet" and click the button "Custom Level".
    e) In "Security Settings" dialog, scroll to the bottom where you will see a category named "User Authentication". There select the option "Prompt for username and password". Click "OK" and close the window.
    f) Now do the same for "Internet" and "Trusted Sites".

  4. In the document, the initial step itself they are mentioning to add you system to the domain, which itself is not going to work if you trying it on a personal system. The reason being, the steps to create and configure the AD(Active Directory) is not yet done.

  5. If you are trying SharePoint 2010 on your personal machine without being connected to any networks. Chances are that you will encounter a "TCP\IP Configuration" error while configuring AD. I got this resolved by connecting a network cable to the NIC. The NIC was configured with a static IP.
By the way after seeing this huge list of items, if you are a bit concerned like how to get all these softwares or doesn't feel confident to configure all this yourself, then here's a Virtual Machine(VM) image provided by Microsoft. This  is a Hyper-V image, which can be downloaded by clicking this link. You need to download all the files starting with "2010-7a" and the download itself is around 15 GB. The VM image is prepackaged and configured with all required softwares. 

A word of caution, if you planning to setup Hyper-V on a laptop, then I would recommend going through these links which does cover on how to get this done. Hyper-V on a Laptop (Part1, Part2, Part3)

In case if you come across more hurdles which wasn't mentioned over here, then please feel free to drop in a comment on that. I will be updating the article with your inputs and that too including your name.

Sunday, June 26, 2011

Elevator Pitch on SharePoint 2010

If you are a CIO, IT Consultant, Solutions Architect or any one who's involved in pre-sales or marketing, then definitely having a clear cut view on what SharePoint 2010 has to offer will help you to present the right set of solutions in Enterprise Collaboration Management, Record Management domain. Here's a smart way to get to know about SharePoint the easy way with "SharePoint Adoption Kit" from Microsoft which is packaged with some real time success stories and more. Definitely a must to read for the decision makers.

Creating Web Databases with Access Services

I had seen a pretty good number of start-ups and SME's using Microsoft Access for storing all kinds of data from managing clients list to sales lead. Microsoft Access solution's by and large in itself is quite suited for institutions of this scale. But as you know all business are started with the vision that it will grow by time. Once the business reaches a point where its starts to spread out to different geographical location's, then many of these solution aren't going to be stack up as they previously did. 

Suppose if you were told to migrate these Microsoft Access databases to SharePoint cloud (which seems a promising solution to SME's with limited IT budgets and infrastructure) then you could utilize the feature "Publish Access DB to web" which does get the Access DB in bi-directional sync mode with the SharePoint. Click here check out a video on how to get this going.

Lessons Learnt From Implementing SharePoint Word Automation Services

While implementing Word To PDF conversion in SharePoint 2010, I came across a whole lot of hurdles before getting the solution on track. I started off with an Event Receiver in VS.NET 2010, which hooks the "Item Being Added" event against the "Document Library". But once the solution was deployed nothing seems to be working as programmed. The document which was uploaded wasn't getting converted to PDF and the toughest part was that I could find a way to debug this solution. 

If you are new to "SharePoint Word Automation Services", let me give you a sneak preview of what it is all about. If you have worked with VBA, you might be aware of the fact that, implementing "Office Automation" requires Microsoft Office to be installed on the machine where the application is going to be deployed, without which the application is going to fail. In most cases no administrator will allow you to install Microsoft Office on a server and even if you some how get it installed, the server is going to doom because of the number of office application instances its going to create by the VBA application. Here's an article from Microsoft on this. So the crux with Microsoft Office is that, its only targeted for workstation\desktop segment and not for the server segment. Now the million dollar question is, how can a product like SharePoint survive without Microsoft office functionality at the server side. The answer to that is, Microsoft released a solution for this very problem under the name "Application Services" in SharePoint. Literally this means Microsoft exposed functionalities of all major Microsoft Office Applications like Word, Excel, Access, Visio, PowerPoint through libraries aka Office Server Object Model that could be referred by an application to create and manipulate the aforesaid office documents. The down side with "Application Services" is that, they aren't available as independent product, instead its packaged only with SharePoint Server versions. This doesn't mean that you need to purchase the expensive SharePoint Server for your application to generate Word or Excel documents at the server end, instead you could opt for commercial solutions like ASPOSE or SyncFusion which does the job of "Office Automation" pretty well.

That was a pretty big preview on what "Word Automation Services" were all about. Coming back to the point on how I came to learn the hard way, while trying to get the Word to PDF functionality on track. So here are the points.
  1. Make sure the "Microsoft Word Automation Services" are running by going to Central Admin -> Manage Services in this farm

  2. You need to refer the assembly "Microsoft.Office.Word.Server.dll" which can be found in "\ISAPI\Microsoft.Office.Word.Server.dll"

  3. Don't forget to set you application to 64-bit in project properties and the target framework as .NET 3.5

  4. While passing the path of the Word Document uploaded to the list
     
    objJob.AddFile(FileToConvert, PDFFilePath);you need to pass the absolute URL. I just passed the properties.AfterUrl  which did only contain the "/". Instead you had to build the absolute URL like this SPItemEventProperties.WebUrl (i.e. properties.WebUrl)

  5. When creating an instance of the ConverionJob class make sure you pass the "WordServiceApplicationProxy" text as seen in the Central Admin -> "Manage Services in the farm" page. Passing wrong name as the first parameter will cause to raise an exception "No Word Automation Service found".
    ConversionJob objJob = new ConversionJob("Word Automation Services", objJobSettings);

  6. Don't forget to assign the user token. The assigned user token should have access to the documents in the list.
    objJob.UserToken = objWeb.CurrentUser.UserToken;

  7. Lastly I was expecting the PDF document to show up in the document library immediately after adding\uploading the word document to the document library, but the PDF didn't show up even after waiting for a few minutes. The reason being, the code  objJob.Start(); doesn't mean that the document will get converted immediately after executing the code, instead the job of DOC to PDF will be added to queue which will be eventually processed. The Word Automation Services will be called every 15 minutes by the scheduler, so by that time only you will see the PDF. If you want to get the output immediatelythen you could go to the central admin, select "Job Status" find the text "Word Automation Services", click open the job and click the button "Run Now". Now you should be able to see the output within a few seconds say 10 or 20.

  8. Finally the most embarrassing situation I faced, after deploying the EventReceiver solution was on, how to debug the code. After putting my thoughts on how I solved similar situations in past, the solution that crossed my mind was the following code snippet. I immediately updated the code with the following line as the first statement in the event, after which I build and deployed the code.  
    Debugger.Break();

    Now after uploading the word document, a message box showed up with the text "Unhandled exception in w3wp.exe do you want to debug?" I clicked yes and now the debugger kicked in and selected the name of the already open EventReceiver project and finally I am inside VS.NET with control(yellow highlighting) at the Debugger.Break() statement. Yes the old trick did work. Previously I had used this statement in some of my console applications to get the debugger attached at run-time. So thankfully it helped me to debug my EventReceiver project.

Saturday, June 25, 2011

Converting Word to PDF on SharePoint Server 2010 with Word Services

Today I came across an How-to video on SharePoint 2010 Word Automation Services. In the session the host was giving a demo on how to convert a word document to PDF, which was added\uploaded to a document library. The demo utilizes Event Receiver to get this done. You can view the complete video here on Bing videos.

Open Source Video Players for Web

Longtime back a requirement came up, where I had to integrate video playback functionality in a webpage. The requirements specifically mentioned that it should be platform agnostic. Initially I thought of using Silverlight to get this done; but the downside of using Silverlight was that, it wasn't supporting Linux platform which breaks platform agnostic requirement. 


After some search I ended up with a handful of options which included Flash player and HTML5 Video Playback as well. Fortunately the video formats which I had to handle were all MPEG-4, which was supported by most popular web video players including Silverlight, Flash and HTML5. Finally I decided to go for an hybrid solution which works based on the following logic. 

If the browser supports HTML5 then the "Video" tag was used to playback the video, If not use Adobe Flash player, else use the Silverlight. If the browser didn't support any of those, the user is alerted to upgrade to a latest browser version or to install any of the supported players.

Here are some of the video players I came to stumble upon while working on this requirement.

Open Video Player - A fully open source video player and the best player I had ever seen and the best part is that its freeware. The player comes with a  pretty good number of options for you to choose from, like HTML 5 Video, Silverlight, Flash and iOS (Apple platform).

Flow Player - An Open source video player based on Adobe Flash. A free version is available under the GPL license. The free version even allows commercial use at the time of writing. The only downside is that, it displays their branding logo at the beginning of video playback, which isn't that obstructive to the viewer. If you are concerned about the branding logo at start of every clip, then there's a commercial version as well which is free from all these. Moreover the commercial version allows you to put your own branding logo in there.

JW Player - An open Source video player based on Adobe Flash. Display's branding text on to the left bottom side at the beginning of the video, after a while it disappears. The Pro version has even lot many options but will cost you some bucks. The restricting factor is the licensing terms on using the player on commercial sites.

Thursday, June 23, 2011

Avoid Caching Issues While Development

Browser caching can become a nightmare when developing web applications, as most of the changes what we make in the code may not get reflected at the browser end, which might end up missing the set time frame for that specific task; the reason being caching of contents at the browser level or at the proxy level. 

The problem with browser caching can be sorted out through use of a new feature built-in to modern browsers known "InPrivate Browsing" (in IE) and "Incognito window" (in Chrome). The feature presents you with a session (a new window) which is completely free from all sorts of saved cookie info and content cache. The beauty of this mode is that, what ever browsing you do here wont even leave a trace of those activities in the browser history nor in the cookie container or in the browser cache. 

If you had done Ribbon UI development in SharePoint 2010 before, then definitely you must have faced the dilemma of caching, as what ever changes you made to the Ribbon bar won't get reflected at the browser end as the XML required to render the Ribbon UI is cached. Myself being faced with the dilemma of caching with other development tasks and now in SharePoint, I had decided to go for the aforesaid "Isolated Mode" (as I wish to call it) as its going to eliminate the issues associated with web browser caching.

So next time don't forget to utilize this pretty cool feature packaged with almost all browsers available out there in the net.

Wednesday, June 22, 2011

Installing SharePoint 2010 on Window 7 64-bit

With the release of SharePoint 2010 the good news is that, for development one can develop SharePoint solutions on a Client OS like Windows 7 (64-bit) instead of using a Server OS like Windows Server 2008 (64-bit). With this corporations can save on licensing costs by tapping in existing investments made for client operating systems like Windows 7 or Windows Vista. But this was not the case with SharePoint 2007, which required a server OS like Windows Server 2003 to get it running even for development, though there were some hacks to get MOSS running on a client OS like vista, it wasn't adopted by the development community at large, because of fear of issues\conflicts which might crop up at a later time.

Hearing this I tried to get SP 2010 installed on to my Windows 7 which failed in the first step itself, so if you are among the many developers or System Admin's who received the following error "Setup is unable to proceed due to the following error(s): This product requires Windows Server 2008 Service Pack 2 or above. Correct the issue(s) listed above and re-run setup." while trying to install SharePoint 2010 on Windows 7 (64-bit), then here's an elegant solution by Sandrino Di Mattia, who had posted an excellent article on how to tide over this error.


The reason behind this error is due to the fact that, SharePoint 2010 on production environments is always supposed to be run on Windows Server 2008 (64-bit).

Monday, June 20, 2011

Nexus between State Service and Chart Web Part in SharePoint 2010

While trying to display a simple bar chart in SharePoint 2010 from data contained in a Sales list, I ended up with the following error "The chart cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator."

If you are new to charts in SharePoint 2010 then no need to concern, as much of the overhead of is taken care of by SharePoint itself. For the developer its all about adding a "Chart Web Part" to  a page and assigning properties like linking to data source, selecting the chart of your choice and setting the appropriate titles and legends, that's it. Once you are done with all those properties, you will see the chart beautifully rendered on your page. The only drawback I came to find with inbuilt charts are that  they aren't that interactive when compared with a Silverlight charts, where with the later one could rotate, drill down, click certain portions to view more details and moreover a some rich 3D rendering like that. The built-in SharePoint Chart fits the bill for most usual business requirements.

Searching for the Service:
So coming back to the error which I was talking about. From the error message what I could infer was that "SharePoint State Service" wasn't available or running. I started to lookup for this service under Windows Services (services.msc) but didn't find any. Next I moved on to "SharePoint Central Admin"  where I navigated to "Application Management -> Manage Service Applications" there too the service wasn't listed. So seems like the service wasn't installed during farm configuration phase. 

Solution:
Now we are going to install the "State Service" (which itself is a Service Application in SP2010). 
  1. For this navigate to "SharePoint Central Admin -> Configuration Wizards -> Launch the Farm Configuration Wizard -> Click 'Start the Wizard' ". In next screen uncheck all the services except "State Service" (Note: Before unchecking other services, make sure you are not using any of those services in your project(s). Leaving every services checked, will make your SharePoint server crawl, running all of these services in a single server will consume more CPU cycles and memory. Normally in a production environment, each of these services will be running in different servers so as to offload the overhead from the WFE(Web Front End) SharePoint server.)
  2. Click OK and browse back to Central Admin (no need to continue with a new site creation).
  3. In the Central Admin page select "System Settings -> Manage Services on this Server" and search for the Service Application with named "State Service" and click the "Next" button , after which the status should be shown as "Started".
This error will show up not only for charts, but also when  trying to publish a page in SharePoint 2010. So going back to the page where I had placed the Chart Web Part. Hurray the chart was rendered as expected without any errors.  

Breeze through SQL Server Management Studio

If you are among the many developers who frequently use SQL Server Management Studio for tasks like writing Stored Proc's, complex queries, views etc, then definitely you will find yourself writing SELECT statements to get a view of data inside tables and views. The next possible statement you might frequently use should be the sp_helptext to view definitions of   user-defined rules,  unencrypted Transact-SQL stored procedures, user-defined Transact-SQL functions, triggers, computed columns, CHECK constraints, views etc.

A small analysis on the count of SELECT or sp_helptext statements issued to view the data or the schema of an Stored Proc\View. I came to find that on an average it was around  30 plus. I got this from SQL Profiler after excluding those statements issued from my application. Before I came to find a solution for this, I kept a copy of frequently used functions so as to copy and paste whenever I need any of those, that's how I was doing before embracing this cool elegant solution. 


I would call myself a lazy programmer, yes you read it right "A lazy programmer, but definitely not a lousy one". Being lazy, I always wanted to get more from little. So from a developer point of view this means, more productivity\output from less keystrokes and writing scripts for those little repetitive tasks like changing IE proxy, Hibernating\Shutting down windows, enabling USB ports (hope you know where this specifically applies to), Recovering  crashed desktops and the list goes on and on.

Here I am going to pull yourself into my lazy programmer band wagon(i.e. more productivity from less keystrokes) while working with SQL Server Management Studio. Before moving on, have you ever used the shortcut "Alt + F1" to view metadata for the selected table name? If yes, you had knowingly or unknowingly used the feature on what we are about to explore.


The solutions I am about to show you are in-built to the editor, so no need to worry about shelling out your  hard earned money nor impress your manager for getting budget allocation to get those new tools. Here you will see a pretty awesome feature called "Keyboard shortcuts" built-in with SQL Server Management studio to get this done. So lets move on to the solution part. 

Fire up your "SQL Server Management Studio" and select "Tools -> Options" from the menu.


In the "Options" widow select Environment then select "Keyboard" which should get you to a screen something like the one below(BTW I am using SQL Server 2008 R2). Here you could find three predefined shortcuts already assigned for the key combinations like Alt+F1, Ctrl+1 and Ctrl+2 this means all those three shortcuts are already taken out by MSFT guys, but we still have a lot many key combinations left out there with ready to occupy boards hanging all over them (that means, those shortcuts with no text in the second column).


Lets start filling up those unoccupied slots with our own set of SQL arsenals. To get the job done, you need to copy the statements(highlighted in green) excluding the quotes to the second column (named Stored Procedure).


Ctrl + 3  'SELECT * FROM ' (make sure there's a single space after the FROM keyword and no quotes before and after)


Ctrl + 4 'sp_helptext  (make sure there's a single space after the FROM keyword and no quotes before and after)

Click "OK" button and exit the editor. 


Now its time to see those new shortcuts in action. 
  1. Fire up the SQL Server Mgmt Studio and open a new query window. 
  2. In the toolbar change to the database of your choice. 
  3. Key in a table name to the query window and select(highlight by selecting the table name) the table name you had just entered.
  4. Press the key combination Ctrl + 3 and you should see all the records in that table getting listed in the results window. If any errors are there make sure you had put a space after the "FROM" keyword and no quotes before and after while entering in the keyboard shortcuts window.
  5. So we had successfully saved ourselves from repeatedly typing "SELECT * FROM" each time to view records inside a table.
  6. Next we will try out the other key combination Ctrl + 4. For this enter a stored proc name to the query window and select the SP name and press Ctrl + 4. You should be seeing the body of the SP, i.e SP definition including parameters and all the t-sql code contained in the SP. In case if the output is displayed in a datagrid(which is the default behavior), you can switch to text view by pressing Ctrl + T and re-issuing the Ctrl+4 shortcut. This time you should be seeing the output like in a text editor. To switch back to grid view press Ctrl +D
So I am leaving out the other shortcuts for you to fill in with the most common statements of your choice. So next time onwards the new keyboard shortcuts should do all the magic for you without the need to keyin SELECT or sp_helptext statements and also start getting used to the  Lazy Programmer experience.  


Tuesday, June 14, 2011

Things To Look Out For While Developing SharePoint 2010 Server Applications

As part of mastering SharePoint Server 2010, I was trying out a simple console application which utilize's SharePoint Server side API's to communicate with SharePoint Server 2010. The console application which I was developing was programmed to fetch all the Lists in a given site collection and display their names(Titles), a pretty simple app.

For this I created a new console application in VS.NET 2010 by selecting ".NET Framework 3.5" from the drop down located in "New Project" window.




After which I added a reference to "Microsoft.Sharepoint.dll", which can be found under ".NET" tab of "Add Reference" window(to get here right-clicking "References" folder in solution explorer and select 'Add Reference' from the context menu).

Thereafter I updated the "Main" method with the following code, which does fetch all the SharePoint Lists in the default site collection available under "http://SP2010" (this URL refers to my default SharePoint site collection on my machine)

string SiteURL = "http://sp2010";

using (SPSite myspsitecollection = new SPSite(SiteURL))
{
  using (SPWeb mySPSite = myspsitecollection.RootWeb)
  {
    Console.WriteLine(mySPSite.Title);
    foreach (SPList list in mySPSite.Lists)
    {
       Console.WriteLine(list.Title);
    }
  }
}

The compilation went well without any glitches. The moment I ran this application, I got an error message stating that, the console app couldn't find the site. The exact error message was "The Web application at http://sp2010 could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application". 


I was wondering why on earth my console application can't find this site. At the same time all other apps like SharePoint Designer and SM2 (SharePoint Manager 2, a third party utility) all of which were able to successfully connect to my site from the same machine. It was really embarrassing situation trying to troubleshoot like, why only my application wasn't able to establish the link. To get my console app on track, I tried disabling  the firewall and IDS, rechecked the code, installed Fiddler to monitor the requests to the web server etc, but nothing turned out to be providing hint of any sort to the root cause of this scary bug. As last resort I thought of searching for this error on the internet. After going through a couple of links, I came to hit the bulls-eye, finally got the culprit.

Solution:
The error was because of a default setting in VS.NET 2010. Whenever you create a new project in VS.NET 2010 the project by default sets the "Target Platform" to x86. So if you are developing Sharepoint Server side solutions, always make sure that you set the "Platform Target" value to "x64", else you will be getting weird errors, like the one I got. After updating my  console applications "Platform Target" to x64 things went smoothly as expected, listing out the titles of all the Lists in the given SharePoint site collection.



So to summarize; while developing server side apps for SharePoint 2010 make sure you follow these steps without fail.
  1. Always select ".NET Framework 3.5" from the drop down while creating new project. This applies to both Server Site app and Client side apps.
  2. Update the "Platform Target" value to x64, as SharePoint 2010 is 64-bit product.
  3. Refer "Microsoft.SharePoint.dll"
  4. Make sure you are able to connect to the Sharepoint site by specifying the url in Sharepoint Designer. If not make sure that no firewall policies are preventing you from connecting to sharepoint server.
  5. Your application will be running under the same login credentials with which you had logged into the system.



Happy SharePoint development.

Monday, June 13, 2011

How to secure your personal computer

Having heard this query countless number of times from my friends and colleagues, usually these queries pops up only whenever their systems gets infected or when they detects some unusual activity in the system. I thought of documenting the process which usually I follow to keep my system secure. I would also like to mention two principles before moving on to the solution part.

Principle 1: Truth to be told on fundamental aspect of every security system developed by the human race is that, there no such thing as 100% secure or fool proof product\solution. Whenever you hear about a highly sophisticated secure product or solution, it merely means that, those who designed\developed had made the product\solution rugged enough so that, it takes a considerable amount of Skill(Knowledge), Infrastructure, Time, Money and patience to punch a hole in whatever they had come up with. So this doesn't mean that one should avoid security products\solutions at all. Security solutions\products will always evolve and fortify itself from whatever they had learnt from the past. My advice is, while choosing or implementing products and solutions first asses how sensitive is the core system you are planning to secure is. Most of the time you will be find yourself implementing a layered security approach with security products\solutions are different levels.

Principle 2: How to secure you personal computer economically. Yes you read it right "economically". The term "economically" is significant in the context of securing personal computers, as I had seen corporate workstations and laptops fortified with all sort of expensive intrusion detection systems, firewalls, software updates to protect from known virus and vulnerabilities (even then I had seen systems going down or infected, which  is a different story). If you do a simple analysis on how much a person invests in terms of money or time to secure his\her personal computer, you will find it at zero in most of the cases. No one ever wants to spend money on security, but whenever their system gets compromised because of virus or backdoor attacks chances are, they might loose all the valuable data or the data might fall into the wrong hands, which is going to keep you running from pillar to post from law enforcement agencies to banks et al. In worst case scenario you even might not be aware of, that your system was compromised, which could put yourself into much bigger trouble.


Lets start off with securing your personal computer. Before moving on, make sure you meet the following prerequisites.
  1. You are using Microsoft windows XP or above (Vista, Win7).
  2. You have an internet connection (optional)
  3. You have administrator privileges and physical access to your machine.
  4. Never try this steps on your corporate machine, as it may violate your company IT policy.
Here we go:
  1. Never login to you system as an administrator(or a user with admin privileges), unless there is  something that specifically demands you to login with administrator privilege. Never think of this for tasks like installation\un-installation of applications or starting\stopping services etc, all these could be accomplished without logging in as administrator. Here's how
    1. Installing Apps - Right-click the setup file and select "Run as" from the context menu. Provide the administrator username and password to start the installation.
    2. Un-Installaing Apps - Go to system32 folder(type "system32" in you Run dialog), find the file named "Appwiz.cpl". Right-click the file and select "Run as" from the context menu, provide admin username and password.
    3. Start\Stop Service (WinXP) - Go to system32 folder, search for the file named "mmc.exe". Right-click the file and select "Run as" then provide the admin username and password. Once the MMC window opens up, select File->Open from the menu and look for the file name "services.msc" (located in system32 folder)
    4. Start\Stop Service (Vista\Win7) - Go to system32 folder, search for the file named "services.msc". Right-click the file and select "Run as" then provide the admin username and password. 
    5. Run a custom executable under admin privilege - Right-click the executable and select "Run as" then provide the admin username and password.
  2. Always create a normal user account and use this account to login for executing your day to day tasks like browsing, emailing, office apps etc. This helps to limit or nullify virus\worms from infecting, spreading or altering your system and files.
There is still lot many steps to be included, to get your system secure. I will be updating this article when time allows.