Category «Programming»

The Woes of Windows Store App Submissions

I recently submitted a Windows 10 / Windows Phone app to the Windows Store named Data Viewer for Dota 2. I’m here to warn the world just how awful the process of submission can be.

Microsoft first created the concept of the Windows Store with the release of Windows 8, Windows RT, and Metro Apps — I mean Windows Store Apps — I mean Universal Windows Apps. Whatever you want to call them, the store quickly became an unregulated messy disaster full of copycat and scam apps. Many, many apps were nothing more than front ends to scamming websites, copies of things like Facebook, or general do-nothing apps with a price tag and description which made it seem like a good purchase.

In order to address this problem, in normal Microsoft fashion, Microsoft decided to wait 3 years and come up with a new process of submitting the app. Every app would be held to “rigorous” standards which would guarantee all apps were clearly named and labeled to prevent confusion and scams. There are several guideline posts out there from Microsoft, and you can rest assured that all of them are vague and barely helpful.

So how did this affect my app? Originally, the app was named “Dota Database” after its sister site and had the same icon as appears on that site. The first submission resulted in this super helpful message: The app name and icon do not accurately represent the features.

Uh…OK? I’m not sure it could

Continue reading

How to Rename Your App in Windows Store

This applies to the Windows Store and Windows Dev Center as of March 1, 2016 and assumes you are uploading a Windows 10 Universal Platform App.

The Windows Dev Center started out badly back in Windows 8, and it hasn’t improved too much since then. I have to be honest when I describe it, because it’s sometimes nothing short of painful. One of those pain points is the UI and poor documentation regarding the concept of the “App Name”.

In order to submit to the store, you need to create “App Packages”. Each package has metadata associated with it that you define in your “App Manifest” (Package.appxmanifest in your project). This manifest is where the app’s name must match exactly with whatever names you have reserved in your Dev Center for that app.

Creating the App Name

When you create an app submission, you have to pick an “App Name”. This is the name that is displayed across your Dev Center Dashboard and the Windows Store. This name also has to match exactly in your app’s created manifest. That secret bit of information isn’t documented well and seems to only appear in tiny text when you are creating an app package through Visual Studio.

Changing the App Name

If your app has not yet been submitted to the store, then you can change the name by reserving a new one in the Dev Center, changing the manifest to that name, creating an app package, and then uploading that package.

Continue reading

Share a Generic XAML ListView, ItemsSource, and DataTemplate with UserControls in Windows Universal Apps

This post applies to Windows Universal Apps specifically. These techniques probably won’t work with WPF or Windows 8/8.1 Apps because the XAML hierarchy and namespaces are different.

The title is certainly a mouthful, but stick with me to understand where this scenario can be useful.

Let’s say you want to re-use a ListView without copy and pasting everything about it wherever you need it. Simple enough, right? Just put it in a UserControl! Not so fast. What if you want to define the ListView’s ItemsSource from one level above the UserControl? It gets a little more complicated. This is especially true if you want to take advantage of a VisualStateManager with the ListView’s ItemTemplate.

CustomListView

For example, I had a UserControl which allowed users to scroll left/right on a ListView by clicking buttons left/right instead of using a scrollbar. I wanted to share this ListView in multiple places,  but didn’t want to restrict the UserControl to a single ItemsSource by hard coding it in the UserControl itself. I wanted to “pass in” the ItemsSource and DataTemplate to define the layout of the items from one level above the UserControl. Additionally, I wanted the layout to change based on the width of the screen to work with phones, tablets, and wide layouts.

So here’s what I did after a few hours of struggling through wildly varying documentation across WPF, Windows 8/8.1, and Windows Universal Apps.

Creating the DataTemplate UserControl

We first need to define the lowest level of the chain to determine

Continue reading

A Quick Reference to Azure Key Vault via Powershell

Azure Key Vault has been generally available in certain regions since June 2015. You can’t use the Azure Portal to work with the key vault yet, so you have to drop down into Azure Powershell and run a few commands. It’s a little confusing to get started since development is ongoing and Azure Powershell itself changes frequently.

Here’s how I have been achieving some simple Azure Key Vault commands via Azure Powershell. I’m using Azure Powershell version 0.9.8, so keep that in mind if you’re comparing these commands to the Getting Started guide linked previously in this article.

Check Your Azure Powershell Version (optional)

If you don’t know what version of Azure Powershell you’re using, try this:

Switch to AzureResourceManager Mode if Necessary (optional)

Since you’re using version 0.9.8 like me, you need to switch into Azure Resource Manager mode.

Login to Azure

Login to your Azure account and enter your credentials in the popup window. It seems kind of odd that it wouldn’t just make you login via Powershell parameters.

Create a Resource Group (optional)

You need an Azure Resource Group to add the Azure Key Vault to. If you don’t have one already, create it now. If you already have one, skip this step.

Create a Key Vault

Continue reading

A Quick Reference to Creating NuGet Packages

All of the following commands should be executed in the folder containing the project from which you want to create a package.

nuget spec – Create a .nuspec file which contains meta-data about the package such as author, description, and title. You will need to edit some of the values in this file when you first create it.

nuget pack <.csproj file name> -Prop Configuration=Release – Create a .nupkg file containing the compiled contents of the project specified in the first parameter. Optionally target a specific configuration.

nuget push <.nupkg file name> – Push the NuGet package up to your NuGet.org account.

More complete documentation here.

Continue reading

How to Rollback Entity Framework Code First Migration

The code first approach to using the Entity Framework can be extremely helpful in creating a new database while staying entirely within your C# code base. If you’re more comfortable with creating plain old class objects (POCO) and then having those translated into SQL driven structures, code first is for you. That said, the process by which updates to the code base are pushed to the database (migrations) can be a bit frustrating to use at times. Not all SQL Server features are supported in a code first approach. In addition, migrating your structures in Azure has its own set of problems.

If you want to roll back to a previous migration due to an error in the current migration or wanting to rewind and start over, the following command can be used from the Package Manager Console in Visual Studio. This will rewind and undo any migrations between the current and the “migration-name” migration.

For example, if you have the following history of migrations in your project where the * indicates the current migration:

  • 201506042221067_RemoveColumn1
  • 201507031735200_AddColumn2
  • 201507044516322_CreateNewPersonTable
  • *20150731124746_SomeBrokenMigration

Use this command to roll back to the “AddColumn2” migration. Notice that the timestamp on the migration name is not included in the command.

The migration history will then look like:

  • 201506042221067_RemoveColumn1
  • *201507031735200_AddColumn2
  • 201507044516322_CreateNewPersonTable
  • 20150731124746_SomeBrokenMigration

Notice that the migrations which were rolled back were not deleted. The next time you

Continue reading

Custom authorization with ELMAH and ASP.NET Identity Framework

If you’re using any of the most recent ASP.NET MVC 5 project templates with authentication and authorization built in, then you’re probably using the ASP.NET Identity Framework. With any ASP.NET project, it’s smart to add references to the ELMAH library just in case any unhandled exceptions occur. You can use both of these libraries together to restrict access to the remote ELMAH page with custom authorization.

First, install the Elmah.MVC package from NuGet. This should download the correct libraries and add the necessary lines to your web.config.

Substitute the “your_user_name” entry with your own username that you’ve setup in the ASP.NET Identity Framework backend. For example, the AspNetUsers table in SQL Server contains your usernames. It appears that ELMAH does get the authentication information from the current thread principal, which the ASP.NET Identity Framework will establish on your behalf upon login.

Continue reading

The required anti-forgery cookie “__RequestVerificationToken” is not present.

In your ASP.NET MVC adventures, you may come across the following error when loading a view.

The required anti-forgery cookie “__RequestVerificationToken” is not present.

After searching Google for awhile, you might become desperate with the many different solutions presented. Normally, the solution to this issue is related to the ValidateAntiForgeryToken attribute on actions. When accessing a GET action, you don’t need to use the anti-forgery token.

However, this is not the only solution. In my case, my web.config had this entry:

Checking the project settings in Visual Studio revealed that my project was not set to use SSL which caused a conflict. Either comment out the above line or set the project to always use SSL.

Continue reading

Fixing Error 5: Access Denied when Starting a Windows Service

After creating your own Windows Service, you may encounter the following error:
53rgc

Sounds serious, but it’s not. It’s complaining that executable can’t be started because the account under which the service is running does not have access. When you installed the Windows Service, you had to choose a context like Local System, Local User, Network User, or something custom. In order to fix this issue, you need to give execute permissions to the user you chose. For example, NETWORK SERVICE account may need permission if that’s the context you chose to run the service.

Even after that hard work, you might still see an error like below:
Fp6Zq

This is a more generic error which indicates that something threw an exception during the OnStart method of the service. Since it’s so generic, there’s not really one solution to the problem. You need to check the Application Log in the Windows Event Viewer to understand what faulted the service. In some cases, it could be a bad application configuration (as one example).

Continue reading

Installing XNA 4 on Windows 8 / 8.1

Microsoft has long since abandoned XNA improvements, but that doesn’t mean you have to stop using the framework entirely. If you’re interested in installing the XNA framework on Windows 8 and 8.1, it can be a little tricky. Follow these steps.

Option 1

Source: http://blogs.msdn.com/b/astebner/archive/2012/02/29/10274694.aspx

  1. Download and install the latest version of the Games for Windows – LIVE Redistributable from http://www.xbox.com/en-US/LIVE/PC/DownloadClient
  2. If you are installing the Windows Phone SDK 7.1, re-run setup and choose to repair it. This will re-run the previously failing XNA Game Studio installers and they should install correctly this time.
  3. If you are install a standalone XNA Game Studio product, re-run setup and it should install correctly this time.
  4. If you are planning to do Windows Phone development, you should also install the Windows Phone SDK 7.1.1 Update after installing the Windows Phone SDK 7.1. This update fixes an issue that prevents the emulator in the Windows Phone SDK 7.1 from working correctly on Windows 8.

If you are installing the Windows Phone SDK 7.1, you can use the log collection tool to gather your setup log files. This log collection tool will create a file named %temp%\vslogs.cab.

If you are installing XNA Game Studio, you can find log files at the following locations:

  • XNA Game Studio 4.0 Refresh – %temp%\XNA Game Studio 4.0 Setup\Logs
  • XNA Game Studio 4.0 – %temp%\XNA Game Studio 4.0 Setup\Logs
  • XNA Game Studio 3.1 – %temp%\XNA Game Studio 3.1 Setup\Logs
  • XNA Game Studio 3.0 – %temp%\XNA Game Studio 3.0 Setup\Logs
  • XNA
Continue reading