Getting the apps version number in iOS

We deploy a bunch of our iOS apps to our internal enterprise store, and one feature it is missing is the ability to notify users that there is a new version of the application available.

Using the following code (it includes all of the version magic, the one I am actually using just returns minorVersion), we can compare it to the version in the store and notify the user on launch that there is a new version.

- (NSString *)appNameAndVersionNumberDisplayString {

    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *appDisplayName = [infoDictionary objectForKey:@"CFBundleDisplayName"];
    NSString *majorVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    NSString *minorVersion = [infoDictionary objectForKey:@"CFBundleVersion"];
    return [NSString stringWithFormat:@"%@, Version %@ (%@)", appDisplayName, majorVersion, minorVersion];
}

To add a bit more excitement, the enterprise store maintains its own version numbers, so you have to make sure when you publish that you increment your version number in your project to match what is in the store.

Stop VS 2012 from auto checking out sln files

Basically there is an issue with the way an older Unity edited the solution file.

Open the sln file, get rid of the 'GlobalSection(ExtensibilityGlobals) = postSolution' section and save.

Adding APN to Nokia Lumia 920

Some of the 920s don't have the add APN under the Cellular/Mobile menu. To add the APN, you do it under Settings -> Access Point

 

For AT&T I used the following settings:

Connection Name:I called mine ‘Bob is awesome’

Access point name: wap.cingular

Username:wap@cingulargprs.com

Password:cingular1

 

I left everything else blank and I seem to be working.

Changing Namespace of your EDMX

I have mostly used Linq2Sql in the past, but as I find myself in a position to support both a website and mobile devices through oData, I have switched to using Entity Framework.

I don't really like Entity Framework better, but I did stumble across something cool today. If you decide to say, refactor a project and totally redo the namespaces, there isn't an obvious way to change the namespace of your EDMX through the GUI. The solution ends up being really straightforward though. If you change the default namespace of the project, the next time you build, it fixes the namespace of the EDMX.

Maybe Entity Framework isn't so bad after all...

Dark Souls for the PC

The Pre-Order for Dark Souls on the PC is up on Steam.

Article I followed to set up spam filtering in Exchange 2010

http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/A_9494-Securing-Exchange-2010.html

 

Just so I don't forget later Embarassed

Linq OrderBy with a String Column Name

This is not new by any stretch, it is posted a thousand places on the web, but I cleaned it up a bit and changed the return type to IOrderedQueryable so you can chain ThenBy after it.

using System.Linq;
using System.Linq.Expressions;

namespace System.Linq
{
    public static class LinqExtensions
    {
        public static IOrderedQueryable<TEntity> OrderBy<TEntity>(this IQueryable<TEntity> source, string sortExpression) where TEntity : class
        {
            var entityType = typeof(TEntity);
            var property = entityType.GetProperty(sortExpression.Split(' ').First());
            var parameter = Expression.Parameter(entityType, "p");
            var orderByExp = Expression.Lambda(Expression.MakeMemberAccess(parameter, property), parameter);
            MethodCallExpression resultExp = Expression.Call(typeof(Queryable), "OrderBy", new Type[] { entityType, property.PropertyType }, source.Expression, Expression.Quote(orderByExp));
            return (IOrderedQueryable<TEntity>)source.Provider.CreateQuery<TEntity>(resultExp);
        }

        public static IOrderedQueryable<TEntity> OrderByDescending<TEntity>(this IQueryable<TEntity> source, string sortExpression) where TEntity : class
        {
            var entityType = typeof(TEntity);
            var property = entityType.GetProperty(sortExpression.Split(' ').First());
            var parameter = Expression.Parameter(entityType, "p");
            var orderByExp = Expression.Lambda(Expression.MakeMemberAccess(parameter, property), parameter);
            MethodCallExpression resultExp = Expression.Call(typeof(Queryable), "OrderByDescending", new Type[] { entityType, property.PropertyType }, source.Expression, Expression.Quote(orderByExp));
            return (IOrderedQueryable<TEntity>)source.Provider.CreateQuery<TEntity>(resultExp);
        }
    }
}

Zerg Cake

Found this on the internet, this is definitely what I want for my birthday.

Acer W500

So, I picked up an Acer W500 to have an x86 tablet to play with while waiting for Windows 8 to get all official on us and, within its limitations, it has been great.

I started looking up options to increase the size of the 32 gig mSATA SSD (I already added a 32 gig SD card) and the only real option looks like this one:

http://www.amazon.com/OCZ-Technology-Nocti-Series-NOC-MSATA-120G/dp/B005FYFVRI/ref=sr_1_23?s=electronics&ie=UTF8&qid=1336517202&sr=1-23

$159 for 120 gigs, which isn't really bad though I don’t know if it is worth it since the RAM is soldered on the board, so you are stuck with 2 gigs, with part of that going to the video card.


I think I am just going to wait it out, I am betting on medfield tablets running windows 8 (arm power envelope, full x86 support). I like the idea of ARM, but I don't know if I am ready to give up x86 quite yet.

Here is one running ICS: http://www.engadget.com/2012/01/10/intel-demos-lenovo-made-medfield-tablet-running-ice-cream-sandwi/

Custom 401 in ASP.NET

Because IIS intercepts your request before you can handle it, you can't just set a 401 page in your custom errors block. While you can still change the default 401 page in IIS, the user will typically get challenged first when you set security with location in the web.config.

You wouldn't do this at all anymore, but I ran into it making a change to a legacy webform app and figured I would save what I found in case I see it again (I am moving 50+ apps).

To handle this you would do something hacky like this:

protected void Application_EndRequest(Object sender, EventArgs e)
    {
        HttpContext context = HttpContext.Current;
        if (context.Response.Status.Substring(0, 3).Equals("401"))
        {
            context.Response.ClearContent();
            context.Response.Redirect("~/AccessDenied.aspx");
        }
    }

One point to note, you can't do this in integrated mode, you would have to drop your app pool to classic mode.

Or you could be one of the cool kids and just rewrite the whole thing from scratch without telling anyone.

Random CSS Link Post

http://www.css3maker.com/

http://jquerymobile.com/themeroller/index.php

http://lesscss.org/

Xamarin

http://blog.xamarin.com/2012/05/01/android-in-c-sharp/

We could only be so lucky.

Random Link Post

Some MetroRT questions answered 

Crazy awesome Microsoft site 

Project Management and being more awesome site 

Awesome Microsoft Robot SDK stuff 

Advanced NT Debugging blog 

Microsoft blog on Globalization 

Global Authorization and allowing Anonymous 

DJ Sures and ez-robot

Good News and Bad News

The good - the new version of Chrome Beta for Android finally supports the desktop user agent string.

The bad - Bluestacks still doesn't let me use touch in the Android app when running on my tablet. They hint that it may work if I install Windows 7 on the tablet, but they are too wishy washy about it to get me to actually try it.

401.2 Access Denied from VS 11

Note to self, when you install Visual Studio 11, it disables NT auth for IIS Express by default. To turn it on, go to My Documents, IISExpress, config and modify the applicationhost.config file, changing <windowsAuthentication enabled="false"> to <windowsAuthentication enabled="true">.

JSIL

If you haven't seen it, some awesome guy named Kevin Gadd has made created a compiler to convert XNA to HTML5 named JSIL.

This should really come in handy soon considering Microsoft is saying they are not supporting XNA in Metro.

One thing to note, be careful when you are pulling down all of the magic from github, make sure you get his fork of ILSpy instead of the official one.

 

I originally pulled this down to convert Invaders to HTML5, it isn't compiling yet, but I had a good bit of stuff in there that wasn't XNA specific (using configurationmanager to dynamic load resources), so I most likely just need to slim it down a bit and give it another go.

Bluestacks

If you haven't tried it, it let's you run Android apps on Windows. Really impressed so far, though touch isn't working for me in  Windows 8. When I contacted them, they said touch is working in Windows 7, they just aren't supporting Windows 8 yet.

It is in open beta, so go check it out.

Enterprise Developers Guild

I used to go to the Enterprise Developers Guild here in Charlotte pretty often until they moved it downtown. Just found out they are having them in the Microsoft Campus again and went to the one this Tuesday called 'Build for All Devices with jQuery Mobile & HTML5' by Dan Thyer.

Had a great time and free pizza, will definitely be going to them more often than not now. Great turn out, must have been at least 80 developers there.

IIS 7(.5) and Anonymous Access

An interesting change I found today is when you choose to allow an application to accessed anonymously, it creds to resources as IUSR by default and not the application pool's identity. To fix it you go to where you configured anonymous access and right click on anonymous access and choose edit.

This is more of a reminder to me, I assume most people already know this, I just rarely ever use anonymous access so it caught me a bit by surprise.

Code Camp in Charlotte May 5th

The Enterprise Developer's Guild is hosting a Code Camp on May 5th at the CPCC campus in Matthews.

 

You an get more information here : http://codecamp.developersguild.org/

 

From what I have heard, they will have some advanced sessions, and if you are a presenter, they are still looking for people to be awesome.

If you aren’t familiar with the Enterprise Developers Guild in Charlotte, they have decently advanced sessions, and currently meet on the 4th Tuesday of each month at the Microsoft campus right down the road from our office at 6PM and the sessions are always free.

 

The one this month (on the 27th) is about jQuery mobile and HTML5.

 

As a plus, there is also free Pizza and soda!

You can get more info at their main site: http://www.developersguild.org/

Code Palousa Final Day

So, day 3 opens with a keynote from Jim Benson, and I am definitely going to have to preface my comments with the fact he is definitely more successful than I ever will be,  and most likely smarter. Having said that, he has this aversion to PowerPoint, and while I definitely can't disagree with him for that, I found his 'solution' even less palatable. This is actually unfortunate, as I get what he was trying to say, I just wasn't able to sit through it.

On to the first session of the day. I went and checked out 'Mobile Cross Platform Decisions' by Christopher Judd (Judd Solutions) and it was actually really good. He covered a lot of great ways to do mobile development, especially in an environment where you need to target more than one platform.

For the second session, I went and checked out 'The Evolution of Patterns' by Chris Eargle (Telerik) since he had done such a great job on day 1. I definitely wasn't disappointed. The only thing I would have done different in that session was tack a couple more hours to it. The hour was up and he was really just getting rolling.

For the third session, I went to 'Responsive Design in ASP.NET MVC - A Crash Course in Responsive Design' by Ed Charbeneau (Sypris Solutions) and it was phenomenal. I walked in thinking it was going to be about responsive in the context of performance, but liked the actual topic better, how to respond to a large range of screen sizes and features to support a wider audience.

Unfortunately, I didn't get to go to any more of the conferences, as the latest flight out to get back to Charlotte was slated for 5:50ish PM. If I were able to stay, I would have checked out Enterprise Users Bill of Rights: 10 Things Every Developer Must Know about User Experience, and probably Validating Data in OData for Mobile Solutions, though the track record for OData sessions was sketchy up to that point.

I guess long story short, Saturday was definitely a better return on investment than the first two days were, and if we were local developers, it would have been great either way. Having paid (our employer, not personally) for tickets, plane, hotel, lost work etc the value just wasn't there. If I want basic 101 classes, I can get them free right here in Charlotte. If I am going through the drama and expense of flying somewhere, I am expecting my brain to hurt when I get back.

Recommendation for next year? I think we are going to pass, if it was local, we would go for sure, but we aren't interested in travelling to it.

Code Palousa Day Two

The day started with a keynote called 'The next generation of Dinosaurs' by Billy Hollis (Next Version Systems). Billy is a great speaker and really gave an excellent presentation. He talked about the time when COBOL stopped being the dominant ecosystem, and the current paradigm of the OO/Java/.NET generation took over. He talked about how very intelligent people who were very good in the ecosystem were just unable to come across to the new ecosystem and how we are in the process of changing ecosystems again with the shift to always on/mobile/craziest things ever coming down the pipe.

He gave a couple of really good things to watch for as the world changes. He talked about how so many of the .net people are so into TDD and how they insist we can't live without it etc, and his answer was excellent. He said 'forget the technology and process and focus on being awesome.' (paraphrased etc).

His point was, if you are awesome and take pride in doing things the best way you can, the tools and processes will fill themselves in. We see the side effects of forgetting this everyday. When all you have is a hammer...

He also mentioned Lightswitch, and how it was so ridiculously ridiculed by .net developers without being seen in the proper context, and I have to admit, I did the same. I am definitely going to be checking it out later this week with a bit more open of a mindset.

He also reminded me of something that I try to keep at the forefront of my mind every time I work on a project. Development is easy, and there really isn't anything we can't do. This means that making something possible that wasn't possible before for you client/business/etc is no longer enough. You have to make it easy for them to use and awesome.

For the first session of the day I went to 'Metro, Metro, Metro', which was sold as a 'deep dive into the crux of Metro' by 'Samidip Basu'. It was so ridiculously basic and end userish that I have purged it from my mind to free space, so I have nothing to say about it except it was a waste of my time.

For the second session, I decided to try another Metro session, called 'Intro to Windows 8: The Windows 8 Platform for Metro Style Apps' by Jennifer Marsman (Microsoft). This one was again to basic, but it didn't really try to sell itself as anything else, so not enjoying this one was my own fault.

For session 3, I went to 'Advanced Configuration of WCF Data Services for Producing oData' by Chris Woodruff (Perficient) again, that claimed 'This track will give deep knowledge into the configuration and extensibility of the WCF Data Service/OData feed. It will also teach developers to secure their feeds through multiple user authentications such as OAuth, Windows and Forms Authentication.' He did cover paging in a way that gave me some ideas about overlapping server and client side paging to keep the user from having to wait for the server side paging.

This session was so ridiculously basic that I finally had to pick up the tablet and provide feedback through Event Board, and iirc the only authentication it covered was telling you it would use whatever IIS was using. Silliness.

For Session 4, John, Chuck and I went to 'How to Make Your Application Awesome with JSON, REST and WCF' by James Bender (Improving Enterprises). This session was ok, but pretty dry, the only 'awesome' thing that happened there was John banging out a metro app tied to the Netflix wcf dataservice while the presenter went on about things.

The last session of the day was ridiculous. It was called 'Application Security: What you don't know can hurt you' by Joe Kuemerle and he was without a doubt a solution looking for a problem. He basically went and turned off all of the built in things that .net does to keep you secure and then railed about how insecure Microsoft's stuff was and showed a bunch of crazy examples that can't work unless you purposely misconfigure things. And I mean purposely to the point of you couldn't do it accidently. I need to make sure to give feedback to this event. We left this one early and wrapped up for the day.

Code Palousa Day One (March 15th Workshops)

I chose to go to the session 'HTML5 techniques you can use today' by Burke Holland (Telerik).

The first 2 hours, we hadn't covered anything. I literally mean anything. The closest we came to talking about HTML was defining who the W3C was. The rest of the time was spent bashing Microsoft and IE. Now don't get me wrong, I agree with everything they had to say, but I didn't fly to a 3 day conference to giggle at 12 year old jokes about IE 6.

Around the two and a half hour mark, they covered polyfill, which is cool but my patience had worn out. John and Chuck (coworkers) said they conference they were in was awesome, so I headed down that way.

John and Chuck were in a Windows 8 conference by Chris Eargle (Telerik), but it was going to be an install and check out Windows 8 and no one else really showed up. I think there were 2 other people there besides John and Chuck and everyone had already installed Windows 8 before coming to the conference. Chris was doing a great job giving an awesome presentation anyhow, covering the use of func/lambdas/delegates and some cool linq and fluent things. I am sad I missed most of it, but it was still much better than staying in the HTML 5 conference could have been.

After lunch I headed to the 'oData workshop' giving by Chris Woodruff. He seems like a really bright guy, but the topics covered were way to 101, nothing was covered that wasn't wouldn't be answered in 5 minutes on Google. I had really high hopes for the oData workshops since we are going to be leveraging it so much at work very soon.

Windows 8 in one Word...

Fail.

This isn't said lightly, I have always been a Microsoft kind of guy, but if Microsoft is planning on shipping this (I am posting from it now) operating system in the next 12 months, it can't do anything besides fail.

Are things stable, sure. Do I see crashes etc? No, not really.

However, I am a Windows guy, been using Windows since...well, since Windows came out.

I bought an iPad, and having never used any of the Apple OSes that had GUIs, it was very easy to use, very intuitive.

I bought an Android tablet (Asus Transformer, absolutely love it), never really doing anything in Linux, very intuitive, very easy to use, but slightly below ease of use of the iPad.

Then Windows 8 comes out. I have installed it on my work laptop, my home workstation, and went out and bought a tablet (Acer Iconia W500, love it, not digging the dock after using the Transformer's *awesome* dock).

The Windows 8 user experience is a wreck. Using it from a keyboard and mouse, and using it from a tablet are literally like having to learn two OSes. Everything behaves totally different. I've been using Windows all of my life practically and it is the first OS I have used in the last decade where I literally started thinking I need a manual. I find myself looking on the internet looking for hotkeys for things because it is so much less efficient to navigate to anything that isn't on the start screen than it ever was in prior versions of Windows.

And god forbid you have 2 monitors. It's all like 'hey look, I get a task bar on both screens now! Welcome to 10 years ago!" Then you realize it is only an illusion. So far it looks like they only mirror each other, so it isn't really providing any value. And, awesomely enough (not), if you move the one with the clock to your other monitor so you can, I don't know, SEE THE TIME, that is now where metro loads, so it again covers the clock.

Also, metro seems to be so half baked as to be ridiculous. The back button on the mouse doesn't go back, the escape key doesn't close the charm/menu/whatever you pulled up, except, oh wait, sometimes it does. If you are working on the desktop and open metro, and then click on your app on the other screen, metro goes away. However, if you do the same thing, but this time open an app before clicking back to an app outside of metro, metro just returns you to the start screen. It's like rolling dice to see what behavior I am going to see at any given time.

If you open a movie or music in the metro app, you can't lower the volume of the music without lowering it for all of Windows. And if we take this a bit further, technically, it should be a Metro feature, you should be able to individually control any apps volume in Metro, since it is the fancy new interface. Come on, give us 2012, not a worse version of 2000.

Removing plugins from the browser in Metro. Now this one is interesting, I understand, and I think it is the right answer, but give us some codec support. Nothing says lovin like not being able to visit any media sites without hitting the desktop IE or installing a 3rd party browser.

They are calling this a consumer preview, but all I can see it doing is helping Apple sell more iPads. The company I am working at is looking at possibly arming a large percentage of its workers with iPads, and if I went to the powers that be and pitched them on Windows 8 instead, my next blog post would be about me, looking for a job.

Microsoft is struggling lately, and Windows 8 sure isn't the cure.

Entity Framework, oh how you cut me

So, Linq to SQL is awesome, but I have never really much cared for Entity Framework.

At work, we are moving to using WCF Data Services for our database access, and using Entity Framework since configuring WCF Data Services to use linq to sql is about as pleasant as punching yourself in the face...3 or 4 thousand times.

So, today I needed to add a view, a simple thing really that did bascially 'select distinct somecolumn from table where somecolumn is not null'. I drag and dropped it on the design..8 times. It never actually took.

After some discovery, I notice that down in the bowels somewhere it was gently telling me there was a problem, but not really telling me what. Interestingly if you open the edmx in notepad, you will notice it added my view, except it commented it out  stating the view 'does not have a primary key defined and no valid primary key could be inferred'.

Awesomely there isn't any way to tell it that column is the inferred private key, can we move on. Instead, I end up following an article on MSDN telling me how to manually edit the edmx file to add about 4 thousand new things to get it to recognize it and let me use it.

Of course I then had to add another table later, so I had to redo it all again.

Humorously, the MSDN article says 'modify your database schema so that each table has a primary key or so that one or more columns of each table or view is non-nullable or non-binary', which I tried, the view had distinct, non null, where is not null etc all in there, but it refused to work by conventional means.

It is no wonder to me why Microsoft has so much trouble trying to kill off linq to sql when EF is such a drama queen, and so often.