ProgressRing causes Layout cycle error

If you use a lot of ProgressRing (in ListViewItem or a GridViewItem) in a View, you can have the infamous error Layout Cycle Error.

This blog post points the fact you have to hide (Visibility = Collapsed) the non active (IsActive=False) ProgressRing. That’s a good point BUT if the ProgressRing has to be visible, what’s the trick ?

The issue is the ProgressRing takes too much time to calculate its own measures, so if you have, 50/60 ProgressRing and you ask for a Resize => Layout Cycle Error (it’s a timeout for sure). It depends of your CPU, so it could be ok on a fast CPU and throw the error on a slow CPU, but you can’t take the risk…

SOLUTION

Do never use ProgressRing in list DataTemplates, this control is too heavy for that. ProgressBar with IsIndeterminate=True has also the same issue, so don’t use it too.

That’s not what you want to read but build your own – fast – progress control and layout cycle error will not be your nightmare anymore ;).

 

Posted in UWP, Windows Phone 8, WinRT | Leave a comment

Solution for Xaml Internal Error error WMC9999: Access denied

If you have this exception “Xaml Internal Error error WMC9999: Access denied” while compiling a WinRT or UWP project with Visual Studio, the solution is :

  • Close Visual Studio
  • Delete or rename the “packages” nuget cache directory of the project
  • Restart Visual Studio
  • Compile

You can check with “process monitor” on msbuild.exe to know which DLL have an Access Denied (in my case, it was BCL task library but I guess it could be anything else) if it’s not Nuget, maybe an other referenced DLL have an access denied !

Posted in UWP, Visual Studio, WinRT | Leave a comment

IIS 7+ : Redirect HTTP to HTTPS

These days, Google forces you to enable HTTPS on your website. If you google it for IIS, you will find several Microsoft post like this : https://blogs.technet.microsoft.com/dawiese/2016/06/07/redirect-from-http-to-https-using-the-iis-url-rewrite-module/

But the solution gave is wrong, you need this rule with Rewrite Module:

<rule name="Redirect to http" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
 <match url="*" negate="false" />
 <conditions logicalGrouping="MatchAny">
 <add input="{HTTPS}" pattern="off" />
 </conditions>
 <action type="Redirect" url="https://{HTTP_HOST}{URL}" redirectType="Permanent" />
 </rule>

(The mistake on the MS blog post is to use REQUEST_URI, not adapted with every cases)

Posted in Uncategorized | Leave a comment

The solution for validating an email address (RFC compliant) in .net C#

It’s a common question : “How can I validate one email address” ?

There are 0b10 (2) types of developers : lazy and ignorant.

  1. Lazy people always wins, because they do not reinventing the wheel, they prefer to search already done API.
  2. Ignorant people will probably use Regexp (I love regexp but not in this case) or write a new algorithm, they could spend few hours or days to implement the full RFC, good luck !

So the code is obvisouly server side, and in .net :

try
{
   new HttpRequestMessage().Headers.From = "mail@foo.com";
   //here the mail is valid
}
catch(FormatException ex)
{
// here the email is invalid
}
Posted in Uncategorized | Tagged | Leave a comment

WinRT Apps : Slow Compilation when you add WinRT components : Solution

PROBLEM

When you create a Blank WinRT project (W8 or WP8.1) with Visual Studio, if you compile as it, it takes : 2 seconds => great !

BUT, if you just add a simple WinRT component library (winmd) as reference and build, it takes 12 to 15 seconds… => wt….???! (if you add a DLL, there is no problem)

Well, it’s not a good start for a project, I didn’t find anything on the Internet about this issue, but I’m sure some developers will burn their computer if they have this issue (maybe they already bought a new CPU 😉 ?)

WHY ?

If you verbose the MSBuild log, you can see this line

> 10179 ms GenerateAppxManifest 1 calls

Ok GenerateAppXManifest is the CPU eater ! We have to found the solution…

SOLUTION

The Solution I found is to override the value AppxHarvestWinmdRegistration to false for MSBUILD in your App csproj, and to fill your AppxManifest .xml Extensions section as it was generated before in the Debug/Release directory – before this hack 🙂 -.

1. open your project.csproj, and add :

<PropertyGroup>   <AppxHarvestWinmdRegistration >false</AppxHarvestWinmdRegistration> </PropertyGroup> <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />

2. Then, you have to update your AppxManifest.xml like it was before in the Debug/Release dir for the Extensions section (specially if you use the Background Audio or anything which communicate with the external process) :

<Package....

<Extensions>
 <Extension Category="windows.activatableClass.inProcessServer">
 <InProcessServer>
 <Path>CLRHost.dll</Path>
 <ActivatableClass ActivatableClassId="BackgroundAudioTask.MyBackgroundAudioTask" ThreadingModel="both" />
 </InProcessServer>
 </Extension>
 </Extensions>

Have a nice coding day ! 

@poppyto

Posted in Windows Phone 8, WinRT | Leave a comment

Solution to Empty Emulator List (plus 0x80070002) in Windows Phone SDK 8

Sometimes, Visual Studio fails and you can’t do anything. You can repair or reinstall but in this case it’s not works.

PROBLEM : You can’t see any Emulators on Visual Studio :

and when you try to compile it throws 0x80070002  (File not found exception) :

SOLUTION :

So there are missing files, I catch them with ProcMon and by using MultiTargetingConnectivity API (this is THE api which throws 0x80070002) They are here in this location C:\Users\[Your User]\AppData\Local\Microsoft\Phone Tools\CoreCon\11.0

They are :
– Microsoft.ServiceCategories.xsl,
– Microsoft.VisualStudio.ServiceCategories.xsl
 Microsoft.XDE.ServiceCategories.xsl
 Microsoft.TypeMaps.xsl

It can be difficult to retreive these files (I repaired reinstall SDK 8 with no luck, trying to remove 11.0 directory and reinstall etc) so as I’m a nice guy, you could find the directory 11.0 zipped here : Download the full directory 11.0, extract here and copy/paste the missing file in your directory.

Have a nice coding day 🙂
Stephane

 

 

 

 

Posted in Uncategorized | 1 Comment

Solution for blurry rendering with DirectX11 on Windows Phone 8

If you experienced a global blurry rendering on your screen when you use DirectX11 on your Windows Phone 8, you probably fails a thing :

The swapchain size must be the screen size (means portrait), not the landscape size.

So  :

swapChainDesc.Width = 800;//
swapChainDesc.Height = 480; // blurry rendering !

swapChainDesc.Width = 480;//
swapChainDesc.Height = 800;  // perfect rendering !

That’s all, take care !

Posted in C++ CX, DirectX 11, Smartphone, Windows Phone 8 | Leave a comment

Solution for Error ERROR_DLL_INIT_FAILED while Loading winmd file in Windows RT

If you experienced the Exception :

Error in the DLL (Exception from HRESULT: 0x8007045a (ERROR_DLL_INIT_FAILED))

The solution is simple : You have to remove the main function.(I know, why the fonction “main” is called with DLL? idk :))

Posted in C++ CX, WinRT | Leave a comment

Solution for Error CO_E_ERRORINDLL while Loading winmd file in Windows Phone 8

If you experienced the Exception :

Error in the DLL (Exception from HRESULT: 0x800401F9 (CO_E_ERRORINDLL))

The solution is simple : You Must Add the _WINRT_DLL flag in the compiler definitions.

Posted in C++ CX, WinRT | Leave a comment

Windows Phone Store 8 shows neutral titles instead of localized titles

Dear you,

I experienced a bug in the Windows Phone 8 Store : I localized my app titles with the AppResLib.dll (& mui) and the tiles title were ok in the phone but the WP8 Store shown only the neutral language title. (on WP7 Store only, it looks ok!)

SOLUTION

In the WMAppManifest.xml (WP8) or in the project settings (WP7), you have to uncheck generic language codes (as “fr”,”it”,”de”) and check all the sub-language codes like “fr-FR”,”fr-BE”,”it-IT”, etc. If you check both generic and sub-languages, this will not working.

CONCLUSION

For the moment : don’t ever use the generic language codes (if you used them in your old WP7 app, this will appears Ok on WP7 Store but incorrectly on WP8 Store)

That’s all and this works !

Complete thread here.

Posted in Uncategorized | Leave a comment