Reputation: 39
I'm trying to insert ad in a Windows Phone 8 app using Visual Studio 2013 Ultimate.
I inserted this code in MainPage.xaml :
xmlns:UI="using:Microsoft.Advertising.WinRT.UI"
And my Grid tag:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<UI:AdControl
ApplicationId="----------------------"
AdUnitId="------"
HorizontalAlignment="Left"
Height="500"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="200"/>
</Grid>
Why do I get this error?
AdControl not exist in namespace "using: Microsoft.Advertising.WinRT.UI" Errore2 type 'UI: AdControl' not found. Check for missing a reference to an assembly and all assembly to which you refer have been compiled
Upvotes: 1
Views: 1040
Reputation: 592
Right click on Reference
in your Solution Explorer
window and select Add Reference
.
WINDOWS RT (UNIVERSAL APPS)
Then move on Windows Phone 8.1 Tab and select 'Extensions'. You should find Microsoft Advertising SDK for Windows Phone 8.1 XAML
. Select it and click ok, then rebuild (F6)
WINDOWS PHONE SILVERLIGHT
Move on Assemblies
tab, then click on Extensions
and add these 2 references:
Then you have to add in the XAML page this namespace:
xmlns:adv="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI"
and finally add the advertising control to your page:
<adv:AdControl ApplicationId="YOUR_APPLICATION_ID" AdUnitId="YOUR_AD_UNIT_ID"
Width="480" Height="80"/>
If you're not able to find references, it's beacuse you didn't install the SDK on your computer. Go here, download the right version according to your needs and install it, then repeat the steps.
Let me know if it works!
Upvotes: 1