Visual Studio Emulator and Android 7 or higher

This post is about how to debug Android with using Hyper-V to debug Android 7 or higher machines in Visual Studio. This is a scenario because it is not possible to use the Intel HAXM virtualization driver in parallel with Hyper-V but this driver is required to run a performant Android emulated machine using the official Android emulator.

So here is how to debug Android version that are not available in the “Visual Studio Emulator for Android” set of machines.
First you need to download Android by using the Android x86 project as a source:
Download the Android version of your favor.

While downloading, you can create a new Hyper-VM. The important step is, that you disable Secure Boot in the “Security” section. You can use a Gen2 machine (tested with Android 7.1). You also have to select an External Network adapter that has access to the internet. Otherwise you will have problems to configure the virtual Android later on.

When your download is done, you can mount the ISO to the virtual DVD-driver of your VM and start the VM. Follow the dialog to setup the VM until you are at the desktop of your Android VM.
Remark: the usage of the cursor is pretty strange. You can only move it when you click the mouse button. But this also results in a swipe gesture. I haven’t found another way of moving the cursor without clicking. Using the latest Release 7.1 R2 fixes this issue.

When you are at the desktop of the Android VM, you can open the main Menu and open the “Termial Emulator” to get a command prompt. Enter “ifconfig” to show the IP of your VM. Switch to Visual Studio. I expect you have the “Visual Studio Emulator for Android” installed, so you have the control buttons in the toolbar. Click the button, that opens the Android Adb command prompt.



Type the following command in this prompt:

adb connect <ip of VM>

(i.e. “adb connect”)

You should see the message “connected to <ip>:5555”
You can verify the connect by executing “adb devices” and you should see your VM in this list.
Additionally you should have an entry called “Microsoft Corporation Virtual Machine (…)” in your “Start Debugging” combobox that lists all your devices available for debugging.



Now you can start debugging almost every version of Android that is available. Have fun with it!

Hint: If your VM goes to sleep, hold any of the arrow keys for a while (let’s say 30 sec) and connect it again via Adb Command Prompt.

Solving Problems with RDS License Manager

Lately I had a RDS Terminalserver that was a Stand-Alone server. So all services were installed on this one Server (Windows Server 2012 R2).

I had a RDS User CAL for 10 User CALs. They were installed. After a crash of the server because the connection to the Shared Storage for the VM was lost, the users were not able to login to the server anymore. In the Remotedesktop License Manager the CAL was available with a Total of 10 CALS but with 0 available and 0 in use. In general it should be available + in user = total.

I reinstalled the RDS License Manger Feature without any changes. I searched the Web and finally found the solution here:

The solution is:
1. Disable the License Server in the License Manager (Right Click the Server => Advanced => Deactivate Server)
2. Uninstall the License Server Feature. Your server have to restart to finish this action.
3. Rename the Folder C:\Windows\System32\lserver to lserver.old (or something else). This resets the License server incl. the currently available CALs. That way you will be able to reinstall them.
4. Install the License Server Feature (no restart required)
5. Activate the Server in the License Server Manager (Right Click the Server => Activate Server)
6. Install and activate the CALs

The result will be a total amount of 10 CALs where 10 are available and 0 are in use (until the first users will connect).

Optimize Ads with Microsoft AdMediator or Universal Ad Client SDK

Hello everybody,

the last days I tested many possibilities according to Ad platforms on Windows Phone 8.1 and Windows 8.1 (Windows UI). My biggest challenge was, that there is a leak of SDKs for the Windows platform in general. The most annoying thing is, that Google isn’t supporting Windows (Phone) 8.1 and above, if you are using the default XAML/C#-Apps. They have an SDK for WP8 but its worthless for WP8.1. That thing is so annoying, because if you ask anybody that is developing apps for mobile platforms and is using ads to finance them, they say: use Google. But obviously this is not possible on modern Windows Phone/Windows Mobile platforms at the moment.

So I had to check, what I can do, because I was unsatisfied with this ugly text-banners, that want sell me strage things. I also found no option to disable this gambling- and diet-ads in the Dev-Center of Microsoft.

The first thing was: Search another provider for AdMediation that has more than two providers (Microsoft and Smaato), that pay you for ads. (AdDuplex is a third one, but it is a click-trade-provider without monetization).
I found some recommendations for MobFox and setup an account to test it. The first thing I recognized: they don’t have a SDK for Windows Phone. The second thing I recognized: they have an API (Google has not!). So I created a control for myself to present the MobFox provided ads. I simply used a WebView and show the HtmlString-Property MobFox provides. The problem is: the WebView is performing a fit-to-width of the content and the content MobFox provides has a width of 1024px, even if you tell them you want 320px banners. After some researching I also fixed this and started testing. It worked until Amazon Audibles provided an App that is larger than 320px. That was really frustrating. I figured out, that there is another option to get ads from MobFox by API. I used the “TextAd”-API for my first attempt. But there is also a “native”-API, that provides images instead of HTML. That would solve my problem, so I implemented also the native-API… and was frustrated again. Except my Fallback-Ad for this Blog, there was no Ad delivered. A whole day long.

I finally came back to the Microsoft AdMediator. But not because I want to use Microsofts Ugly-Text-Ads. There is another option I wasn’t aware of: Smaato. They are also able to do admediation with ads from other networks. Also with ads from MobFox. So I setup the networks in the Smaato-Environment and configured the AdMediator to use 100% Smaato and Microsoft only for Backup. Right after doing this, I got nicer banner-ads instead of text-ads. And this ads were for games and not for diet, fitness, getting rich in just one minute and so on.

So at the moment my recommendation for using ads is to use Smaato. But: Don’t ask me about CPMs. Currently I have to wait and check what will happen after I released my next App update in the next weeks.

One more thing about the old Microsoft AdMediator for Windows Phone 8.1 and the new Microsoft Universal Ad Client SDK:
Currently I only have a Windows Phone 8.1 app and I am using the Microsoft AdMediator but when I will switch to Windows Universal App for Windows 10 (Mobile), I will not use the Microsoft Universal Ad Client SDK. There are MANY problems with this regarding the comments in the Visual Studio Gallery. I will switch to the Windows 10 (Mobile) SDK of Smaato! Yes, they have an SDK for Windows 10 that seems to work!

Microsoft AdMediator
Microsoft Universal Ad Client SDK
Smaato Windows 10 SDK (also Available via Nuget)

Originally posted on February 20th 2016

More from the AdMediator Control

Hi Guys,

I’m still working on the AdMediator Control for my app and I though I found a bug, that is more a misconfigure of the control, but I like to share it with you.

I created an Ad UnitId in the DevCenter of Microsoft with the type “Video interstitial”. My expectation was to get animated banner for my app. So I entered the new UnitId to my app and start debugging. After some refreshes (sometimes some more refreshes, sometimes the first load) my app crashed because of an UnhandledException in win32. I am catching UnhandledExceptions in my app, so I was confused. I figured out, that if I disabled “Microsoft Advertisement”-Network for my AdMediator Control, the problem was gone. So I continued testing and figured out, that the problem only exists, if compile my app in x64. If I compile my app in x86 the app don’t crashes, but I get a text in my banner called “FreeWheelFreeWheel” or “FreeWheelFreeWheelFreeWheel”.

I reported this to Microsoft and get a rapid answer (much faster than I assumed!):

Kristian, if the unit was created for video interstitials, it cannot be used in mediation or with AdControl.  The only use case for such an AdUnit is in the RequestAd method from InterstitialAd class.
That said, we should never crash, and for that behavior I’ve filed bug 4786896.
My guess is that if text “freewheel” showed up in the WebView control, it means we injected the VAST payload (meant for video ads) into the container. WebView itself, or the edge engine is probably going to show in the stack.

That is a clear and good answer! Thanks Microsoft!

Originally posted on October 1st 2015

WNS PushChannelURI is…

I just wasted two hours to figure out why the PushChannelURI in my Windows Phone Emulator has a PushChannelURI that is…… but usually it should be something like…..

When this PushChannelURI is detected and you’re trying to send something to that URI, you would get an error, that this servername is not resolvable. The answer is simple: You have the Notifications-Simulation activated in your Emulator. Disable it, reinstall the app on the Emulator and your will have a regular Channel URI for the WNS back.

Happy testing!

Originally posted on September 12th 2015

AdMediator for Windows Store Apps

Time for my first blog-post.

Update: Everything mentioned here belongs to the new DevCenter of Microsoft, but NOT to Universal Apps for Windows 8.1
Update2: I added information how to solve Error “AM007 We couldn’t add all the required references”

This week I struggled around with the Ads for Windows Store Apps. Microsoft changed the handling of it when they introduced Windows 10.
The Microsoft AdMediator-Control is the Control, that provides the Ads in .Net – as long as you don’t use another 3rd Party thing.

My problem was: I added the control and tried to configure it, like it is described on one of many pages, Microsoft has saved very fragmented in the MSDN:

After I added the control I saw none of the properties, that are described by Microsoft in the example. So I added it by myself. But: What is the ID-Property for? Is it something defined or is it something I can choose by myself? The last question is the correct answer. It is an ID, that is used by your app to identify the Banner. In other Words: it is a second “Name”-Property. But the difference is, that you should never change the ID of that control, because that will break all statistics Microsoft records for you. The Name-Property can be changed at any time.
The next Properties are Width and Height. You need to set them. “Auto” or “*” will not work. The AdMediator Control requires fixed values.

After I finally added the control to the Page, I had to configure the adds. That is really fiddly, but it is also described in the link above. I tried to add the Microsoft-Advertising Service and Smaato. I failed with Smaato. I restarted Visual Studio. No change. Googled a bit: nothing helpful. Finally I figured out, that the resources for the AdProviders are stored in the bin-directory. I closed Visual Studio and deleted the folder. I started Visual Studio and tried it again. It work – Thanks!
I hope now it will work.

After some more weeks I reorganized my projects and solutions. After I did this, my project didn’t build anymore because it cannot find the Namespace “Microsoft.AdMediator.Core.Models” anymore. I checked the references and the message was correct: My AdMediator-Assemblies were gone. Only the References for the Smaato-Provider were still present. In the “Connected Service…”-Dialog the Microsoft Advertisment network was in status “Not Fetched”. When I tried to readd it (removed and add again) I got the Error “AM007 We couldn’t add all the required references. (…)”.
First I tried the solution above, but it didn’t worked.
The final solution for me was:
1. Remove everything related to the AdMediator from your project. References, usings, XML-Namespaces in the xaml-Files, Methods, Events etc.
2. Build your project until it runs without the AdMediator
3. Close Visual Studio
4. Go the the folder were your NuGet-Packages are stored. The folder is named “packages” and is usually next to your Solution-File (*.sln). Delete everything related to the AdMediator, AdDuplex and Smaato. If you are not sure, you can also delete the whole folder, but then the missing libraries have to be downloaded again.
5. Go to your project-folder and delete the bin- and obj-folder
6. Open the package.config in your project-folder with a text-editor. If there is anything related to AdMediator, AdDuplex or Smaato, delete it.
7. Open your Solution again in Visual Studio. Go to the Designer and Drag’n’Drop the AdMediator-Control (not the “AdControl”!). The AdMediator-Control was at the bottom of the Toolbox for me.
8. Configure your control as it was before. If you just comment old control out, you can replace the Drag’n’Drop-Created code by your old one.
9. Check if your project builds (it should)
10. Right Click “References” in the Solution Explorer and select “Add” -> “Connected Service…”. Select “Ad Mediator” and click configure. There should be a “Fetched” now next to “Microsoft Advertising”.
11. Configure your “Microsoft Advertising”-Network by click on the “configure” link. If you are done, click “Add” (but it is more like “OK”).
12. Check if your project builds (it should)
13. Open the Ad Mediator configure dialog again and add the Smaato-Network. It should download the Smaato Libraries and finally results in a “Fetched” too. Don’t forget to configure Smaato after this.
14. Repair everything you destroyed in Step 1 and you are done.
15. If you change the Id of the AdMediator-Control in Step14 (or after configuring any network), you have to open the “Connected Service”-Dialog to Update this in the Ad-Config. If you not open the “Connected Service”-Dialog again, you a Debug-Output in the Output-Window like “Exception thrown: ‘System.NullReferenceException’ in Microsoft.AdMediator.Windows81.MicrosoftAdvertising.DLL”
#Edit2 End

Some more things @Microsoft:

1. Please provide something like a Quick-Start-Documentation INCLUDING the part in the Developer Dashboard. Don’t fragment it over many sites. In the fragmented ones, you can be more detailed – more that it is now!

2. Where can I control the size of the Ads you provide me in the Developer Dashboard?

3. Where can I configure what kind of Ads I like to see? I also wish a Blacklist for companies, that are offering some things to win, if I answer some questions. I don’t want them.

Originally posted on August 20th 2015