Archive

Author Archive

Visual Studio 2013 Code Lens Feature

November 7, 2013 Leave a comment

New Feature in VS 2013 reduces the developer effort in getting quick answer to code and more productive, It’s named “Code Lens” aka Code information Indicator . With this feature integrated with TFS 2013, we have information flowing from TFS directly into Code Editor. Code Lens (Code Information Indicators) in Visual Studio 2013   places decorators on each of the methods in your code that show information such as what change sets led to the creation or recent change, who was the last person to work on the code, what unit tests cover the method (including the latest pass/fail state), and what code references exist. You can also quickly jump into that data, such as an associated change set or referenced code file with just a click.

  • Finding All References of Method.

Previous I use to right click on Method Name and select “Find All” references in Context Menu, to know where exactly this method is used in solution. Now in visual studio 2013, I can see All reference has method decorator.  Below is sample

11

On Mouse Click on References, I see all referenced location (results) as pop up ,Also there is a scroll bar (if needed) to allow moving through multiple entries:

12

  • Unit Test cases.

Can find tests that are associated with Method. The Show Tested By option will show what tests are associated with your code and an overall status indicator:

14 13

review the test’s results in test project, choose the test status indicator failed or success

  • Code MAP.

15

To visualize these references, create a code map from the reference list or from the code editor.

  • Bug Indicator.
  • 16

Number of bugs associated with Method

  • Change List.

17 18

Number of change sets affected this code, Visual Studio shows who checked in change sets for this code in your current branch. To contact the change set owner over LYNC

  • Code Review and Work Item Details . Either open the code review request or contact the requester.

19

To Turn On this feature

Go to Tools | Options | Text Editor | All Languages | Code Information Indicators:

20

and many more.. Please refer to this URL for more information. -Mahender

Categories: Visual Studio Tags:

Hyderabad Techies – Tech Kalasala – Work Shop on Azure Cloud Computing

June 12, 2013 Leave a comment

World of Technology is getting improving day by day, Cloud Computing is the one technology where it is next stage in the Internet’s evolution, which provides services — from computing power to computing infrastructure, applications etc. You can access cloud wherever and whenever you need. For the first time, I went to college (G.Pullaiah College of Engineering & Technology)to give brief notes on Cloud Computing and its uses to students on 19th Jan 2013. Work shop went well almost 107 students attended session. Student showed their intrest in learning in Cloud technology.

IMG_20130119_125236

543918_10200448594362430_1724394834_n

484783_10200448591962370_1993316182_n

530718_10200448607682763_28924797_n
Here is the feedback for session

Personality Development – 96.26% (103/107) said useful
Technical session – 93.46% (100/107) said useful
Presentation – 98.13% (105/107) said useful
Overall – 95.95% (308/321)

Thanks to Hyderabad Techies community, Hari Hara and Management of G.pullaiah college of Engineering and Technology, Kurnool for providing me this opportunity and It was good learning experience for me dealing with large set of target audience. Please email me @ mails2mahender@hotmail.com for PPTs of Cloud Computing Work Shop.

-Mahender

Categories: Uncategorized

Passed 70-513 Exam

December 17, 2012 Leave a comment

Hi,
Today I gave my 70-513 (Windows Communication Foundation Development with Microsoft .NET Framework 4)Exam. I passed exam with a score of 75%. Thanks to Microsoft Learning Site.

I followed James Foster Blog and his learning plan for WCF Exam preparation.
James J Foster.

This is good guide for WCF developers. Microsoft Windows Communication Foundation Step by Step .

Please follow above links for preparation of WCF service 70-513 exam.

-Mahender

Categories: Uncategorized Tags:

Exception While uploading Block Blob : Azure blob storage invalid content .StorageClientException – The specified block list is invalid

September 27, 2012 4 comments

Hi,

Windows Azure Blob is the simplest way to store text or binary data with windows azure. With the new Version of Azure, there are 2 types of Blob one is Block Blob and other is Page Blob. I suggest to go through this link before further going further in my blog .
In digest,
Block Blob –
Block blob is made of block each having unique blockID.Maximum block size is 4MB
Page Blob –
Page blob is collection of pages of size 512 bytes.

Block Blob provides stream of data. Whereas Page blob provides data in page wise.
We prefer Page blob for frequent Insert, update and read i.e. random read/ write. Whereas Block Blob is for large size where we have only read operation.

When we upload huge data into Blob, it takes too much time to upload. With the latest version of Azure SDK, where we can break the file into multiple block and start uploading parallel into ATS. Each and Every Block uploaded into Azure is associated with Block ID.

int blockSize = 4*1024;
using (MemoryStream ms = new MemoryStream(data)) // Read the Data from FileStream and copy into MemoryStream
{
ms.Position = 0;
// block counter
var blockId = 0;
// open file
while (ms.Position < ms.Length)
{
// calculate buffer size (blockSize in KB)
var bufferSize = blockSize * 1024 < ms.Length - ms.Position ? blockSize * 1024 : ms.Length - ms.Position;
var buffer = new byte[bufferSize];
// read data to buffer
ms.Read(buffer, 0, buffer.Length);
// save data to memory stream and put to storage
using (var mstream = new MemoryStream(buffer,true))
{
// set stream position to start
mstream.Position = 0;
// convert block id to Base64 Encoded string
var blockIdBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(blockId.ToString(CultureInfo.InvariantCulture)));
blob.PutBlock(blockIdBase64, mstream, null);
blockIdList.Add(blockIdBase64);
// increase block id
blockId++;
}

}
blob.PutBlockList(blockIdList);
}

In the above code, we are reading chunks of data from file and upload the data to block blob with ID.Here is code for that
blob.PutBlock(blockIdBase64, mstream, null);
blockIdList.Add(blockIdBase64);

Once all the blocks are uploaded dont get forget about calling
blob.PutBlockList(blockIdList);
Otherwise you blob is uncommitted transaction. When you run the above code, after uploading certain number of block, system throws exception “The specified block list is invalid”

@ var blockIdBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(blockId.ToString(CultureInfo.InvariantCulture)));

When I troubleshoot for hours, I got know that BlockID length are not same , If the BlockId starts from 0 then blockID will have variable length like 2 digit or 3 digit and soon, BlockID length varies. Since BlockID’s length are varying , ATS unable to upload block. To fix the Issue, Just replace

var blockIdBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(blockId.ToString(CultureInfo.InvariantCulture)));
to

var blockIdBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(blockId.ToString(CultureInfo.InvariantCulture).PadLeft(32, ‘0’)));

Now I see BlockIds are of Fixed Length.

I hope this will help someone who are facing same issue where is pretty tuff to identify the issue.

-Mahender

Categories: Azure

The context is already tracking a different entity with the same resource Uri in Azure

September 26, 2012 Leave a comment

Hi,
Recently I started working on Azure. I got to usage of Azure Table Storage.Generally I hate working on Backend system where I need to have information on index, join etc , Any way we are leaving behind the relational databases and started using Windows Azure Storage which has provided some additional benefit from cost and Maintenance view. Coming back to my topic, today i will discuss about one such type of error where we are developing application using Azure Table Storage(ATS). When we try to move data either from SQL Server or other data sources into ATS, You might encounter error like “The Context is Already tracking a Different Entity with the Same Resource URI”. What are reasons for encountering these problems, after couple of hours of searching , I came up with root cause of the error. Whenever we are moving data into ATS, you should consider proper design of RowKey and Partition Key. To know more about Row Key and Partition Key .Please follow this link . In a Nutshell, you Partition Key is nothing but set of entity are of same type. You will group set of entity by a Key which partitionKey. Within each Partition Key, you have set of Row Keys. We have ensure that data of row key generated should be unique for a particular. Apart from RowKey, there is Property for each entity in ATS, which is ETAG. Etag are used to know about entities which are Updated, It has value which is compare from Client to ATS, always Etag values must be matched whenever your updating Entity in ATS.Azure Table handles concurrent updates or deletes through optimistic concurrency using an ETag value that is changed each time an entity is updated. The TableServiceContext stores the ETag of every entity it is tracking and submits this ETag in an If-Match request header when an update is requested. Azure Table rejects the update request if the submitted ETag does not match the current ETag for the entity. This comparision is done automatically by ATS, since every action is REST model.

Here are trouble shooting tips, Based on Row Key Designing for my application, I came to conclusion that there are 2 rows with same RowKey for a particular Partition Key Always ensure that You dont have 2 Entity with Same Row Key, If there is situation like than try to concatinate RowKey with Some ID @ end of RowKey , so that ATS can differentiate 2 entities.

Another reason for Getting above Error is because that your deserialized type does not exactly match the Type of the tracked entity. Check Your Base Class whether it inherits from TableServiceEntity. Its must to have Base Class of your entity to inherit from TableServiceEntity.

Another Crude method to fix issue is Disabling the Change Tracking for Context. In order to disable change tracking you use the MergeOption.NoTracking option of the MergeOption enumeration
like
TableServiceContext tableServiceContext = cloudTableClient.GetDataServiceContext();
tableServiceContext.MergeOption = MergeOption.NoTracking;
and then tableServiceContext.AttachTo(tableName, entityName, “*”); where * means the force update of entity to the context using DataServiceContext.AttachTo() with an ETag of *.

Using above 3 trouble shooting approaches for fixing the error.

-Mahens

Categories: Azure Tags:

Problem with Element Binding in DataTemplate

December 19, 2011 Leave a comment

Hi,

After Long vacation, i started blogging today. This post is the first post after my marriage, a new phase of my life has just started :).

Getting back to topic. This is one of the challenging problem where most of Silverlight 4 developers generally face . One of the often requirement that we receive is how to use Element-Binding within data template.

Most of the developers purports themselves, Why Element data Binding is not working inside data template. The Reason for that is , Whenever You place any Child Controls Inside the data template. Silverlight or WPF Engine Generates the DOM structure for the child controls inside data template in a separate Tree. For Example :

<code>
<ListBox x:Name="ListSample">
<ListBox.ItemTemplate>
<DataTemplate>
<HyperlinkButton x:Name="SourceSiteHyperlink"  NavigateUri="{Binding Path=SourceSiteURL}"  TargetName="_blank"  VerticalAlignment="Center">
<TextBlock Text="{Binding ElementName=TextBlock1, Path=Text}"  Foreground="#525a60" Style="{StaticResource EllipsetextBlock}"></TextBlock>
</HyperlinkButton>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</code>

If you consider the above example, List Box by name “ListSample” has a Item-Template property which is meant to design the each List-Item look i.e “How exactly List Item data has to be shown on UI”. So, every Item-Template accepts type of Data-Temple. Within Data-template, I have a Child Control of Type HyperLink-Button, Which means that every List-Item will behave like a Hyperlink button, On Clicking of any List-Item, It will opens up the new Window with specified Navigate-Uri property Value. The Content Property of Hyperlink-Button is shown by Text-block, where its Text property is bind to an Element of type Text Block by Name “TextBlock1″, what ever may be value of textBlock1 , the value is shown up as content for Hyperlink-Button. If the TextBlock1 has value ” Hello” then Hyperlink-Button will have content (text) has “Hello”. This is exactly what every Silverlight developer think off and design XAML.

But when we run the application, We don’t see Hyperlink Button’s Text value. Because, The DOM structure within Data-Template, is generated in separate Tree which is not part of Main Tree(This is DOM which is shown on UI). So when we write Binding expression with Element Binding then XAML parser checks for element by name “TextBlock1” within the data-template DOM tree which is separate tree. So XAML parser cannot get the value of “TextBlock1” . So that’s the reason for no value shown on UI.

To Fix the Problem Here are the Alternative Solution

1) Create a Public Class for example : Here is Create Class by Name “SampleClass” under the same namespace of XAML.cs

2) Add a Dependency Property of type string and i name it has “URl”

public static readonly DependencyProperty URLProperty= DependencyProperty.Register(“URL”, typeof(string), typeof(SampleClass), new PropertyMetadata(String.Empty, null));

public string URL
{
get
{
return (string)base.GetValue(URLProperty);
}
set
{
base.SetValue(URLProperty, value);
}
}
3) Register the XAML Namaspace @ the top of XAML .
xmlns:dc=”clr-namespace:sampleSilverlightApplication”
here sampleSilverlightApplication is the Namespace of Silverlight Application

4) Register a Resource key under User Control Resources Tag.

<code>
<UserControl.Resources>
<dc:SampleClass x:Key="Key1" URL="{Binding ElementName=TextBlock1,Path=Text}"></dc:SampleClass>
</UserControl.Resources>
</code>

Explanation about above step is, I’m creating a StaticResource by Key Name “Key1”, Where URL is a dependency property for “SampleClass”. I registered “SampleClass” and set the URL Dependency property which is binded to an element “textblock1” with Text has Path. meaning is We are setting value of Textblock1 text property value to URL Dependency Property of SampleClass.

5)Now, We need to use StaticResource created in Step 4 in our data template.

<code>
<ListBox >
<ListBox.ItemTemplate>
<DataTemplate>
<HyperlinkButton x:Name="SourceSiteHyperlink"  NavigateUri="{Binding Path=SourceSiteURL}"  TargetName="_blank"  VerticalAlignment="Center">
<TextBlock Text="{Binding Source={StaticResource Key1},Path=URL}" Foreground="#525a60" Style="{StaticResource EllipsetextBlock}">
</TextBlock>

</HyperlinkButton>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

</code>


 

In the above step , If see HyperLinkbutton content’s
<TextBlock Text="{Binding Source={StaticResource Key1},Path=URL}" Foreground="#525a60" Style="{StaticResource EllipsetextBlock}">
</TextBlock>

Text property of textBlock is binded to StaticResource by key name “Key1” in UserControl.Resource Tag.

Finally , we run the above app, you should be able to see the value depicted in Hyperlink-button’s content property.
I hope this clear explanation helps other developers who are facing same problem like me. In case of any query, Please do reply back.

Thanks,
Mahender

Categories: Silverlight Tags:

Differences between ready () and Microsoft AJAX pageLoad(). When to use ready and pageLayout

October 3, 2011 Leave a comment

Introduction

Some time people gets confused about when to use Jquery ready() and pageLoad method. This article explains clear differences between pageLoad and Jquery ready().

Introduction on ready() and pageLoad()

JQuery’s ready() function is part of JQuery framework. Main importance of ready() function is , this event/method gets fired up on load of screen. At times people uses ready() function has initializes and also event binding for some of the control. ready() function is only fired once, for example : If your screen has partial post back /updates, then for every refresh or content refresh, ready () doesn’t get fired. It only fires initially on loading of page. So what is difference between ready and window.onload() . Window.Onload() method gets fired once all the content load in the page, i.e If the page contains heavy image, Window.Onload() will not fire until all the images get loaded. At times, we want some function to fire, once entire DOM structure is constructed. In those scenarios, we will make use of JQuery’s ready() function.

Now comes pageLoad, When Microsoft is developing asynchronous post-backs, it is expected that window.Onload function should be fired on refreshing of panel, but surprising the window.Onload function hasn’t fired, since document content Loaded or document readyState isn’t set to completed state. Onload function get triggered if browser supports DOMContentLoaded (which is presents only in non IE Browser). So Microsoft started implementing similar Onload function in AJAX , which gets fired on every asynchronous request. So If you AJAXify your asp.net page, Sys.Application is the client namespaces which performs all AJAX request, binging events etc. pageLoad is the alias method for sys.Application.add_Load() .

So AJAX pageLoad handlers gets fired up on each and every Asynchronous request. There is caveat here is, Always declare or implement your pageLoad method after declaration of scriptmanager and before closing tag of Form ( ). When AJAX panel makes an partial postback or asynchronous call, panel’s gets refreshed and OnLoading response for asynchronous call, this PageLoad event triggers.

Here is the syntax,

function pageLoad(sender, eventArgs) {

//ur code here

}

In comparison with ready(), ready() triggers only once ,after dom structure is constructed but doesn’t get fired up for every asynchronous calls. Whereas, pageLoad fires every time on every asynchronous calls.

There is another approach incase if you are not happy with above method, in JQuery 1.3 introduces live() method. $(document).live() event solve the famous ASP.NET Ajax and jQuery post back problem s.

With Regards,

Mahender

Categories: Jquery Tags:
%d bloggers like this: