Showing posts with label WP8. Show all posts
Showing posts with label WP8. Show all posts

Sunday, September 15, 2013

One or more errors occurred while processing template 'Entity.tt'. Using Reverse Engineer Code First in VS 2012 Update 1

Hi,

Using VS 2012 Update 1, I was doing some changes in my database schema and when i try to reverse engineer code first my updates i was getting the following error:

One or more errors occurred while processing template 'Entity.tt'.

In the output window, VS listed that System.Xml and System.Xml.Linq exist on 2 different paths, one where the .NET framework is installed and the other one is pointing to the Siliverlight 5 DLLs in the GAC.

While it is reported as a bug in Microsoft Connect website, I was trying to remove the link to the Silverlight 5 Dlls that i'm not in need when i reverse engineer code first my EF files to apply my DB changes.

To fix this problem: 
1) Open the following directory:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes

2) Take a backup from EF.Utility.CS.ttinclude or the VB version based on the your project language you are using.

3) Open the notepad in an administrator mode.

4) Open the CS.ttinclude file.

5) change the following 2 lines:

<#@ assembly name="System.Xml" #>
Change it to:
<#@ assembly name="System.Xml, Version 4.0.0.0, Culture=neutral" #>

<#@ assembly name="System.Xml.Linq"#>
Change it to:
<#@ assembly name="System.Xml.Linq, Version 4.0.0.0, Culture=neutral"#>

6) Save the file.

7) Right click on the project that has the EF files and click on Reverse engineer Code First.

8) bingo! you will get your database updates with no errors.


Let me know if you have any issues with this.

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.




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.



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!