this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...

Tuesday, December 18, 2012

Windows 8 application development requirement


Since launching of Windows RT model, in internet we see buzz of Windows 8 application development. Before developing any application it is very important for creating it’s development environment.

Many times during my professional discussion we came to situation of what’s software requirement for developing any Windows 8 based application?

Below are must things for developing windows 8 application.
·         Windows 8 OS, you can’t create application on any other OS (i.e windows 7).
·         Visual Studio 2012, you can develop your application in Visual studio’s latest version. There are few choice you can have , which version you are using of IDE (i.e express, professional, enterprise, ultimate etc)
·         Developer account, for developing any windows application it asks for your developer account. You need to specify your live id (i.e hotmail, live, msn, outlook) credential and system will do rest of things for you.
·         For developing Windows mobile 8, you will need to install Windows phone 8 SDK explicitly. It does not come along with your Visual studio installation.

Hope, this check list will help you building up your development environment.
Happy Windows 8 app development!!

Best of luck!



Monday, October 1, 2012

Add Event/Appointment in Google Calendar with Google account credential.


Google calendar is one of the best free tool for tracking your day to day appointment and reminder for your rest of schedule. There are facilities for reminder with email and sms that will enable you for preparing your next meeting/appointment.
We can leverage this tool in our any of application, we can sync our event or appointment with google calendar so one may miss reminder from application but alternatively get from google calendar.
Doesn’t it seem cool? Even implementation is simpler than it seem.
Firstly, you will need to add reference of following files.

using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Calendar;

You can find those files here.

Below is code block for adding event in google calendar.

public CalendarService GetService(string applicationName, string userName, string password)
        {
            CalendarService service = new CalendarService(applicationName);
            service.setUserCredentials(userName, password);
            return service;
        }

public static void AddEvent(CalendarService service, string title, string contents, string location, DateTime startTime, DateTime endTime)
        {
            Google.GData.Calendar.EventEntry entry = new Google.GData.Calendar.EventEntry();

            // Set the title
            entry.Title.Text = title;

            //Set event details.
            entry.Content.Content = contents;

            // Set a location for the event.
            Where eventLocation = new Where();
            eventLocation.ValueString = location;
            entry.Locations.Add(eventLocation);

            //Set starting time and end time for the event.
            When eventTime = new When(startTime, endTime);
            entry.Times.Add(eventTime);

            Uri postUri = new Uri("https://www.google.com/calendar/feeds/aslam.h.net@gmail.com/private/full");

            // Send the request and receive the response:
            AtomEntry insertedEntry = service.Insert(postUri, entry);
        }

Here, GetService method will take three parameters named application name, username and password.
Application name can be any name, you wish. Username is your google account name where you have configured your calendar and wish to sync with that calendar. Password is your google account password.
Method will return back calendar service object. We can use this service object anywhere for using any service associated with calendar.

Method AddEvent: this method will add event in any our calendar. Most of statements are formatted with comments.
There is one critical statement you need to take care.

Uri postUri = new Uri("https://www.google.com/calendar/feeds/shailesh@gmail.com/private/full");


Please note that one dynamic part, shailesh@gmail.com. It’s my calendar’s id. You can easily find your sync calendar id with following steps.

1)      Logon to your gmail account and click on calendar link at top bar, it will open up your calendar in new tab.
2)      On the right side, there will be section named “My Calendars”. It lists out calendars, you created. You can create more than one calendar in google calendar tool.
3)      Go to any of calendar, click on the arrow. It will show one menu. Click on “Calendar settings”.
4)      There will be one row with “Calendar Address”, most probably before last row. Just look around this row, there will be information like this.
(Calendar ID: shailesh @gmail.com)
This is the address for your calendar. No one can use this link unless you have made your calendar public

That’s it.

I hope this will enable to sync your important tasks, appointment and meeting with google calendar.

Happy scheduling appointment

Friday, September 7, 2012

Html.RenderPartial() Sytanx Error : No overload for method 'Write' takes 0 arguments

Hey Everyone,

I was trying Html.RenderPartial() in Asp.net MVC and what I got “No overload for method 'Write' takes 0 arguments“

From my code it seems very clear that I have written correct syntax but actually there is a little problem with it.

My earlier code was is as below

@foreach (var p in Model.Members)

{

@{ Html.RenderPartial("MemberSummary",m); }

}

But it was giving me Error : “No overload for method 'Write' takes 0 arguments”. As we all know RenderPartial() directly writes in the output stream so it was better for using it than Partial().

After close look inside of code, I found that it should be C# statement and I was mixing inside of code block and I corrected out my code as below. It worked.

@foreach (var p in Model.Members)

{

Html.RenderPartial("MemberSummary", m);

}

Have a happy debugging !!

Monday, July 30, 2012

Windows Mobile 7.5 on my view.

Before few days ago I got chance to play with Windows mobile 7.5. I heard a lot about it but unfortunately I didn’t get chance to work around. At first glance I was really impressed with it’s graphical user interface and its screen layout. Now nobody would criticize Microsoft mobile os for looking around this.
I must admit os is not just fancy at look but Microsoft has invested big in making its very responsive. It was much faster than android phone I have used. I was astonished with its simple user interface and for operating it, one would not be necessary tech-savy. It is targeted for any of the no-voice user who is wishing furnished, easy to use smart phone.

End User Experience
From the end user perspective, it’s very nice MS phone so far. Who ever used earlier version of windows would be surprised with its easy layout and graphics. I am sure end user would love operating system and its user experience. They will find it powerful, business smart phone. It includes all necessary app for business needs and also has some fun application inbuilt. One would not feel it less useful for both business and fun.
Early Microsoft phone was mostly used by business user and even its operating way was also somewhat tricky. But in case of 7.5, all limitations are over come.

Developer Experience
Earlier version development was very similar to that of windows forms development in .net framework. But in case of 7.5, it has been changed from very basic. Now, developer has facility for developing high end user graphics application. Development and design is on XAML. If one had worked with earlier version, they would need upgrade themselves for this new development.

Market Perspective
Now a day’s most of site, online buying and banking is booming and they provide their facility in mobile native platform. One is already aware about android and ios app market. In both of platform you would find lots of free and paid version application. Some of them are targeting business need and some of them are for entertainment. Definitely windows platform has very less application compared to other platforms due to recent changes in development. One would invest for developing windows apps by considering future growth. There will be definitely users who are looking for great application as they have in other platform.
Future of windows mobile 7.5

Microsoft is going to launch new os Windows 8. Around the net it has created buzz and now almost all will be upgrade to new os Windows 8. There are so many discussions around it. Microsoft is going on something different way than earlier now they want to line up their os with all devices. Certainly it will take some time for moving in Windows 8, at least for 2 year it will not be. One could say that they can use windows mobile 7.5 and then they will be continuing using it. Critical part of adopting windows mobile 7.5 is that it will not be upgraded to windows 8. Alternatively at some way Microsoft has indicated, they may come up with windows mobile 7.8 and it will be very near to windows 8.

Right now, windows mobile is taking market share from other OS and only constraint people are feeling to adopt is to have lack of application available compared to other platform. That will be huge advantage for entrepreneur for creating apps on windows mobile platform. Microsoft would also take steps for making its app store rich.

Let’s hope at least tech people would use Windows mobile as they use other smart phone.

Monday, July 2, 2012

Green field / Brown field development

In software development we are usually have two types of work to be done in any application. Both some legacy system is already running and we should require build on new system on it or build new system from very scratch.

When we are going to build new system without considering any of the old system and it does not connect with any other system such type of development referred as Green Field development

In contrast some system does not require depending on any other system, we can go ahead with development from scratch, we don’t rely on any other system such type of development referred as Brown Field Development.

Both type of development have their advantage and disadvantage on development.

Green Field:

Advantage

We have more control at the time of development,

We don’t rely on sub system.

We are free to stretch system as we need

Disadvantage

No reference is available, new system should build carefully meet all requirement of business.

Brown Field:

Advantage

Have reference of already running system

Can take advantage of existing data for future expansion

Can leverage system incorporate with new System.

Disadvantage

Hard to implement programming semantics at some level due to bound with old system.

We do many application but we might not know what type of development we do? Hope this will help us identifying our development.

Wednesday, June 6, 2012

Print button is not working in Crystal report viewer


Crystal report is very crucial part of LOB application reporting. Most of enterprise uses Crystal Report for the reporting purpose. In case of windows platform, it has good integration with .net framework and .net provides crystal report viewer for rendering Crystal report.

From the early, VS 2005 has inbuilt integration with Crystal report version 10. We don’t need to install other component for accessing Crystal Report Viewer. It was straight forward process, for running that application on client machine we all need is installing Crystal Report runtime.

It was going good and we didn’t come across any issues till date. Some older applications were built on VS 2005 and it was running in most of windows operating system with runtime and necessary component installed. Problem arose with 64bit version, when we try to install application built on VS 2005 and using crystal report on Win 7 64bit or other later version of 64bit. In that case, we don’t able to take advantage of printing facility of Crystal report viewer.

After investigating, we found that there was problem with crystal report version10. If we upgrade our crystal report version to later on, it would work and it did.

We choose path of upgrading our solution to VS 2010, and what we found that we didn’t see any Crystal Report viewer in toolbox. It requires installed explicitly, Microsoft stops to ship that along with VS 2010.

I hope below link is worth to keep with us while upgrading to vs2010 for Crystal Report .


Hope this post will be helpful!

Tuesday, June 5, 2012

Change default time out of strongly typed dataset table adapter command.


By default when every any command executed by table adapter, its time out is 30 second. Due to heavy load of data and traffic over the network, we require increasing this default time out.
It’s very straight forward when we use code for it. In case of strongly data set it’s a bit tricky.
Firstly, you will require extending your dataset existing name space and its table adapter. In data table adapter class, you can add one method for changing this time out.
//Extend existing data table adapter class created by strongly typed dataset.
Namespace MyTableAdapters
Partial Public Class MyTableAdapter

Public Sub SetCustomCommandTimeout()
Utility.SetCommandTimeout(CommandCollection)
End Sub

End Class
End Namespace
//Set Custom Timeout to underlying command.
Public Shared Sub SetCommandTimeout(ByVal commands As System.Data.SqlClient.SqlCommand(), Optional ByVal timeout As Integer = -1)

If (commands IsNot Nothing) Then

If (timeout < 0) Then timeout = GetConfigTimeout()

For Each cmd As System.Data.SqlClient.SqlCommand In commands
cmd.CommandTimeout = timeout
Next

End If

End Sub

//Get Custom time out from web.config.

Private Shared Function GetConfigTimeout() As Integer

Dim timeOut As Integer
If Not System.Configuration.ConfigurationManager.AppSettings("CommandExecutionTimeOut") Is Nothing Then
timeOut = CType(System.Configuration.ConfigurationManager.AppSettings("CommandExecutionTimeOut"), Integer)
Else
timeOut = 0
End If

Return timeOut

End Function

Hope this would be very helpful !!

Tuesday, May 1, 2012

Do not serialize public property or field in a class


There could be some situation where one have some properties and fields defined in the class. Most of time property are exposed as public and they can be easily accessed by object of class.

During the data transfer serialization of objects happens and at that time we have all the public fields and property contained in the class.

Some situation has special needs to prevent serializing public property or fields. Below code snippent shows how to handle such situation.

[XmlIgnoreAttribute]
        public bool IsActive
        {
            get { return this.mIsActive; }
            set { this.mIsActive = value; }
        }

Have happy coding!!

Wednesday, February 22, 2012

Programmatically create folder in SharePoint Document library with client object model

SharePoint 2010 has very strong client object library, with the help of client object model we can almost interact with all document related functionality from our application and can interact with SharePoint 2010.

Below is some code snippet for creating new folder in the SharePoint Document Library.

public bool CreateSPFolder(string libname, string correspondance)

{

bool bolReturn = false;

ClientContext ctx = this.GetSPClientContext();

Web web = ctx.Web;

List documentLib = ctx.Web.Lists.GetByTitle(libname);

string targetFolderUrl = libname + "/" + correspondance;

Folder folder = web.GetFolderByServerRelativeUrl(targetFolderUrl);

ctx.Load(folder);

bool exists = false;

try

{

ctx.ExecuteQuery();

exists = true;

}

catch (Exception ex)

{

bolReturn = false;

}

if (!exists)

{

ContentTypeCollection listContentTypes = documentLib.ContentTypes;

ctx.Load(listContentTypes, types => types.Include

(type => type.Id, type => type.Name,

type => type.Parent));

var result = ctx.LoadQuery(listContentTypes.Where

(c => c.Name == "Folder"));

ctx.ExecuteQuery();

ContentType folderContentType = result.FirstOrDefault();

ListItemCreationInformation newItemInfo = new ListItemCreationInformation();

newItemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;

newItemInfo.LeafName = correspondance;

ListItem newListItem = documentLib.AddItem(newItemInfo);

newListItem["ContentTypeId"] = folderContentType.Id.ToString();

newListItem["Title"] = correspondance;

newListItem.Update();

ctx.Load(documentLib);

ctx.ExecuteQuery();

bolReturn = true;

}

return bolReturn;

}

Monday, January 23, 2012

Fix issue HTTP/1.1 200 OK Server: Microsoft-IIS/7.5 Error with a SharePoint 2010 Web Application

Generally, such error comes when we try to browse web-application url. There could be many problems around this problem and depends on it there are different solution for it.

First most common issue around this is that, web application does not contain any site collection at web application root level url, to resolve this you can create site collection from central admin ->Application Management ->Create Site Collection. During creation of site collection, please select your web application where you would like to create.

Second scenario, if you have already site collection created and still this problem occurs. To overcome such problem you have choice to restart IIS, reattach your content database, check services on your pc whether “work station” service is started.

Hope this will help!!

Thursday, January 12, 2012

Prerequisites could not be found for bootstrapping (while upgrading from VS 2005, 2008 to VS 2010)

Latest IDE by Microsoft for .net application is VS 2010. Most of applications are upgraded to newer version of IDE, some are in the process and some are already done. The thing create problem during upgrade is that most of time targeted framework does not change, it just refer older version.

When you try to add prerequisites, you will be surprised that it will not find your older version any more. Many forums said that Microsoft has disabled it and you need to upgrade to higher version of prerequisites.

You can see that in the given below images that shows unavailability.


To resolve this issue you need to copy boots trapper files.

Older version of VS files can be found at

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages

You need to copy files from above location to below location and once you copy required folders, you will be able to access those in prerequisites.

C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages

Cheers!!

Wednesday, January 11, 2012

Adding Footer to SharePoint 2010 Custom Master Page

When you are going to develop custom layout of your SharePoint site, it could be requirement of having footer in the page. V4 master page does not contain any options to set footer in page.

You need to add footer manually to your custom master page.

If you check your master page you will find below line

Just above that line you can add your custom footer section as below sample markup.

Copyright © 2012 Company. All Rights Reserved.

Style for above div

*Customized foooter */

#s4-customfooter{

clear: both;

padding: 10px;

color: #ffffff;

background-color: #4F5E85;

}

Hope this will help!!

Thursday, January 5, 2012

The Project Item "module1" cannot be deployed through a Feature with Farm Scope

You might have faced such error sometime during your deployment of SharePoint projects. Usually this error comes due to lack of availability of particular item in the scope. You have limited items that can be deployed in the scope of web, site, web application and farm level.

Microsoft has prepared a very nice article to list out it. You can check out here

Monday, December 26, 2011

OOB: Change master page from SharePoint 2010

Most of time we don’t prefer to use conventional user interface provided by SharePoint when we configure it. We want our separate identity when we try to publish our site on base of SharePoint framework.

When you try to find out Changing of master page in your SharePoint, you may not get that options in your Site Settings, first you need to do is to Enable “SharePoint Server Publishing Features”.

To enable above features follow below steps..

Go to Site SettingsàSite Collection Administration à Site Collection Features à Activate SharePoint Server Publishing Features.

Now you may able to see Master pages menu in the Site setting under Look and Feel depends on the version you have installed on your machine.

Alternatively you can directly go to change master page with _layouts/ChangeSiteMasterPage.aspx , just add below url with your site and you will be redirected to change master page for your site.

How to get public key token for my dll or exe?

Sometime we need to find our dll or exe’s public token when we have strongly signed out. There is a very nice tool given by .net is sn.exe

Just go to command prompt of visual studio, and type following command. Here please note that you need to set your application folder path where your dll or exe assembly is stored.

Sn – T abc.dll

This will give us public token of abc.dll like below message

Public key token is c8903c1b3f99ec16

Wednesday, December 14, 2011

Install SharePoint 2010 on windows 7 64 bit

Most of time in case of development It would require to install sharepoint on the non-server os, As we know sharepoint 2010 can only be installed on the 64bit operating system. Now we have one choice to create environment on the Windows 7 64bit os.

If we don’t dig more on it, we have choice to install as standalone sharepoint but instead of that we would like to have sharepoint farm configuration and we don’t wish to install SQL express by Sharepoint installation but we have our own SQL server then?

Also to enable installation on Windows 7, we require changing in configuration file and that is to add one setting for it.

Below things require to add at ..\files\Setup\Config.xml

If you don’t add above setting, setup will give you error and you won’t be go further.

Next thing for using your own SQL server installation is to create Sharepoint Configuration database and that can be done with help of Powershell command named SP-NewConfiguationDatabase

Once you use above command in the powershell you will be asked to enter required details for your server and database creation.

To use above command please note that, you are going to use your windows user in it, so you need to give full qualified name.

Like mypc\user, if you don’t give full name it will give you error.

Reference:

http://msdn.microsoft.com/en-us/library/ee554869.aspx -for Installing Sharepoint

http://technet.microsoft.com/en-us/library/ff607838.aspx -for configuration database creation.

http://spdeveloper.net/2010/06/errors-when-installing-sharepoint-2010-in-windows-7-development-environment/ --for possible error we could have in creating configuration database.

Wednesday, November 30, 2011

How to Resolve Activate disabled Sandbox solution in SharePoint 2010

This problem mainly occurs when you start to develop sandbox solution and upload you solution to fresh SharePoint farm, if you have already developed some sandbox solution and some admin is maintaining SharePoint farm, you may never come to such problem.

Situation was, I was able to add solution to my site and I was also able to see SharePoint WSP and all was looking great, but when I was going to activate it, it didn’t seem to work and it was showing me user right tooltip, which usually comes up when we have not enough permission to access anything.





I wonder about my permission and I doubled check my permission but there was not an issue, then after checking about other problem if there could be.. but nothing was there.

After google, I found that there was issue of service named “Microsoft SharePoint Foundation Sandboxed Code Service” required to start prior to activating any sandboxed solution. This service can be activated from Central admin ->System Settings ->Server -> Manage Service on Server-> Start Service Microsoft SharePoint Foundation Sandboxed Code Service start

Reference: I found that useful information here

Connected WebParts in SharePoint 2010

SharePoint has very cool features of connected Web Parts, It simply means that two different web parts are connected and they can share data between them.

In Connected Web Parts there are basically two things required at least, one is Consumer Web Parts and Provider Web Parts. Consumer Web Parts gets data from Provider Web Parts, and this data passing is usually done with use of interface.

Connected web parts are best when we have two different web parts and we want to change web parts activity based on external events happen in another web part exist in the same web page.

Here, MSDN contains very nice walk through for creating connected web parts.

In above article, two attributes plays role for connecting web parts

ConnectionProvider:

It should be attached to any one method which returns data, it does not necessary that it must have some value specified in the bracket, what so ever you write there will be displayed when you access web parts from SharePoint site.

ConnectionConsumer

It should be attached to any one method which gets data from another web part.

NOTE: when you use this connected web parts in Web Part page added in sharepoint, you will have option to connect with consumer web parts. But in case of default page you may require to turn to edit mode of your page and then click on edit of web part and then you will have this options of connecting to another consumer web part.

In above scenario it is assumed that firstly we have added both consumer and provider web parts in the page and then we will have option to connect web parts.

Tuesday, November 29, 2011

Thoughts on Web Parts in SharePoint 2010

SharePoint 2010 has many inbuilt functionality and features. One can leverage on it and take advantage of out of box SharePoint development. But business is all about having information in the right way and at a certain moment easy to catch.

Most of case Web parts serve many business needs for showing up information in the customized forms when SharePoint out of box development does not provide enough information.

At the time of Web Parts creation in SharePoint 2010, one has two choices Visual Web Parts and Standard Web Parts.

Both of these are much useful on their way and most of asp.net developers are much familiar with Standard Web Parts because it is very much similar to that of asp.net developers. Visual Web parts allows developer to just drag and drop control as they do in most of asp.net pages, you will have availability of all standard web controls, you don’t need to take care of setting underlying properties of controls. On the other hand Standard web parts allows developer to set each and every property at run time, you can have more controls on each controls. You can create as many controls as you need; you can dispose your control when you don’t need it.

There can be debate of using Standard Web Parts and Visual Web Parts, but certainly it depends on the choice of developer and business nature. Sometimes it is noted that Standard Web parts gives good performance compared to Visual Web Parts, and at the same time you need to take care of many things when you develop Standard Web Parts compared to Visual Web Parts.

It is good that now developer has choice to choose which type of web parts they want to develop, in earlier developer has to create user control and then they can add that visual element in standard web parts, but now they can directly add visual elements with use of Visual Web Parts.

To take decision of using any web parts is based on the time and resource it requires and also many other parameters need to consider for business activity.

Monday, November 28, 2011

Connect office 365 SharePoint online with SharePoint client object model

When you create any SharePoint client object model application there are choices to connect with SharePoint either in LAN or SharePoint server. But now days there are much hype in office 365 provided by Microsoft, it does allow SharePoint online. You don’t need to manage your own SharePoint server if your organization is not much big and many companies are planning to move their work to office 365.

So it’s naturally necessary that your client object model should support this office 365 SharePoint online connection. Here there is a trick to connect with it, it’s not direct way to connect with SharePoint online. You need to consider many things for it like cookies and your id, password etc.

Here, it is very nicely explained how to authenticate with office 365 and make connection to SharePoint online with client object model.