The world's coolest Laptop

Computing technology

The perfect UI for a logon screen

Communications has made our world tiny

Cant live without one

Saturday, July 30, 2011

Build action property - WP7:The property could not be read/written because the language service returned an unknown error



The property could not be read/written because the language service returned an unknown error

One of the most frustrating errors I have faced till now while developing app for Windows phone 7(WP7). I didn’t get any proper solution when I googled. So I wanted to share what solution I found for this error.

The story goes like this. I finished my windows phone 7 app – Finance Manager beta(listed in my blog). When i submitted to the App hub it said,

The [NeutralResourceLanguage] attribute is missing on the entry Linkassembly.

Well i was puzzled by this and as every person does I googled. And I got the solution to this problem easily. It was because fortunately many of the people had faced the same problem. I found 2 ways to solve this problem either manually through or using wizards. As a programmer I went for the manual option. The manual solution is to go to assemblyinfo.cs file. This file can be accessed in the solution explorer under the properties section. Then add the following commands.

using System.Resources; //on the top

[assembly: NeutralResourcesLanguage("en")] //In the section where all the attributes are given.

Else you can right click on the properties tab and under the build tab below default namespace. Click on the assembly information. In that under the Neutral language drop down select the language you want.

Normally this should solve the problem.

But unfortunately, my problem did not get solved, I gave the new XAP after adding this tag also, App Hub returned the same error. So I went to the second option of using the wizard. But when I clicked Assembly information all the fields were empty. I was wondering what the problem was. So I decided to manually feed in the values in to the fields. But when I clicked ok, Visual studio threw an error

The property could not be read/written because the language service returned an unknown error

I googled this, but unfortunately no solutions. I had no other choice but to solve the problem myself. So as I looked in to various things in my project settings, properties etc, I did find what the problem was.

There is a property of all the items in the project called Build Action. If this property is set wrong then the functionality of the app will be totally different even if one has done the coding perfectly. When I saw what the Build action property of Assemblyinfo.cs ,it was set to content. It should have been compile. I changed it to compile. Immediately all the fields in Assembly information of the properties of the project were loaded properly(As I described earlier, all the fields were empty but now they were loaded with values ).

Make sure your Build action property for all items is set properly. For example if u set the property of the DLL’s used for Localization should be set to content. If you set it to resource, though DLL have been created properly you will not get the output. So as such, Build action property if not set to the proper value can be really bugging.

Tuesday, July 12, 2011

Frames in Windows phone 7 - The concept of vanishing grids



One of the major challenges while designing a mobile application is that size of the mobile screen is very small compared to the regular screen size of the laptops or desktops. So it becomes really tedious in terms of the design even though most of the smart phones today have the scroll feature. Particularly when we want to design a page with many options, the page gets really crammed up with buttons. So what do we do? Recollect the concept of frames in a website. By frames what is I mean is that frames allow the designer to present multiple documents in a single interface.

While I was designing my windows phone 7 app, my main aim was user friendliness. It is very tedious for the user to navigate to different pages every by clicking numerous buttons. It doesn’t present a single interface for all the functions. For an end user it is not comfortable as it involves too much of navigation, interface keeps changing, No centralization etc. So when I decided to do something about this, as everyone does I googled my query with different tags. I ended up seeing something about Pivot and panorama controls which was also there in the offline training kit. Well I did find it interesting but at the same time, I thought of doing some experimentation. So here i provide my approach to the problem without using any of the pivot or panorama controls.

I started recollecting what grids were (Equivalently the canvas and stack panels). I recollected there is a property called height of a grid. What if I can make that height zero and resize it whenever I want to. So if I have multiple grids and make one appear at a time and at the same time make others not appear (make their height 0), it would solve the problem. Indeed, this approach did work. You can also use the same approach with width of the grid.

The first step is to categorize the options you have. The second step is to decide how you want the interface to be. Next step is the design an interface. I designed the page as follows. On the top section of the page, I had buttons denoting the categories and bottom of the page I had an area to display the associated items for that category like textbox, buttons etc.

When I click category one, the set of associated items should appear in the display area. Now how exactly do you achieve this is the next question. To do this first create different grids for different categories with each grid encapsulating the items belonging to that particular category. Let’s say for the sake example that the names of the grids are grid1,grid2,grid3 and so on for category1, category2, category3 etc. respectively. Now these grids are placed in the display area inside the main content panel. Under each grid encapsulate those items belonging to that category. Say for example, if category1 has 6 buttons and one textbox, then those items are to be placed under grid1. Now in the XAML code note the height or width of that grid and then make the height or width of the grid1 zero. Now repeat this procedure for all the grids so that you have a customized grid for each category. Please note that during design you won’t be able to see what you have done with previous grids(you can see only the present grid you are working with) as you have made the heights of those grids 0. You can view them by making the height of the present grid (the one you are working with) as zero and assign the height of the grid to that value, you have made note of earlier.

Coming to the coding part of it I am going to demonstrate using C# though this concept can be applied to VB also. In main constructor (Where the function initialize component is invoked) below the InitializeComponent() function give the following code.

grid1.Height = 0;

grid2.Height = 0;

grid2.Height = 0;

grid2.Height = 0;

grid2.Height = 0;

grid2.Height = 0;

You can also create an event handler when the page loads and give the above code there. This code is to make sure that all the grids are at zero height or in other words no category is displayed when the user enters the page. This is not mandatory and can vary depending on how you want the user to see the interface when he enters the page, the logic etc.

The next step is the event handlers when the category buttons are clicked. While placing the components, note the size of the grids which is according to your design. Let’s say for example sake that 255 is a height suitable for the design(the one you noted earlier). Create the event handler for click event of Category1 button by double clicking the category1 button in the design view. The following code goes into that:

grid1.Height = 255;

grid2.Height = 0;

grid2.Height = 0;

grid2.Height = 0;

grid2.Height = 0;

grid2.Height = 0;

Similarly for category 2 buttons, in the click event handler the following code goes:

grid1.Height = 0;

grid2.Height = 255;

grid2.Height = 0;

grid2.Height = 0;

grid2.Height = 0;

grid2.Height = 0;

This process is repeated for all the categories.

You can alternatively make the width of the grid also zero. The purpose is to make the other grids vanish and make only one grid appear at a time.

And there it is your own frames page in WP7 with vanishing grids.

Well the advantage with this technique is that it’s very simple to use, many of them are just copy pasting the things that have already been done, easy management, a single UI with multiple options etc. The disadvantage is that while designing if you lose track of what you have been doing it is very difficult to come back to what you have been designing because if you have large categories it is very much difficult as the XAML code becomes big. Apart from this I personally didn’t face any disadvantage.