Wednesday, July 17, 2013

What’s new in Records Management and Compliance in SharePoint 2013


Hi Folks,
I’m writing this article about what’s new in Records Management and Compliance in SharePoint 2013. SharePoint 2013 has extended the retention policies to be applied on the site level!.

Having the site retention policies on the site level is a cool feature, especially for most of the small/medium organizations that creates sites for their departments and not site collections.

Another cool feature which is the site policy also applies on SharePoint 2013 Foundation, so you can apply your site retention polices if you have SP 2012 Foundation instance.

Site Level Retention:

You can manage retention policies to SP sites and exchange 2013 team mailboxes that are associated with the sites.

Compliance officers create policies, which define the following:

n  The retention policy for the site and the associated exchange team mailbox, if any is associated.

n  What causes the project to be closed?

n  When a project should expire.

Here are the steps to apply compliance and retention policies:

1)      The site owner creates a SharePoint site.

2)      The site owner creates an exchange server 2013 team mailbox.

3)      The site owner assigns/selects the appropriate retention policy template.

4)      The site owner invites team members to join the site.

5)      All emails and documents among the site team members, the selected policy will be applied.

6)      When the project is completed, the site owner closes the project.

7)      Once the project is closed by the site owner, all project folders in outlook 2013 User Interface will be removed.

8)      When the project expires as per the selected policy, all associated artifacts to this project will be deleted.

 Hope this helps.

Useful Urls:

** Overview of site permissions in SharePoint 2013


 

 

Monday, June 24, 2013

New BCS Enhancements in on-premise and online SharePoint 2013

Hi Folks,

I'm writing this blog to list the new BCS features and enhancements in SharePoint 2013. SharePoint 2013 is released with great features for developers and IT Admins in terms of ease of use connecting to external sources and the ability to develop self-contained SharePoint applications that connect to external sources. In this article i will describe the new features and enhancements when building solutions on top of SharePoint 2013.

BCS enhancements in on-premise SharePoint 2013:

1) Automatic generation for BDC Models for OData data sources:
In SharePoint 2013, you are able to connect to OData endpoints and generate BDC models. You must use Visual Studio 2010 to create BDC models for OData data sources.
Then you can import these models in BDC Catalog on your farm-scoed external content types or added on a SharePoint App. VS 2010 will generate  BCS operations for all OData Operations (Get, Put, Post and Delete).

2) The ability to create SharePoint App-Scoed External Content Type:
When creating BDC models in VS 2010, you will be able to add App-Scoped external content types that will be used only on the associated SharePoint App.

3) Performance improvements in external lists:
SharePoint 2013 has introduced new enhancements and improvements to minimize the load on the database servers in the SharePoint farm and by increasing the speed of list rendering.
The ability to perform paging, filtering, and sorting of the external list data before it is sent to SharePoint is a great feature.

4) Limiting the records returned by external system:
In the BDC model, users can specify the number of records in the list that they want displayer per page.

5) Data Source Filtering, Sorting and export to excel:
In SharePoint 2013 you are able to filter and sort the data exposed through the an external list. So, in this case the external system filter and sort the data before send it back to the external list.
Also, you can export an external list to excel and in this case you get all list content and structure it shows in the browser.

BCS enhancements in SharePoint Online:

1) REST (CSOM): REST Api is available for web and mobile devlopers to consume SharePoint data using Client Obect Model for the REST Api.

2) BCS Client runtime supports side by side Office 2010 and Office 2013 installaion.

Hope this helps.

-Mostafa Elzoghbi

Thursday, June 20, 2013

Understanding Crawl and Index components interactions in SharePoint 2013 - Part 1

Hi,

I’m writing this post to describe the main components in SharePoint 2013 Search and related components.
As you know, SharePoint 2013 has a slight change in Search components than SharePoint 2010 since they re-architected search components and their dependencies from the previous version.
I will explain the purpose of the 4 main components (marked with asterisk below) so it will be easier to understand and help you when you plan for your SharePoint Farm deployment since Search is a crucial component to scale for SharePoint collaboration and user adoption.

Main SharePoint 2013 Search Components:

1)      Crawl component*.

2)      Content Processing component*.

3)      Analytics processing component.

4)      Index component*.

5)      Query Processing component*.

6)      Search Administration component.

*These components are covered in this article.

SharePoint 2013 Databases:

1)      Crawl database.

2)      Link database.

3)      Analytics reporting database.

4)      Search Administration database.

First and foremost, is to understand the Crawl components interaction, here I will talk about 3 main components:

a)      Crawl Component

b)      Content Processing component

c)       Crawl database

n  Crawl component: The crawl component is responsible for crawling content sources. It delivers crawled items – both the actual content as well as their associated metadata – to the content processing component.

The crawl component invokes connectors or protocol handlers that interact with content sources to retrieve data. Multiple crawl components can be deployed to crawl simultaneously.

Note: The crawl component uses one or more crawl databases to temporarily store information about crawled items and to track crawl history.

n  Crawl database: The crawl database contains detailed tracking and historical information about crawled items. This database holds information such as the last crawl time, the last crawl ID and the type of update during the last crawl.

n  Content processing component: The content processing component is placed between the crawl component and the index component. It processes crawled items and feeds these items to the index component.

The content processing component transforms crawled items into artifacts that can be included in the search index by carrying out operations such as document parsing and property mapping.

Both the content processing component and the query processing component perform linguistics processing. Examples of linguistics processing during content processing are language detection and entity extraction.· The content processing component writes information about links and URLs to the link database.

 Below shows the dependency data flow between Crawl and Index components:

Crawl Component àStore à Crawl DB àFetch/Process crawled items

à Content processing àcontent processing & extractionà Index Component

Second, once the data has been processed to Index Component, The next step contains other 3 main components are interacting to provide search capability in SharePoint:

a)      Index Component

b)      Index Partition

c)       Query Processing Component

 n  Index component: An index component is the logical representation of an index replica.

In the search architecture, you have to provision one index component for each index replica.

The index component receives processed items from the content processing component and writes those items to an index file.

The index component receives queries from the query processing component and provides results sets in return.

Queries are sent to the index replicas through the query processing component. The system routes and load balances the incoming queries to the index replicas.

 
n  Index partition: An index partition is a logical portion of the entire search index.

The search index is the aggregation of all index partitions.

n  Query processing component: The query processing component is between the search front-end and the index component.

The query processing component analyzes and processes search queries and results.

Both the query processing component and the content processing component perform linguistics processing. Examples of linguistics processing during query processing are word-breaking and stemming.

When the query processing component receives a query from the search front-end, it analyzes and processes the query to attempt to optimize precision, recall, and relevancy. The processed query is then submitted to the index component.

The index component returns a result set based on the processed query back to the query processing component, which in turn processes that result set before sending it back to the search front-end.
 
 
 
There are my thoughts on the main Search interacting components in SharePoint 2013, Drop me a line if you have any additions or questions.
 
 
-ME
 

Thursday, June 13, 2013

How to set parameters' values to SSIS packages

Hi,

This post to walkthrough step-by-step how to pass parameters to a SSIS package.
Usually you have set of parameters and you want to set the values at run time before the package runs.

The methodology that i will implement in this post, is to export the parameters that i want to set from an XML file by defining the SSIS configuration file using Visual Studio BIDS 2008/2010 or SQL Data tools.

Let's say, you have a SSIS package with a parameter called @myParameter, Here is how to setup the configuration file for the SSIS so we can pass it when the package runs.

Steps:
1) Open yout SSIS package.
2) Right click after you open the package and select on "Package Configurations".




 


3) Set the configuration file name and click on Next button.



4) Under Variables node, select the parameter name "@myParameter" you want to export to the configuration file, then click on Next button.
5) Write a name for the configuration and click on next.
6) The VS BIDS will create a XML file with the exported parameter properties.
7) open "TestPackage.dtsConfig" using the notepad and set the value property for the exported parameter.
8) Change the value of the parameter value in the dtsConfig and then save the file.
9) Run your package and the SSIS package will get the updated value from the xml file.

Hope this helps.


 

Wednesday, June 12, 2013

Windows Phone 8 Get Started and in-depth topics - TechEd NA 2013

Hi everyone,

If you haven't attended TechEd North America 2013 and you are a windows phone developer, This blog post is for you.

I was looking to see all windows phone 8 sessions so i can check them on my own time, I found this blog post that has all videos for windows phone 8 in TechEd 2013.

Take a look and enjoy.


http://blogs.windows.com/windows_phone/b/wpdev/archive/2013/06/06/teched-north-america-2013-summary.aspx

-ME

Tuesday, June 04, 2013

SharePoint 2013 REST Service Integration versus Client Object Model

 
Hi Folks,
Microsoft has released REST service in SharePoint 2013. As a SharePoint solution architect/developer you will be having more than one option to manipulate SharePoint data in your client applications.
 
With the REST interface in SharePoint 2013, folks are asking about what are the differences? And what are the benefits over each other? I will list all my insights in points in this blog post.
 
1) One of the main differences between Client Object Model API (COM) than REST API that it requires SharePoint Client assemblies that's only available for .NET technologies. While using the REST API doesn't require any .NET assemblies to be referenced in your client application but use any programming language to execute standard HTTP requests. For example: use the REST API to access SharePoint 2013 from your PHP website or iPhone/Android App.
 
2) What if I want to consume SharePoint 2013 data with Mobile Applications?
If you are planning to consume SharePoint 2013 data through using iOS or Android devices, then the REST API is the way to go. While if you are developing SharePoint 2013 solution on a windows phone 8 then still you have 2 options either REST or Client Object Model while I recommend to go with the REST for portability and code-reuse purposes specially if you plan to have different version of your application in iOS & Android platforms.
3) Benefits of using REST over COM in Mobile apps? The size of your application will be smaller when you use REST since you don’t need to add any assemblies in your App.
4) What about Windows 8 Apps? If you are developing HTML5 & JavaScript Windows 8 App this requires using the REST API in SharePoint 2013.
5) How do you Access SharePoint 2013 REST API?
The REST API is a WCF services hosted on the SharePoint Application server and has HTTP endpoint; you can access it through the following URL:
If you want to access a site collection:  http://MySite/site/_api/
If you want to access a web site:  http://MySite/site/_api/web/
To do the basic CRUD operations, check out this article:
 
“Get started with the SharePoint 2013 REST service”
“Using the SharePoint 2013 REST service”
6) When you read the above MSDN articles, the sample requires you to get an access token to access SharePoint 2013 REST API, Is there an alternative?
The answer is yes, you can access the REST API without getting an access token by using the Cross-Domain JavaScript Library. Here is your complete reference to code this.
7) The REST API is not just available for Site Collections and Site scope CRUD operations but it is also available on BCS, Search, and Social Features in SharePoint 2013. Check out these urls:
a) Using BCS REST service:
            b) Using Search REST service:
c) Using Social Features REST service:
As a solution Architect and Web guy, I’m so excited with the SharePoint 2013 REST API. It is a great shift to the web standards and to eliminate the boundaries to integrate SharePoint with Non-Microsoft platforms and tools.
I see this API will be primarily and heavily used by Mobile Developers and System integrators toward SharePoint Hybrid Solutions.
Hope this helps.
 
 
 

Thursday, May 09, 2013

Microsoft.ReportViewer.Common.dll is missing!

Hi Folks,

If you are having ASP.NET web application that is using Report Viewer control, you should be having the following dlls on your machine:

Microsoft.ReportViewer.WebForms.dll
Microsoft.ReportViewer.Common.dll

The first dll, has to be added as a reference in your bin directory while the second one can reside in GAC.

You probably will be getting an error if you don't have the common dll on your machine, first, first check the GAC:  C:\Windows\assembly

If you don't have it, then you need to install Report Viewer Redistributable package.

Here you have to note that the version of the dll will vary based on the installer version.

If you want version 10, you have to install VS 2010 release, here is the link:
http://www.microsoft.com/en-ie/download/details.aspx?id=6610

If you want version 09.00.21022.08 of the dll, you need to install VS 2008 release:
http://www.microsoft.com/en-us/download/details.aspx?id=6576

If you want version 8 of the dll, you need to install VS 2005 release:
http://www.microsoft.com/en-us/download/details.aspx?id=6219


Hope this helps.

Tuesday, May 07, 2013

Import SSIS package error 0xC0010014 when importing SSIS package

Hi Folks,

I'm writing this blog post to share an interesting find while i was developing a SSIS package using VS 2012 with BI tools. Microsoft has release on March this year 2013 BI tools to VS 2012 so you don't need to use VS2010 shell while developing SSIS packages.

The download link for BI tools in VS 2012 is here:
http://msdn.microsoft.com/en-us/library/jj856966.aspx

After i developed my SSIS package and try to deploy it on the SQL Server 2008 R2. I was getting the following error message when importing the package, here is the screen shots:

 
If you are using the Management studio you will get this above error without details!, but to get the detailed error message use SSIS Execute Package Utility, you can launch it from SQL SERVER 2008 R2 --> Integration Services --> SSIS execute Package utility
.


If you read the actual error message it says:
Package Migration from Version 6 to Version 3 failed with error 0xC001700A

Basically the Version that i used to develop the SSIS is higher than the recognized version by the SQL Server 2008 R2. To fix this problem you need to change the package version from 6 to 3 and it works like a charm!

Follow the following steps:
1) Right clich on our dtsx file and select edit, Open the file in notepad.
2) Look for:

      DTS:Name="PackageFormatVersion">6

3) Change the number 6 for the version to 3 and save the file.
4) Select the File System File from the SSIS execute utility and you will not get any errors!
6) From the management studio you can import the SSIS with no errors.

Hope this helps.

[Update 05/09/2013] You will run through other issues if you used VS 2012 SQL Data tools against SQL Server 2008 R2, one of them is the sql job agent will fail to run the imported job due to the xml format mismatch while executing the package. So, it is recommended to develop any SSIS SQL2008 R2 components using the old BIDS VS 2008.


-ME
 

Monday, May 06, 2013

How to convert your WCF Service Library to WCF Service Application

Hi Folks,

If you have a WCF Service Library Project in VS 2012 and after you wrote some functional code and then you decided to change the project from a WCF Service Library that doesn't contain web configurations and can't be hosted in the IIS to a WCF service application that is hosted in IIS, this blog post will tell you how to do it in details.

The WCF service library doesn't contains the Web Configuration Tab when you open the project configuration (By right click on the project --> Project Properties) and it has only app.config file and not web.config file because it is not suppose to be hosted in the IIS.

To change your WCF service library to WCF Service Application:

1) Right click on the wcf project and click on unload project.
2) After the project is being unloaded, right click on the wcf project and click edit the project configuration file ".csproj".
3) Look for the following attribute :

 {3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}

Change the project type to the following:

{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}

4) Reload the project.
5) Open the project configuration, you will be able to see the web tab to configure the wcf service.
6) Add web.cofig file to your project.
7) Copy any necassary keys from the app.config to the web.config.
8) Rename or delete the app.config file.
9) Make sure that you have correct port and end point configuration in the web.config.
10) Clean and Build your project. At this point the project is build with no errors.

After you run the project you will see that there is no .svc file that is the service application file used to call the WCF. But you need to have one in your project.

11) First Rename your Service.cs and IService.cs.
12) Add new WCF Service svc to your project and name it as you like.
13) Copy the code you have in the Service Class and the interface to the newly created service.
14) Compile the project.
15) Run the WCF Service application and now your WCF can be accessed through the web.


Note:
This works with VS 2012 project templates with Update 2 as well.

Hope this helps.



 

Tuesday, April 16, 2013

Few tips to know when considering developing MVC4 Applications in VS 2012 - Part 1

Hi Folks,

I'm writing this blog post for ASP.NET web forms developers who have been working with Web forms for years and they are hesitant to develop MVC 4 ASP.NET applications; maybe for different reasons either it is not easy to understand or there are a lot of things you need to wrap your head around to get started building your first business application!

So i decided to write these series of posts,I will try to makes it easier for you to get started in MVC 4 applications with few tips that will help you know how it works and some other considerations to think about.

1) Basic Concepts of the MVC design pattern:
In MVC design pattern implementation by Microsoft, any page you see in the browser is a view, it can be a page or a user control. it can be aspx,ascx or cshtml. MVC has introduced cshtml which is the new render engine called RAZOR, this engine allows you to wirte cs code within your html elements by prefexing any C# Code by @ symbol. For example:
 
<div>@Html.ActionLink("Home", "Index", "Home")</div>

The above line is rendered by Razor as a link with a caption called Home and Index is the method will be called in the Home Controller.

2) Controllers:
All controllers in MVC 4 are stored under a folder called controllers, if you want to create a new controller, right click on this folder and select add new controller and the new controller will be created with all functions if you picked the model "Table" you want to target for this controller.
All controllers MUST have Controller suffix.
Usually you have one controller per 1 entity, but you can design your controllers as you want.
Any action in any view should be mapped to a method in a controller, and the controller takes care of the execution and return the results to the view. That's why you see all controllers can return a view that could be a page or partial page, file, redirect, or Empty.
Check out this link for the types of result you could get from any controller method call:
http://msdn.microsoft.com/en-us/library/system.web.mvc.actionresult(v=vs.108).aspx


3) No Master page in the MVC4 web project:

You will not see a default master page in your project, the general look and feel in the project is controlled by a "Shared View", This Shared View acts as Master Page in the web forms.

If you want to modify the shared view, it is under Shared View Folder --> _layout.cshtml

You still can add a master page to your project  and link all your views to it.

4) Connecting to a database/ Creating your Model:
Model is your database/datasource file in the project. First thing you should do before creating any controllers or views is to create your entity model for your project.
There is no change in this regard. Just add any data entity file that you are familiar with such as: Entity Framework, Entity Data Model, LINQ or SQL Compact Db files.

After creating your model, you can add your controllers since the MVC 4 gives your the ability to create all your CRUD operations once you pick your entity/model and context "dbml or any data source file"


I want to keep it short and simple, I will keep posting more parts in details for building your first MVC 4 application.

Thanks and drop a line if you have any questions or feedback!


Regards,
Mostafa









Friday, April 12, 2013

WCF Error: The underlying connection was closed: The connection was closed unexpectedly.

Hi Folks,

While i was developing a WCF service API for my enterprise application, I got an error while i'm calling a search function in the WCF. The WCF function is calling a stored procedure.

I tested the stored procedure and there is no issues with it at all, and the error was being thrown in my web when the data is being serialized and sent over the network.

The error message:

The underlying connection was closed: The connection was closed unexpectedly.

The point here is that i have other functions in the WCF work perfectly with no errors but only the search function is throwing an exception.

So, it is not configuration thing, it is something else i want to nail it down!

The only way to get the actual error message from calling a WCF service, is to install a tool called "Microsoft Service Trace Viewer" . Here is the download link:
http://www.microsoft.com/en-us/download/details.aspx?id=3138


After you install it, add the following section in the web.config before the closing of the configuration attribue:

<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>

Run your applicaiton, and execute the action that throws the exception then do the following:
1) Open the following path:
C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin

2) Double click on SvcTraceViewer.exe tool

3) From the File Menu, Click on Open.

4) Navigate to your project folder and you will find a file called: traces.svclog, select this file.

5) Check the actual WCF call that causes the error from the activity window and then see the details of the error in the right pane.




Hope this helps.
 

Friday, March 29, 2013

How to enable MS Dynamics CRM 2011 to integrate with Windows Azure

Hi,

I'm writing this article to explain a good architecture design for integrating your Microsoft Dynamics CRM 2011 with windows azure.

Let's  say you have on-premise CRM 2011 instance, and you want to use Windows Azure Blob storage to store Customer's documents on the cloud. How would you do that ?

The example i'm giving is applicable to any other windows azure service such as: SQL Azure, Mobile Notification Service, AppFabric Features..etc.

Since Windows azure is a scalable Cloud platform, you can easily integration your CRM 2011 with the windows azure on the cloud in 4 main steps.

Before going through the details, I'd like to explain the architecture of the proposed solution.

MS CRM 2011 has a backend windows service called "CRM Asynchronous Service" this is the component that will be in charge to communicate with the windows azure through a service bus.

MS CRM 2011 has 2 types of plugins, out-of-the box (OOB) and custom plugins. The OOB plugins runs  with full trust but the custom plugins runs with partial trust, and we will develop a custom plugin to connect to a listener through azure service bus.

The solution has the following components:

1) Configure CRM to be Windows Azure Aware.

2) We need to configure a service bus on Azure with an endpoint to communicate with the CRM server.

3) A listener hosted in Windows Azure to communicate with the asyncrhounous service, specificially listening to CRM assembly "Microsoft.Xrm.Sdk" with RemoteExecuteContext defined. so we need to develop a listener and deploy it on windows azure.

4) A custom CRM Plugin to communicate with the Windows Azure Listener.


How To accomplish, configure and develop this solution:

1) To accomplish step 1 , "Configure CRM for Integration with Windows Azure" :
http://technet.microsoft.com/en-us/library/gg328249.aspx

2) To accomplish step 2, "Configure Windows Azure ACS on Azure" :
http://technet.microsoft.com/en-us/library/jj863635.aspx

3) How to write a windows azure listener:
http://technet.microsoft.com/en-us/library/gg309615.aspx

C# Sample code - Listener:
http://technet.microsoft.com/en-us/library/gg309657.aspx

4) To accomplish step 4, "How to write Azure Aware CRM Plugin":
http://technet.microsoft.com/en-us/library/gg328194.aspx

Note, if you want to develop a custom workflow activity:
http://technet.microsoft.com/en-us/library/gg327854.aspx

Registration step - FINAL:
http://technet.microsoft.com/en-us/library/gg328524.aspx


**Here is some sample code for all what i mentioned above "listeners & plugins":
http://technet.microsoft.com/en-us/library/gg334712.aspx

Note: you should be having CRM SDK and Windows Azure SDK 1.7 or higher to be able to exercise and develop the solution.

Hope this helps.


Reference:
-Azure Extensions for Microsoft Dynamics CRM 2011:
http://technet.microsoft.com/en-us/library/gg309276.aspx



 

Wednesday, March 27, 2013

Fix It: Application deployment Failed, Please try again in VS 2012

Hi,

A well-known error message is being thrown from VS 2012 when you try to run the emulator for Windows Phone 8. After you installed all the tools and trying to see your application on the emulator you get the above error and it is a show stopper! It's so frustrating and annoying not to be able to view your running code.

After i was stuck for 3 days, and posting my question in MSDN and contributing on StackOverflow and other forums, all of these suggestions didn't work with me.

My case is fairly simple: I have a brand new laptop, Lenovo AMD E1500 (Supports SLAT) with 4GB RAM on Windows 8 Pro 64bit with VS 2012.

Every time i try to run my windows phone 8 application after selecting "WVGA 512MB" Emulator, it takes forever and i got this error:

Application Deployment Failed, Please try again.

When i check the output window in VS2012, I see the error happens when the VS 2012 tries to connect to the created VM in Hyper-V.

Here is the steps you have to make sure befor uninstalling the SDK or the other tools:

1) Turn off windows firewall.
2) Make sure that you are running VS 2012 as an administrator.
3) Make sure that you are a member of Hyper-V Administrator on your machine.
4) Open Hyper-V and check the you have a VM called "Emulator WVGA 512MB" since this is the VM that VS 2012 is trying to deploy the xap file into.
NOTE: IF YOU DON'T HAVE THE VM, THIS POST IS NOT INTENTED TO FIX IT.

5) Check the connection type for "Windows Phone Emulator Internal Switch" in Hyper-V manager by clicking on Virtual Switch Manager link on the right pane is Internal.

6) In the control panel, Check Network and Sharing Center and then click on change adapter settings --> you should be able to find 3 adapters starts with vEthernet, those are being used with Hyper-V.
Don't change any configuration by your self without any direction from a network guy! missing around these configuration might need you to re-install all the tools and rebuild all virtual switches!

7) Check below Article for MSDN and verify you have the following configuration for "vEthernet (Internal Ethernet Port Windows Phone Emulator Internal Switch)"

http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681694(v=vs.105).aspx

8) IMPORTANT: Turn off  any antivirus real time scanning, This turns into scanning all communications which slow down the VS/Emulator and times out the emulator running process so you won't be able to deploy your application. THIS WAS MY FINDING AFTER SPENT 3 DAYS!

After following all above instructions you shouldn't have any issues with running your WP8 Emulator.

Have Fun.




VS 2012 Update 1 is available

Hi,

Yesterday, Microsoft released a new update for VS 2012. In this first update for VS 2012, They included a lot of enhancements in terms of TFS services, SharePoint Development ALM, .NET Framework enhancements, Mobile development Enhancements and IDE fixes.

The complete list of all the updates in details are listed here:

http://support.microsoft.com/kb/2797915

So, if you are developing using VS 2012, it is strongly recommended to install this update, this is the download link:

http://www.microsoft.com/en-us/download/details.aspx?id=35774

Hope this helps.

Sunday, March 24, 2013

Generic Failure in WP8 Emulator and Error when opening Hyper-V Switch Manager!

Hi,

I was developing a windows phone 8 application using VS 2012, and after i did some changes in the network adapter by disabling the hyper-v virtualization protocol "vEthernet" and all its components, the emulator stops working!.

The reason i did this because i wasn't able to give a static IP to my machine so i can access it from my second machine, installing TCP/IP 4 to set the static IP and unchecked Hyper-V protocol screw my virtual Ethernet adapter and emulator components that are using it.


I was looking and searching what caused this problem, the only thing i was sure about it it is something related to the network adapter settings! since the network adapter doesn't have the required settings for the Hyper-V neither The emulator nor the Hyper-V switch manager is working and throwing errors.

The emulator was throwing an error: Generic Failure in VS 2012.

The Hyper-V Switch manager is throwing this error message: An error occurred while trying to retrieve a list of virtual switches.


To cleanup your machine and get back developing on the emulator, do the following:

1) Open Hyper-V Manager, you will find a VM created for your emulator, Delete this VM.

2) From Control Panel, Open Add or Remove windows Features -> Un check Hyper-V. This will un install all Hyper-V configuration. Reboot your machine.

3) From Control Panel, Add back Hyper-V to your windows, this will install Hyper-V manager and install all required vEthernet and other components that are required to run the emulator.

4) Open Hyper-V Manager, Click on "Add Virtual Switch Manager" and then add a virtual switch of type Internal.
Notice: you won't get the error message we had earlier!

5) Open your visual studio, and run your WP8 application, this will configure the emulator VM and all its components.
Notice: The first will take a longer time to run, since the windows will install all required drivers and create the VM used by the emulator and setup the network adapters between the PC and the VM.

6) If you check the Hyper-V manager after the first run for your application, VS 2012 has created a new VM and used the new Virtual Switch we created earlier.

Hope this helps!

Drop me a line if you have this problem and have other solutions or workarounds to it.

Thanks.



Wednesday, March 20, 2013

Calling Stored procedure from EF takes long time and times out!


Hi Folks,
 
I was going through an interesting performance issue when calling a stored procedure from my web application more than one time and the WCF was timing out because of the stored procedure execution takes long time to execute.
 
At the first, I have a parameterized stored procedure that takes different parameters. First time it executes as expected.
 
The second time, the EF calls the stored procedure and i don't get any results back to my application. i thought there is an issue in the Stored procedure but no because the stored procedure works as expected from the SQL management studio.
 
 
This means, there is something is going on between the EF bindings and getting results to mapped views/entities we have in the DBML file.
 
I was searching and trying to find any clue why this could happen ? I tried different things but it didn't work, until i read the following articles about performance issues in EF:
 
http://msdn.microsoft.com/en-us/library/cc853327.aspx
 
I realized that i don't have issues in terms of the SQL performance, but EF does have some overhead on executing any stored procedure and getting the results back to mapped view objects. Since this search stored procedure return list of objects to one of my entities, i want to know why does it take long time to execute and i don't get my results back ?!
 
I found the solution for my problem by doing 2 steps:
 
1) Since i don't want to track any loaded objects for my entities, i added the following merge option with No Tracking when i call my stored procedure.

C# Code:

this.ObjectContext.Search(EmpId,EmpName, DeptId,DeptName, System.Data.Objects.MergeOption.NoTracking).ToList();


2) Since SQL Server has a known performance issue called Paramter sniffing, which means the SQL Server engine allows to compile the plan for the stored procedure and reuse this plan for subsequent calls of the same stored procedure with different paramters! and this was my case, i pass long list of parameters but with different values. the first time executes as expected because the server chose to compile the plan with the results but the second time it re-uses the compiled plan which might not work well with the results that i want and this takes long time to get the expected results!
 
This is a known issue when your stored procedure inlcudes Like keyword in your queries and you use the input paramters directly to filter your results without using other temp paramters assigned from the input parameters.
 
What you need to do is to force SQL to compile the query each call and not to use a precompiled plan and this can be accomplished by using : RECOMPILE query hints along with your query. This is supported in SQL 2005 and above. I'm using SQL 08 R2 server.

Select * FROM myView
WHERE DeptName like '%' + @DeptName+ '%' 
OPTION (RECOMPILE); -- This enhance the performance query and fix the parameter sniffing issue for multiple calls stored procedure.

 After these 2 changes, I ran my web application, the application works as expected and no times out for the stored procedure that is being called twice!

Hope this helps.


Reference:
1) Table Hints in SQL Server:
http://msdn.microsoft.com/en-us/library/ms181714.aspx

2)  Paramter Sniffing in SQL Enginer:
http://blogs.technet.com/b/mdegre/archive/2012/03/19/what-is-parameter-sniffing.aspx


 
 

Tuesday, March 19, 2013

What do you expect from Entity Framework 6 Alpha ?

Hi,
 
I was reading the MSDN magazine March 2013 and i found an article by Julie Lerman about EF 6 Alpha features.
 
If you haven't had the chance to read the article, here is a summary of this article for .NET developers and architects:
 
1)      EF 6 will be supporting multiple schemas. So in your dbml file you will be able to reference and import multiple schemas in your database.
 
Julie has written a detailed article about this feature, here is the link for this:
 
2)      EF6 will be supporting the asynchronous processing (Async).
Since we have Asynchronous pattern supported in .NET 4.5. The EF 6 will be bringing some of these features by having: SaveChangesAsync(), ExecuteSqlCommandAsync and FindAsync() functions that don't block the UI while executing and you will be able to write asynchronous code in your application in EF 6.
 
For Linq to Entities, they have added bunch of other Async methods for enumerations such as: ToListAsync(), FirstOrDefaultAsync(), MaxAsync().
 
This is a very important feature especially for Silverlight, WPF and Windows Phone developers in addition to web developers.
 
3)      Enum and Spatial support
EF 6 will be supporting enums and Spatial data types. Unlike earlier version where dependent on the .NET framework you are using/targeting. The new EF 6 will be supporting this no matter which .NET framework you are targeting. So you can use enums and spatial support even you are targeting .NET 4.0 framework that doesn’t support certain EF 6 features.
 
Hope this helps.

Monday, March 11, 2013

Conditional using statement in C# debug versus Release

Hi Folks,

I'm writing this blog post to share how to write conditional using statements in C#. The meaning of this is how to use using statements in Debug mode versus Release mode in reference to different dlls. This is needed when you are using any testing/sandbox DLLs that use any non production environment and you want your code to use other reference when you build a Release for your application in reference to production dlls.

The below code is using In-App Purchase library for Windows Phone 8.

C# Code:

#if DEBUG
using MockIAPLib;
using Store = MockIAPLib;
#else
using Windows.ApplicationModel.Store;
#endif
Notice: you give the same alias name for the testing Libaray namespace as the one that will be used in production so you don't need to re-write your code.

Then, you can use any class for the referenced namespace:

ProductListing p = new ProductListing();


Tip: You should select Release before your deploy your application to products so the application will refer to the production assemblies and not the ones are used in the debug mode.


Hope this tip helps!