Wriju's BLOG

.NET, Cloud and everything

Windows Phone 7 Application bar Icon is not showing in Emulator

I have developed an application with Application Bar in Windows Phone 7. I have used the icon from C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Icons. I copied them to my project’s local folder but when I am running it in Emulator is it not showing. Below is the snapshot of how it came To be able to… Read more

Every Share Point 2010 is OData Server

If you have a SharePoint 2010 site you can get all the data stored within it as OData Feed. Like I have a site with URL http://sharepoint/sites/demosite, you just need to add this portion to the URL _vti_bin/listdata.svc. This would give you the list of Entities within that SharePoint site. Namoskar!!!… Read more

How to connect to Hosted TFS using Visual Studio 2010

You can connect to hosted TFS (Team Foundation Server) from Visual Studio 2010. But to do that you need to install the patch along with Visual Studio 2010 SP1. The patch is available at http://go.microsoft.com/fwlink/?LinkId=227805 After that it is very simple. Add the URL After that it will ask for the login. So pass your… Read more

Azure OData and Windows Phone 7

In this post I am planning to cover the topic where we will be exposing data in SQL Azure using WCF Data Services and consume it from Windows Phone 7. We have data available in SQL Azure. So we will create one let’s say and application ASP.NET MVC and add the Entity Framework data model… Read more

Windows Phone Mango Development Jump Start available at Channel 9

Learn development in Windows Phone Mango with Rob Miles and Andy Wigley 1. Mango Jump Start (01): Building Windows Phone Apps with Visual Studio 2010 2. Mango Jump Start (02): Silverlight on Windows Phone—Introduction 3. Mango Jump Start (03): Silverlight on Windows Phone—Advanced 4. Mango Jump Start (04): Using Expression to Build Windows Phone Interfaces… Read more

Windows Phone : Using Accelerometer in Emulator

If you are building application which is dependent on Accelerometer, then the Emulator allows you to test that. The below example was demonstrated on MIX11. Let’s suppose you have image and based on the X or Y axis of your phone image will rotate. <Image Height="428" HorizontalAlignment="Left" Margin="106,96,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="233" Source="/PhoneApp3;component/Images/Phone7.png" > <Image.Projection>… Read more

Windows Phone 7 : Choosing Email Application to send email

You may choose email application to send an email from your phone. EmailComposeTask MyEmailComposer = new EmailComposeTask(); MyEmailComposer.To = "wriju@contoso.com"; MyEmailComposer.Subject = "Mango Email"; MyEmailComposer.Body = "Welcome to the Magic!!!"; MyEmailComposer.Show(); Namoskar!!!… Read more

Windows Phone 7 : Choosing Email address from the list

If you are composing a text and wanted to send it to the people listed in your contact you can choose from the list. Here is how you can do it. EmailAddressChooserTask emailAddress = new EmailAddressChooserTask(); emailAddress.Completed += new EventHandler<EmailResult>(emailAddress_Completed); emailAddress.Show(); And to capture the email address you can have this small code. void emailAddress_Completed(object… Read more

Partner Event : Windows Phone 7 Mango – Platform Overview for Application Development

I am happy to announce the upcoming event for Microsoft MPN Partner on Windows Phone 7 Mango – Platform Overview for Application Development Date & Time: Aug 29, 11 Pacific time via Office Live Meeting Registration: https://training.partner.microsoft.com/learning/app/management/LMS_ActDetails.aspx?UserMode=0&ActivityId=752004 Presenter: Wriju Ghosh, Lead Partner Technical Consultant, Microsoft. Abstract: This session will walk you through the windows Phone… Read more

Windows Phone 7 : Invoke Bing Search

If you let people quickly open Bing search with the selected word while navigating your application in your Windows Phone 7. //Curtsey WP7 Training Kit – MUST HAVE IT!!! WebBrowserTask wbTask = new WebBrowserTask(); string BingURL = @”http://m.bing.com/search?q={0}”; string searchKeyword = textBox2.Text; wbTask.Uri = new Uri(string.Format(BingURL, searchKeyword), UriKind.Absolute); wbTask.Show(); Namosakar!!!… Read more

Windows Azure Free Whitepapers Updated

Introducing the Windows Azure Platform Architecting Applications to Use Windows Azure AppFabric Caching Introducing Windows Azure Windows Azure and ISVs – A Guide for Decision Makers Windows Azure Security Overview Professional Developers Conference 2010 Video Player Windows HPC Server and Windows Azure Cloud Economics IT as a Service Cloud Platforms for Business Leaders An Introduction… Read more

Windows Phone 7 : Open URL in IE9 from Application

Launching browser from your Phone application is often required. The common term could be “Shell” for those who came to classic VB age like me. Later in .NET it was wrapped under System.Diagnostic.Process. In Windows Phone 7 we might need such functionality while working with RSS kind of application where user can click on the… Read more

Windows Phone 7 : Using Local Database for Application

Windows Phone uses concept of Local Database and by implementing LINQ to SQL you can create 100% relational database driven application. To understand more on this refer http://msdn.microsoft.com/en-us/library/hh202860(VS.92).aspx So what you need is the good old tie up between Silverlight and LINQ to SQL. Here we go. You need to refer System.Data.Linq assembly and use… Read more

Windows Phone 7 : How to change Startup Page

Windows Phone 7 Silverlight project generally starts by opening MainPage.xaml. How to change this? Under solution explorer, expand Properties and open WMAppManifest.xml and there we can change it <Tasks> <DefaultTask Name=”_default” NavigationPage=”LocalDB_WP7.xaml” /> </Tasks> Namoskar!!!!… Read more

Windows Phone 7 : IsolatedStorage Save and Read Data to a File

Windows Phone 7 apps runs in an isolated environment and often application needs store and retrieve data from files. Application can use its IsolatedStorage to store and retrieve data. The example shows how to read from a  file and display it in ListBox and save data to the file located in its isolated storage. We… Read more

Windows Phone 7 : How to play media

Windows Phone 7 can flawlessly play media files. There are list of supported codec which Windows Phone 7 can play. However below is the simple XAML which can enable the media loading. <MediaElement x:Name=“myVideo“ AutoPlay=“True“ Source=“Kalimba.mp3“ /> You can also control various behaviors through your code.  Note. 1. Now while using the Windows Phone 7 Emulator… Read more

Windows Phone 7 : Checking Network Connections before Downloading

Not every user will use unlimited data connections. So as a good application developer you should check and notify user whether they would like to proceed further or not. Some of the quick things you may want to do //Check if network is available var _isNetworkAvailable = Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsNetworkAvailable; //Check if Cell Data connection is available… Read more

Windows Phone 7 : Building Simple RSS Reader

Here we will build simple RSS reader in Windows Phone. Reading RSS is reading XML file online. So you need some engineering between XML and XAML. Here you go. Your phone UI <Grid x:Name=”ContentPanel” Grid.Row=”1″ Margin=”12,0,12,0″> <ListBox Name=”lstRSS”> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text=”{Binding Path=Title}”></TextBlock> <TextBlock Text=”{Binding Path=PubDate}”></TextBlock> <TextBlock Text=” “></TextBlock> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid>… Read more

Windows Phone 7 : Handling Hardware Back Button

Often user presses hardware back button while inside an application. This would send the existing application to the background and let other be on top. Most of the times this is acceptable but sometimes application requires user to choose whether to go back or notify about it. Handling back button through code, protected override void… Read more

Windows Phone 7 – Binding Data to ListBox through Code

In Windows Phone 7 we need to display data programmatically. Below one demonstrates the simply way of binding data through code. Suppose you have Emp class as below. public class Emp { public int Id { get; set; } public string Name { get; set; } } Let’s create List<Emp> List<Emp> myData = new List<Emp>()… Read more

Windows Phone 7 : How to get Phone and Application memory information

If you want to get the memory information of your phone and application //Total Phone Memory (in bytes) var totalMemory = Microsoft.Phone.Info.DeviceStatus.DeviceTotalMemory; textBlock1.Text += Environment.NewLine + (totalMemory/(1024 * 1024)).ToString(); //Application Current Memory Usage (bytes) var appCurrentMemoryUsage = Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage; textBlock1.Text += Environment.NewLine + appCurrentMemoryUsage.ToString();   Namoskar!!!… Read more

Channel 9 Video on Entity Framework 4.1

Published the video on ADO.NET Entity Framework 4.1 Code First Development video. This covers quickly the basic features if this amazing product. Check it out at https://channel9.msdn.com/posts/EF41CodeFirst The code used for the demo is using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Entity; using System.ComponentModel.DataAnnotations; namespace EF41CodeFirst_BDotnet { //Dept Class public class Dept {… Read more

Code First EF 4.1 : Table per Hierarchy

Concept of Table Per Hierarchy (TPH) is to implement polymorphism and to de-normalize the relational database via inheritance. The entire hierarchy is mapped to a single database table holding all the properties of all the classes. The database then would create a column called “[Discriminator]” to hold the specific type. In Code First this is… Read more

Using ADO.NET EF 4.1 Code First with existing Database

Most of the time questions comes to our mind about EF 4.1 Code First whether or not can we use it with already available database? Simple answer is YES. I have very few personal view on it. I have seen in most of my application development scenario, database gets designed and created before and then… Read more

Code First EF 4.1 : Querying Many to Many Relationship

In continuation to my previous post on how to create one to many, let’s see how can we query it. We will use the same code base and query it Option 1 When we want to query it normally like below var emps = ctx.Emps .Where(e => e.EmpId == 1) .SelectMany(e => e.Projects, (em, proj)… Read more

Code First EF 4.1 : Building Many to Many Relationship

Since we do not have any designer question might arise how can we create Many to Many relationship in Code First 4.1. Here it is public class Emp { public Emp() { Projects = new HashSet<Project>(); } public int EmpId { get; set; } public string EmpName { get; set; } public ICollection<Project> Projects {… Read more

CodeFirst EF 4.1 : Changing Database Table and Column name

At times we need to control the Table and Column name of our generated database or have different Entity/Property name of code than actual database in EF 4.1 Code First. There are two ways we can do it. Using Annotations using System.ComponentModel.DataAnnotations; //Changing database Table name to Employee [Table("Employee")] public class Emp { //Changing database… Read more

Code First EF 4.1 : Missing “ADO.NET DbContext Generator” VS Template

I have seen people coming back to me asking questions about the template visible in Visual Studio 2010 as “ADO.NET DbContext Generator”. This template allows you to create the POCO classes and the context for CodeFirst from already existing edmx file. The template in Visual Studio looks like But missing. But why? At times if… Read more

Code First 4.1 : Using Stored Procedure to Insert Data

Code First in Entity Framework does not support Stored Procedure by default. As there is no designer we cannot even map our stored procs to the entity. There are a many scenario we have seen where we are bound to use stored procedure for any database modifications (insert/update/delete). Here is how we can use stored… Read more

LINQ to XML : Handling blank or no Element and Attribute

It quite so happen that you are working with XML where you are expecting a specific element in every set. But somehow that is missing in some of the sets. Now at runtime you would get an error.. The XML file which I am targeting <?xml version="1.0" encoding="utf-8"?> <Employees> <Employee Location="Earth"> <Name>Wriju</Name> <Email>a@a.com</Email> </Employee> <Employee… Read more

Windows Azure Storage Simplified

While working with Windows Azure it makes me feel as if I am working on ADO.NET Entity Framework and WCF Data Service. Everything is entity based and connection opens up through context. Lets see how can we create an application to add Movies to our database. Following are the using block entry We need Movies… Read more

MIX11 Recording Download using IE and Zune

Internet Explorer comes with a great RSS integration and by using that we can download the recording of MIX11. I have the channel9 MIX link https://channel9.msdn.com/Events/MIX/MIX11 and after I open it in IE you get to see the RSS After that I choose the type of video I want to download and open Zune (installed… Read more

EF 4.1 Code First Validation

When we either use the Fluent API or the attribute to put restrictions to our properties and while adding if we violet that, error would occur. Code First provides us set of classes to capture them Code First Model public class Department {     [Key]     public int DeptId { get; set; }     public… Read more

ADO.NET Entity Framework Code First 4.1 – Online

April 20, 2011 at 11 AM Pacific Time. Please register at https://training.partner.microsoft.com/learning/app/management/LMS_ActDetails.aspx?UserMode=0&ActivityId=731858 Learn what is new in ADO.NET Entity Framework Code First 4.1 ADO.NET Entity Framework comes with a new update to make things simpler while accessing data. ·         Background – no edmx, no visual model ·         Assemblies ·         Create and Load Database ·         Data… Read more

EF 4.1 Code First – Running SQL Queries

ADO.NET Entity Framework’s Code First 4.1 allows us to execute SQL queries directly. You may need to get one column output or quickly update a table. One thing we need to be careful about running these raw queries is that you need to be double sure about the validity of these… If you are viewing… Read more

EF Code First 4.1 Lazy Loading

EF Code First supports Lazy Loading as Model (edmx). You need to define the navigation properties to set the relationship to load the query. So if we try to implement the below code 1: public class Department 2: { 3: [Key] //To make it Primary Key and Identity 4: public int DeptId { get; set;… Read more

ADO.NET Entity Framework Code First Development

I liked LINQ to SQL for its clean approach of defining only code to be able to access the database. ADO.NET Entity Framework comes with a much more richer experience of you being the fine grained control over the code. In this current version we have Model First and Database First approaches, now we have… Read more

Moving On-premises SQL Server Database to SQL Azure

Is very easy and can’t think of anything simple. I did it with my favorite TestDB database Open SQL Server Management Studio. Right click the database and select Generate Script After that run the wizard as below   Select “Script entire database and all database objects” Select “Save to new query window” and click advanced…. Read more

Channel 9 : TFS 2010 – First Look

Just published one Channel 9 video on TFS 2010 covering   Ø  How to create Collection Ø  How to create Team Project Ø  How to setup the security Ø  How to create Workspace Ø  How to configure Source Control Ø  How to configure Team Build https://channel9.msdn.com/posts/TFS2010FirstLook Namoskar!!!… Read more

TechEd 2011 India

Thanks everyone. It was pleasure talking to all of you in India TechEd 2011 on “Choosing Right Data Access Methodologies”. It was a jam packed session and a lot of people were standing or sitting on the stage. I loved talking. Huge!!! I have been getting emails to share resources. Let me tell you one… Read more

TechEd 2011 India – Special

I have been following TechEds since 2005. This time India TechEd 2011 is very special to me. I am delivering session called Data Access Methodologies: When to choose what (ADO.NET, Entity Framework, LINQ, WCF Data Services) and the official abstract says, Often an Application requires to access database. A lot of evolving data access technologies… Read more

ADO.NET Entity Framework : Adding User Defined Function in Storage Model

Sometimes you may want to use same logic again and again. Let’s suppose you do not have access to your database which allows you to write function or stored proc. Never mind, EF allows you to define the logic at Model and you should be able to experience the same. You want to search an… Read more

Windows Azure Tips

How to: Build a Windows Azure Application How to Configure Virtual Machine Sizes How to Configure Connection Strings How to Configure Operating System Versions How to Configure Local Storage Resources How to Create a Certificate for a Role How to Create a Remote Desktop Protocol File How to Define Environment Variables Before a Role Starts… Read more

Visual Studio 2010 Training Kit for SP1

You can download it today by going here: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=752CB725-969B-4732-A383-ED5740F02E93&displaylang=en Silverlight 4 ·         Hands-on Lab – Migrating a Windows Forms Application to Silverlight ·         Hands-on Lab – Migrating an ASP.NET Web Forms Application to Silverlight ·         Hands-on Lab – Working with Panels, XAML and Controls ·         Hands-on Lab – Silverlight Data Binding ·         Hands-on Lab –… Read more

Windows Azure Jump Start Free Training Video

Session 01: Windows Azure Overview Session 02: Introduction to Compute Session 03: Windows Azure Lifecycle, Part 1 Session 04: Windows Azure Lifecycle, Part 2 Session 05: Windows Azure Storage, Part 1 Session 06: Windows Azure Storage, Part 2 Session 07: Introduction to SQL Azure Session 08: Windows Azure Diagnostics Session 09: Windows Azure Security, Part… Read more

ADO.NET Entity Framework Performance Tips

Over a period of time I have been working with ADO.NET Entity Framework and I am flattered with its amazing usability. I am a big fan of EF and especially with EF4 release a lot more avenues are open. I love to talk about this technology in any forum and given a chance I would… Read more

Visual Studio 2010 SP1 : What’s there

I am very excited to see the Visual Studio 2010 SP1. You can download this from http://go.microsoft.com/fwlink/?LinkId=209902. The article http://go.microsoft.com/fwlink/?LinkId=209902 talks about what is there and some of my picks are   HTML5 and CSS3 designer support Razor support IntelliTrace support for x64 And a lot of open issues have been resolved too. Namoskar!!!… Read more

ADO.NET Entity Framework Transaction

Any data-driven application needs Transaction and to ensure that the unit of work is either together successful or fail. Transaction plays a very important role. Assume that we are working with SQL Server. Now SQL Server has it’s own Transaction mechanism which could be used in Stored Procedures. However, not every time a Transaction is… Read more

Windows Azure – Adding Portal Co-Admin

Earlier it was concern with a many customers regarding the credential sharing. Generally big bosses used to purchase the azure account and developers were using it. Then only one Live Account was allowed to login to one subscription, they had to share the user id and password which would not be an acceptable way. Now,… Read more

Windows Azure Billing – Understand usage statement

Every month you get a bill of your Windows Azure Platform usage. Below is the guide to help you understand the inside of it. You may also find some unused Hosted Service causing the pic of your bill. http://www.microsoft.com/windowsazure/support/understandbill/ If you are a register Windows Azure user, you can check your bill at https://mocp.microsoftonline.com Namoskar!!!… Read more

I want to develop Apps on Windows Phone

There are few new Virtual Labs available, hence you do not need full setup. All you need is your MSDN Virtual Lab MSDN Virtual Lab: Building your First Windows Phone 7 Application  MSDN Virtual Lab: Hello Windows Phone  MSDN Virtual Lab: Launchers and Choosers  MSDN Virtual Lab: Using Pivot and Panorama Controls  MSDN Virtual Lab:… Read more

Free Windows Azure till June 2011

Sign-up now to get free access to the following Windows Azure platform resources: Compute: 750 hours of an Extra Small Compute Instance 25 hours of a Small Compute Instance Storage: 500MB 10k Storage transactions Data Transfers: 500MB in / 500MB out Relational Database: 1G Web Edition SQL Azure database (for 90 days only) AppFabric Access… Read more

Windows Azure Tools Error and Troubleshooting

When you try to develop Windows Azure Application using your Visual Studio 2010 and get the following error Windows Azure Tools: Failed to initialize Windows Azure storage emulator. Unable to start Development Storage. Few simple steps you need to follow is 1. Go to Windows Azure SDK folder under program files 2. Find DSInit.exe from… Read more

Azure AppFabric : Two possible errors and troubleshooting

Azure AppFabric Access Control is an easy to implement feature. While I was trying to add it to one of my applications, I found two show stopping errors. 1. A potentially dangerous Request.Form value was detected from the client (wresult="<t:RequestSecurityTo…"). To solve you need to do two things a. Add below to Web.Config under <System.web>… Read more

Windows Azure Storage Table Simplified

With Windows Azure 1.3 release I am super excited to see the most desired features addition and new portal. I will be posting on new feature soon. What remains the same as backbone of Windows Azure is the storage mechanism – a robust, secured and accessible location to capture user data apart from regular SQL… Read more