08 Oct 2012

Windows Store app Development Snack: Stop asking for the SMS code when going to the dashboard

For more posts in this series, see the series index.

imageWhen you get to publishing you may find it annoying to go to the dashboard as you are often being asked to put in a SMS code for verification.  The cause here is your browser is seen as insecure and thus you must confirm the login. So what is the solution?

  • Step 1: Make sure you login to Windows 8 with the same credentials as you use in the store.
  • Step 2: When you added you Microsoft Account to Windows 8, it would’ve emailed you a link to verify the computer. Make sure you have clicked that link.
  • Step 3: Use IE 10 and login to the dashboard.

And problem solved, now it will only ask you to login & confirm the login when the session expires!

03 Oct 2012

Windows Store app Development Snack: What's in a name?

For more posts in this series, see the series index.

During development of Zune, then Windows Phone and finally Windows 8 the term Metro was used to define the UI design style, this was later extended to explain what a desktop app is versus a Windows 8 app is. However Microsoft has stopped using the name and recommended developers stop using the name too so what should we call these things?

Metro apps – these are now called Windows Store apps. Visual Studio uses this name too so shouldn’t be too surprising. Note one pedantic pro-tip: app’s is ALWAYS lowercase.

Metro as in the style – As I explained Metro started out as a way to explain the UI design, that is now known as the Microsoft design style.

Metro principals – Finally we often talk of the 8 traits or principals of a great Metro Windows Store app and one of those is Embrace Metro Windows design style principals:

  1. Show pride in craftsmanship
  2. Do more with less
  3. Be fast and fluid
  4. Be authentically digital
  5. Win as one

Source: http://msdn.microsoft.com/en-us/library/windows/apps/hh464920.aspx

04 Apr 2012

Why the harder you work to prove to Microsoft you know better, the less chance it will ever happen

Disclaimer: I do not work for Microsoft and these are my views based on discussions with multiple people at Microsoft which I have stitched together – maybe I misunderstood everyone and this is all wrong too. All examples I use are my own. I am no lawyer – check with a lawyer for legal & license advice.

tl;dr: Microsoft is really worried about being sued and thus is risk adverse to “stuff from the internet”. It is better to tell Microsoft what you dislike, not how to fix it. Learn about licensing content.

Paper Work

A few years ago I went on an amazing trip to work with Microsoft but before I could do that I needed to sign not only a NDA, but also waivers for the work I would do – which makes sense. I did it for free and Microsoft didn’t want me to sue them for money later for my work. Not only that I had to sign them, my employer had to do the exact same thing. Once again because I work for someone else who could claim money from Microsoft and Microsoft lawyers had deemed that a risk and needed to be protected.

This involved a lot of time and money, it is VERY expensive to have lawyers review documents from other lawyers and the DHL the originals half way round the world, but it is far cheaper than being sued.

I know that neither myself of BBD would sue Microsoft for the work I did, but that doesn’t still the hearts of those lawyers who live in a world of ugly mean liars that will cheat the system if it was easy and good. I wish it wasn’t this way but some wishes don’t happen.

The Users Voice

A while back Microsoft started spinning up loads of uservoice.com (UV) sites to collect feedback and I believe they are successful in getting some things changed. There is an odd issue I see on UV especially with how Microsoft deals with it, that being as technology advanced users & developers we are taught to give the most detail as possible – really there is nothing like too much detail… however in UV, it seems that Microsoft ignores them and favours those who do and give very little. A great example of this, is in Visual Studio land where we can compare the current top two ideas: this short idea which is “under review”

image

versus to this guy who has pages of details and even as taking the design and proving a lot of it could work – for all his hard work, nothing.

image

WTF?! Microsoft doesn’t listen to me

If you read both suggestions they seem to say the same thing except the lazy guys one got the reward, right? No – it is more fundamental than that. The first one is really just discussing the what & why the VS colour change that is an issue, the second piece of feedback though is discussing how to fix it. The problem for Microsoft is if they take the second guys stuff, a person who hasn’t signed a waiver, the how guy has a legal ability to sue Microsoft for the money they owe him for work/royalties etc… And Microsoft legal won’t allow that to happen because that is their job, to protect Microsoft legal issues.

This is not a complaint about legal, I am sure they are nice people that are just doing their job and it is annoying their job and my wishes do not align...

The thing about taking the what feedback is Microsoft is pretty safe in taking and improving VS in anyway they see fit and that is why the what & why is under review and not the how.

Licensing & Public Domain

The next that will be brought up is that this is work in the public domain and thus “free”… wrong. Public domain work is more a legal trap than anything, and there is so many steps that you need to jump through to get access to using that “free” work that often it is easier to redo it yourself. This is why ANYTHING you do should have a license, even if you want to just give it away and never see it again or if you want someone like Microsoft to be able to use it.

For software check out a good open source license, such as BSD 3-clause which basically says do what you like with my work and I promise I won't sue you except if you use me as an endorsement for your product which contains my work. For non-code items,  like art, music or blog posts have a look at the creative commons licenses.

Microsoft can fix this too

Microsoft could reach out to people with good ideas and get them to sign waivers (WAY too much work and also maybe risky after the work is provided), but better would be to adopt an approach like StackExchange (SE) does. SE states if you provide feedback on their sites it is creative commons.

Microsoft could do the same and even put in a waiver clause on UV, I don’t know if UV allows for this, but Microsoft is big enough to get it done. It doesn’t solve great ideas that are posted elsewhere, those still required YOU to take the time to learn a little about licensing, public domain and so on and take the right steps so we can ALL benefit… not just the lawyers who get paid to say no.

01 Mar 2012

Upgrading Visual Studio "11" Developer Preview Metro Projects to Visual Studio "11" Beta Metro Projects

76451If you created Metro style (WinRT) projects in Visual Studio “11” developer preview (alpha) and you try to open them up in the beta you will have a few load issues. These are ones I have found in my apps so it is not exhaustive, but seems like the most common.

Projects will not load

The projects themselves will not load with the following error: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v1.0\Microsoft.Windows.UI.Xaml.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. 

The solution to this is to open the project file and navigate to the <Import> node and change the path from v1.0 to v11.0 (see the highlighted extra 1 in the image below that is needed):

image

Compiler Directive

If you used the compiler directive WINRT that has been changed to NETFX_CORE so you will need to update your code.

Package fails to build

The package fails to build/deploy and complains about an InitialRotationPreference attribute. To solve this open the Package.appxmanifest file and find the <VisualElements> node and you should find an line similar to this:

<VisualElements DisplayName="AtomicMVVM Metro Style App Demo" Logo="Images\Logo.png" SmallLogo="Images\SmallLogo.png" Description="AtomicMVVM Metro Style App Demo" ForegroundText="light" BackgroundColor="#000000" InitialRotationPreference="portrait">

What you need to do is remove the InitialRotationPreference attribute from the end, so it ends like this:

<VisualElements DisplayName="AtomicMVVM Metro Style App Demo" Logo="Images\Logo.png" SmallLogo="Images\SmallLogo.png" Description="AtomicMVVM Metro Style App Demo" ForegroundText="light" BackgroundColor="#000000">

Big load failure image from: http://www.hostedfile.com/pictures/76451/big-load-failure.html

29 Feb 2012

Important changes to Express Editions of Visual Studio "11"

manualtrafficexchangetipNote: The source of this is the Visual Studio “11” beta Product Guide (http://go.microsoft.com/fwlink/?linkid=243994) so this may change by release.

Today we have five Express products: C++, C#, Visual Basic, Web and Phone however with the launch of Visual Studio “11” we will only have TWO!

These two editions of Express we will have are Web & Windows. I do not believe we will only ever have two editions, as the 2010 Express editions grew during the product so I would expect a few new ones coming along post launch.

So how does the old Express editions map to the new Express editions?

  • C++ maps to NOTHING
  • C# for WinForm/WPF/Silverlight maps to NOTHING
  • VB for WinForm/WPF/Silverlight maps to NOTHING
  • Phone maps to NOTHING
  • Web maps to Web

Let me reiterate this, if you want to build non-Metro applications (unless they are web) there is NO Express edition anymore for this! The Windows Express edition ONLY allows the building of Metro apps (including ARM). Web dev using Express editions still continue to work as before.

Both Express editions have a new enhancements too, which is a fantastic thing: The ability Version Control & Work Item Tracking with TFS is included out of the box.

For the Windows express edition it has even more enhancements

  • A subset of static analysis (fxCop) for helping developers pass Win Store evaluation
  • Performance Profiling has been added: CPU Sampling for C#/VB/C++ Metro apps and Instrumentation for HTML/JS Metro Apps

Stop/Important image from http://sitechoppers.com/why-it-is-important-to-build-your-downline/

24 Feb 2012

Windows Phone: Icons not loading, Internet Explorer just black, performance poor

My Windows Phone the other day started acting badly, any icon from an application that I installed refused to load, Internet Explorer would just show a black screen and the performance on the phone was VERY poor. The cause? I use this awesome device too much and I had run out of space:

oops

Using the Zune software is the only way to see that!

What had happened is that I hadn’t installed new apps, but I had done a bunch of updates the day it started and so it seems the updates filled it up. Once I cleaned up some apps & games I don’t use I freed up a few gigs and all started working fantastically again!

10 Feb 2012

How different is WinRT really?

Update 29 Feb 2012: There is now a post covering the Consumer Preview/Beta changes: How different is Metro Style (WinRT) development really? The beta post

Note: Before you read this post, it is using the public technical preview of Windows 8, VS 11 & .NET 4.5, so I expect some issues will likely be resolved in later releases. Check the site out for more info!

Recently I have been working on a MVVM framework (it’s the new Hello World project for developers) and I wanted to make sure it worked with WPF, Silverlight & the new hotness: WinRT (or Metro or Windows 8 depending on who you ask). So I started to retrofit the framework and build a demo application at the same time to show it off. I quickly found a bunch of issues that you need to take care of when moving to WinRT.

Namespaces

It has been mentioned since //Build that we will have new namespaces so this should not be a surprise. In my MVVM framework it looks like this:

#if WINRT
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Core;
    using Windows.UI.Xaml.Data;
#else
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Input;
    using System.Windows.Controls.Primitives;
    using System.ComponentModel;
#endif

You should be able to spot almost a one to one mapping there, except for the last few, but we will get to those.

Duplication of INotifyPropertyChanged, ICommand & INotifyCollectionChanged

home-simpson-fire-cereal-epic-failThis issue will affect EVERY developer in WinRT and it is a MASSIVE fail on Microsoft’s part. The INotifyPropertyChanged, ICommand & INotifyCollectionChanged that are used in every XAML based system are not the ones used in WinRT XAML based systems. In fact the framework has TWO of each – one in the old namespace and one in the new namespace. So you will find your databinding just broken with no compiler errors! To solve this you have to switch the namespaces.

ObservableCollection<T> is broken

doublefacepalmHand in hand with the previous one is that the trusted ObservableCollection<T> no longer works either! It implements the old (wrong INotifyCollectionChanged) and thus all bindings to it are broken. You need to bind to a class that implements IVectorCollection<T>. One problem, the framework doesn’t ship with an implementation! So to bind to collections, you need to build your own collection class or grab a shim (as I chose to).

Proxies & WebRequest

Smile Smile I used WebRequest in the demo to pull images from Flickr and you know what just worked – proxy settings. The first time ever in .NET! I hope who ever decided that proxies should just work gets an award! Smile Smile

Reflection has added a whole new layer

In non-WinRT we can get all kinds of info on a type directly by working with that type (i.e. Type.GetType). However in WinRT that is not the case! Type.GetType is no longer enough, when you have gotten the type you need to call GetTypeInfo on that to get to all the information on the type. Why this extra layer is here is beyond me.

#if WINRT
                if (control != null && typeof(ButtonBase).GetTypeInfo().IsAssignableFrom(control.GetType().GetTypeInfo()))
#else
#if SILVERLIGHT
                if (control != null && typeof(ButtonBase).IsAssignableFrom(control.GetType()))
#else
                if (control != null && control is ICommandSource)
#endif
#endif

MIA Types & Methods

For a MVVM framework you will have a bit of reflection and so the first thing I noticed is the super handy Types.EmptyTypes is gone! So to have as close to a single code base I am doing this nonsense now Sad smile

#if (WINRT)
        private readonly Type[] EmptyTypes = new Type[] { };
#else
        private readonly Type[] EmptyTypes = Type.EmptyTypes;
#endif

There is a fair bit of these missing properties & methods like Type.GetType is missing some of the overloads I have come to love:

#if WINRT
            var viewType = Type.GetType(viewName);
#else
            var viewType = Type.GetType(viewName, true, true);
#endif

Lastly do not expect the trusted methods like GetConstructor, GetMethod or GetProperty to exist. Now we have collections we can iterate over. I admit this is a better option, but some helper methods here would've been useful.

public static MethodInfo GetMethod(this Type type, string methodName, Type[] parameters)
{
    var results = from m in type.GetTypeInfo().DeclaredMethods
                  where m.Name == methodName
                  let methodParameters = m.GetParameters().Select(_ => _.ParameterType).ToArray()
                  where methodParameters.Length == parameters.Length &&
                        !methodParameters.Except(parameters).Any() &&
                        !parameters.Except(methodParameters).Any()
                  select m;

    return results.FirstOrDefault();
}

So be aware when working in reflection be aware that it will work differently.

User Controls must be created on the main thread!

This I do not get at all, but in WPF & Silverlight a background thread can create a user control and pass the content to a Window on the main thread. This is SUPER useful for the creation of content and then when needing popping it into the foreground almost instantly! However WinRT has different ideas, all user controls MUST BE created on the main thread – YUCK!

#if (WINRT)
                Window.Current.Dispatcher.Invoke(CoreDispatcherPriority.High, (s, e) =>
                    {
#endif
                        shell = (IShell)typeof(TShell).GetConstructor(EmptyTypes).Invoke(null);
#if (WINRT)
                    }, this, null);
#endif

Simpson Fail Image from: http://www.thebuzzmedia.com/creator-of-wikipedia-fail-fast-fail-often/

Double face palm image from: http://tvtropes.org/pmwiki/pmwiki.php/Main/FacePalm

15 Sep 2011

Windows 8: How to get it working

(Update 1) Note: This relates to the Windows 8 Developer Preview, your mileage may vary and this may change.

This post is here to help you, and me, by sharing solutions that I am finding while trying to get Windows 8 running for a professional developer. I am using a HP 8510w laptop so some things maybe specific. This will be updated randomly and will be more like a live blog than a polished post.

(Update 1) As I update this I will prefix new content with (Update #) where # is the update number. The latest ones will be in bold.

Problems & Solutions

Graphics

I have a NVidia Quatro graphics card and to get it working correctly with Win8 (rather than the basic graphic driver) I needed to use the BETA driver from: Beta and Older Driver Versions – I used the Verde 285.27 Driver and that worked just fine, everything else was broken in one way or another.

(Update 5) This just worked with the Windows 8 Community Preview

.NET 3.5

imageA bunch of apps use .NET 3.5 or earlier so I needed that. To install it you must install it via the Turn Windows Features On/Off  option in the control panel (it’s under Programs). I had a BUNCH of issues (error 0x800F0906) getting it to work as it needs to download it which I think are proxy related. Once I downloaded via 3g it finally came down (took an hour Sad smile).

(UPDATE 2) Tried this via a transparent proxy and it worked too. Seems it is related to proxy servers that require basic authentication.

(UPDATE 4) Finally found a solution Smile Thanks to Zayd Kara for helping me with this:

Copy the SXS folder from the Windows 8 ISO to the C:\Temp folder.

Then run: dism.exe /online /enable-feature /featurename:NetFX3 /All /Source:c:\temp\sxs /LimitAccess

pic

Metro Style Apps Don’t Run

Details: http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/cd6df64d-737d-40e0-b999-03e654204448

(Update 1) Found the error message in the Event Log (Application and Services Logs –> Microsoft –> Windows –> WwaHost –> Admin)

Windows Web Application Host has encountered an unexpected exception. The error is number 0x8007000E.

image

(UPDATE 2) One of the best new features in Windows 8 is the ability to reset your machine without affecting your files. I did this and this solved all my issues image

(UPDATE 4) The cause of this is the DLink modem software for my 3G modem. It is screwing up com. No idea why, and no way around it. That’ll teach me to use a 3g modem that doesn’t work with the natively Windows 7/8 mobile internet support.

Windows Phone Developer Tools

The 7.0 RTM release will NOT install at all. The 7.1 RC will install so you may need to get that one.

YOU MUST install .NET 3.5 first (see above). Once installed I didn’t have any emulator options and trying to run it would cause: HRESULT: 0x89721800

I resolved this by deleting “%LOCALAPPDATA%\Microsoft\Phone Tools\CoreCon\10.0” (source for that App Hub Forums)

The emulator option appeared but now when I try to run it, it crashes Windows 8 with a BSOD related to vmm.sys – no solution yet.

(UPDATE 2) I have tried everything and nothing seems to help. Resorted to using a Windows 7 boot from VHD to be able to run these tools Sad smile

(Update 5) Solved: http://sadev.co.za/content/installing-windows-phone-developer-tools-windows-8

Microsoft Security Essentials

It would not install because of a compatibility issue Sad smile Downloaded it again from the website, which doesn’t tell you version numbers and the file size looked the same, but this newer one did work fine.

(UPDATE 2) Paul Adare pointed out on the forums that this is included now out of the box, so not needed Smile 

Switch to Live ID

Not working, error 0xD00000072 – suspecting proxy again.

Install of Visual Studio 2010 Offline Documentation

Completely failed, no idea why.

Capture

D-Link 3G Modem

It could not find the drivers, so I had to go to device manager, select the unknown devices –> Right click –>  Update Driver –> Browse my computer –> C:\Program Files (x86)\D-Link Connection Manager\drivers\64bit\WIN7

Then it found and installed the drivers for the 3G modem

(Update 1) Visual Studio 11 Express for Windows Developer Preview

Cannot build or run Metro Style apps.

Designer is failing with Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))

And running them fails with Unable to activate Windows Tailored application

I suspect this is related to the Metro app issue above.

Capture5Capture6

(Update 1) Internet Explorer 10

Two interesting issues, one browsing our intranet which runs on HTTPS any content from HTTP fails to load and there is NO option to allow it.

Capture3

Second issue is in the IE desktop mode there is no tooltips Confused smile 

ie-desktop

However the solution is to run the Metro Style Internet Explorer, and it shows tooltips… and they are LOVELY:

ie-metro

(Update 3) SharePoint

I am referring to connecting to SharePoint server using IE 10, in short – it is horrid for anything other than basic browsing. I have installed Chrome to get around this.

(Update 3) Windows Server AppFabric

imageI needed Windows Server AppFabric installed so I could do development, however AppFabric does not install on Windows 8 Sad smile

To work around this I waited for the error to appear, then browsed to the extracted files (the moment you click ok on the error it cleans itself up) and used the expand command to extract the msu file which you can find in the packages folder.

That gets me a cab file which I extract again and that produces another 1 996 files. In there I used the file search to find the assemblies I needed to get the code to build, won’t run but at least I can code Smile

(Update 4) HP LaserJet 4250 Printer

I have this printer on the network but it was horrid trying to get Windows to see and work with it. The trick was to download the actual PCL6 drivers from the HP website. This has all the options to set it up and it works fine now Smile

(Update 5) This just worked with the Windows 8 Community Preview

Things that just worked

For balance here are application that have been installed with no issue.

  • Visual Studio 2010 + SP1
  • Firefox 6
  • Chrome (what ever the latest is)
  • Windows Live Writer
  • TweetDeck
  • Office 2010 + SP 1
  • (Update 1) VLC
  • (Update 3) Pull

There is also some more info in the comments!

Pages