InterstitialAd advert cancelled when requested - UWP - Windows 10 - win-universal-app

I've just created 2 new Ad Units in my Microsoft Dev Dashboard to handle InterstitialAdon both PC/Tablets and Mobile.
I initialize my InterstitialAd first:
// Instantiate the interstitial video ad
interstitialAd = new InterstitialAd();
// Attach event handlers
interstitialAd.ErrorOccurred += OnAdError;
interstitialAd.AdReady += OnAdReady;
interstitialAd.Cancelled += OnAdCancelled;
interstitialAd.Completed += OnAdCompleted;
Then I've got the following code to request the relevant InterstitialAd advert based on the platform being used:
#if DEBUG
interstitialAd.RequestAd(AdType.Video, "d25517cb-12d4-4699-8bdc-52040c712cab",
"11389925");
Debug.WriteLine("Page_Loaded - RequestAd: " + sw.Elapsed.ToString());
#else
#if WINDOWS_PHONE_APP
interstitialAd.RequestAd(AdType.Video, MAppId, MAdUnitId);
#else
interstitialAd.RequestAd(AdType.Video, WAppId, WAdUnitId);
#endif
#endif
It works as expected when in Debug mode, but when in Release mode, the second the relevant interstitialAd.RequestAd is called, the OnAdCancelled method is called.
I've double checked the values associated with MappId, MAdUnitId, WAppId and WAdUnitId and they all are definitely correct and associated with the correct platform being used.
Any ideas??
Thanks.

This appears to be a bug where if you use slightly more complex conditional statements, it throws this error. I had to change my code to the following to get rid of this error:
var myAppId = "";
var myAdUnitId = "";
//Test Ids
//myAppId = "d25517cb-12d4-4699-8bdc-52040c712cab";
//myAdUnitId = "11389925";
//Windows Store AppId;
myAppId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
myAdUnitId = "xxxxxxxx";
#if WINDOWS_PHONE_APP
myAppId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
myAdUnitId = "xxxxxx";
#endif
interstitialAd.RequestAd(AdType.Video, myAppId, myAdUnitId);
And after having wasted so much time on this, I found out that there is no Interstitial Advert in my region.
Hope this helps others!

Related

unity udp dgram socket not working on hololens

I tried to connect between hololens and python server. So I used dgram socket but this is not working on hololens.
this is my code sample.
hololens client
public string conHost = "192.168.0.58";
public int conPort = 3174;
void Start()
{
ipep = new IPEndPoint(IPAddress.Parse(conHost), conPort);
clientThread = new Thread(setupSocket);
clientThread.Start();
}
public void setupSocket()
{
mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
}
void Update()
{
if(Send)
{
Send = false;
byte[] bytes = Encoding.UTF8.GetBytes("124306324602435");
byte[] buffer = Encoding.UTF8.GetBytes(bytes.Length.ToString());
mySocket.SendTo(buffer, buffer.Length, SocketFlags.None, ipep);
}
}
python server
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
#server_address = "192.168.0.18", 9029
#print('starting up on {} port {}'.format(*server_address))
sock.bind(("192.168.0.58", 3174))
ready=True
while(ready):
try:
epoch_time = time.time()
data,address = sock.recvfrom(100)
fileLength = data.decode("utf-8")
print(fileLength)
except:
continue
When I play this code in unity project, it works. But in hololens, not working.
I used try-catch, I got this error messege on Update
System.NullReferenceException: Object reference not set to an instance of an object [0x00000] in <000000000000000000000000000000000>:0
It occurs because the variable mySocket is not initialized as an expected value. Actually, the implementation of System.Threading has changed in .NET 4.x in a way that is not backward compatible, and the HoloLens app uses IL2CPP scripting backend with.NET4.x but the Unity Editor uses Mono scripting backend with.NET2.x. So, it works in Unity Editor but fails to start your thread in .NET4.x, we recommended that using System.Threading.Tasks class instead. Besides, to use WinRT APIs in Unity projects built for the UWP you need to use preprocessor directives, more information please see:WinRT APIs with Unity for HoloLens

Pubnub library not compiling on Particle Photon

I am trying to publish a message using pubnub on the Particle Photon. The code snippet below comes straight out of the Pubnub example code.
The code will not compile, with the message from the compiler as follows:
PubNub/PubNub.h:87:47: error: expected class-name before '{' token
class PubSubClient: public PubNub_BASE_CLIENT {
^
PubNub/PubNub.h: In constructor 'PubSubClient::PubSubClient()':
PubNub/PubNub.h:23:28: error: class 'PubSubClient' does not have any field named 'WiFiClient'
#define PubNub_BASE_CLIENT WiFiClient
^
The code for this tiny project is as follows:
// This #include statement was automatically added by the Particle IDE.
#include "PubNub/PubNub.h"
char pubkey[] = "<key here>";
char subkey[] = "<key here>";
char channel[] = "Channel";
void setup() {
Serial.begin(9600);
Particle.publish("Serial set up");
PubNub.begin(pubkey, subkey);
}
void loop() {
TCPClient *client;
char msg[64] = "{\"photon\":\"on\"}";
client = PubNub.publish(channel, msg);
client->stop();
Delay (30000);
}
Has anyone had a similar problem, and if so, can you guide me as to how to fix this.
Thanks.
It looks like the library available in Build IDE was in an older version (0.0.1). Fixed, latest version (0.0.2) has been published.
To update library in your app you need to remove the PubNub library from your app in Apps drawer:
And then go to Libraries drawer, find PubNub library, click Include in App, select your app and confirm:

Windows UWP CreateFIle2 cannot read file in ApplicationData.LocalFolder

I am trying to build UWP app in C#. My app has a native library written in C++. Whenever the app tries to read a file in ApplicationData.LocalFolder, CreateFile2 api is returning ERROR_NOT_SUPPORTED_IN_APPCONTAINER. The file exists in the path specified to this api.
This is the sequence of operation in my app.
Launch app. App creates file & writes some data
Later on based on user input app tries to read data in this file
Step 1 is working fine. App is able to create the file & write data in it. Only when app tries to access it later on, does it get this error.
I get the path to ApplicationData.LocalFolder using
Windows.Storage.ApplicationData.Current.LocalFolder.Path
This is the actual path I see in the app:
C:\Users\xxxxx\AppData\Local\Packages\ac7a11e4-c1d6-4d37-b9eb-a4b0dc8f67b8_yyjvd81p022em\LocalState\temp.txt
My code is as below:
CREATEFILE2_EXTENDED_PARAMETERS ms_param = {0};
ms_param.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
ms_param.dwFileAttributes = FILE_ATTRIBUTE_READONLY;
ms_param.dwFileFlags = FILE_FLAG_NO_BUFFERING;
ms_param.dwSecurityQosFlags = SECURITY_DELEGATION;
ms_param.lpSecurityAttributes = NULL;
ms_param.hTemplateFile = NULL;
g_hfile = CreateFile2(filename, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, OPEN_EXISTING, &ms_param);
if (g_hfile == INVALID_HANDLE_VALUE)
{
return GetLastError();
}
I tried CreateFile2 with both OPEN_EXISTING & OPEN_ALWAYS option for dwCreationDisposition parameter, but I see the same error in either case.
I had similar issue with CreateFile2 earlier. But that was an problem with my app & I have fixed that issue. This time though the file is available within the LocalFolder, still I get the error.
The problem here is related to the dwSecurityQosFlags you've set in CREATEFILE2_EXTENDED_PARAMETERS.
When called from a Windows Store app, CreateFile2 is simplified. You can open only files or directories inside the ApplicationData.LocalFolder or Package.InstalledLocation directories. You can't open named pipes or mailslots or create encrypted files (FILE_ATTRIBUTE_ENCRYPTED).
The dwSecurityQosFlags parameter specifies SQOS information. In Windows Stroe app, we can only set it to SECURITY_ANONYMOUS. Using other flag will raise ERROR_NOT_SUPPORTED_IN_APPCONTAINER exception. This indicates that it is not supported in UWP app.
Following is the code I used to test:
StorageFolder^ localFolder = ApplicationData::Current->LocalFolder;
String^ path = localFolder->Path;
path += L"\\MyFile.txt";
CREATEFILE2_EXTENDED_PARAMETERS ms_param = { 0 };
ms_param.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
ms_param.dwFileAttributes = FILE_ATTRIBUTE_READONLY;
ms_param.dwFileFlags = FILE_FLAG_NO_BUFFERING;
ms_param.dwSecurityQosFlags = SECURITY_ANONYMOUS;
ms_param.lpSecurityAttributes = NULL;
ms_param.hTemplateFile = NULL;
HANDLE g_hfile = CreateFile2(path->Data(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING, &ms_param);
DWORD error = GetLastError();
If I don't have "MyFile.txt" under LocalFolder, I will get ERROR_FILE_NOT_FOUND exception, otherwise it will be ERROR_SUCCESS.

Using cef for win64 - How to enable fullscreen

I'm using CEF and have built the cefsimple.exe. I can include any html file to the simple_app.cpp which will start after the doubleclick. But how is it possible to start this cefsimple.exe in fullscreen mode? Which build do I need? I work with VS2013 on a win64 system.
SimpleApp::SimpleApp() {
}
void SimpleApp::OnContextInitialized() {
CEF_REQUIRE_UI_THREAD();
// Information used when creating the native window.
CefWindowInfo window_info;
#if defined(OS_WIN)
// On Windows we need to specify certain flags that will be passed to
// CreateWindowEx().
window_info.SetAsPopup(NULL, "cefsimple");
// my first try: *************************************
/* RECT winrect;
winrect.bottom = 0;
winrect.left = 0;
winrect.right = 0;
winrect.top = 0;
window_info.SetAsChild(NULL, winrect);*/
#endif
// SimpleHandler implements browser-level callbacks.
CefRefPtr<SimpleHandler> handler(new SimpleHandler());
// Specify CEF browser settings here.
CefBrowserSettings browser_settings;
std::string url;
// Check if a "--url=" value was provided via the command-line. If so, use
// that instead of the default URL.
CefRefPtr<CefCommandLine> command_line =
CefCommandLine::GetGlobalCommandLine();
url = command_line->GetSwitchValue("url");
if (url.empty())
url = "file:///C:/Projekte/BOF-WENDT-HTML5/Fullscreen.html";
// Create the first browser window.
CefBrowserHost::CreateBrowser(window_info, handler.get(), url,
browser_settings, NULL);
}
Not yet implemented in CEF, see:
https://code.google.com/p/chromiumembedded/issues/detail?id=562
Update: Changes for this feature have landed https://bitbucket.org/chromiumembedded/cef/issue/562

Finding builds in Team Explorer's "My Builds"

I'm writing a Visual Studio 2012 add-in which extends Build Explorer - basically, I add a context menu option for every build (completed or running, but not queued). Following a blog post about doing this in VS2010, I managed to do so for builds that appear in Builder Explorer - hooray!
Now, my context menu also appear in Team Explorer's Builds pages, My Builds section. However, when I get the callback, I can't find the actual builds anywhere!
Here's my beforeQueryStatus event handler, where I try to find out whether I have a build to show or not:
private void OpenCompletedInBuildExplorerBeforeQueryStatus(object sender, EventArgs e)
{
var cmd = (OleMenuCommand)sender;
var vsTfBuild = (IVsTeamFoundationBuild)GetService(typeof(IVsTeamFoundationBuild));
// This finds builds in Build Explorer window
cmd.Enabled = (vsTfBuild.BuildExplorer.CompletedView.SelectedBuilds.Length == 1
&& vsTfBuild.BuildExplorer.QueuedView.SelectedBuilds.Length == 0); // No build _requests_ are selected
// This tries to find builds in Team Explorer's Builds page, My Builds section
var teamExplorer = (ITeamExplorer)GetService(typeof(ITeamExplorer));
var page = teamExplorer.CurrentPage as Microsoft.TeamFoundation.Controls.WPF.TeamExplorer.TeamExplorerPageBase;
var vm = page.ViewModel;
// does not compile: 'Microsoft.TeamFoundation.Build.Controls.BuildsPageViewModel' is inaccessible due to its protection level
var vm_private = vm as Microsoft.TeamFoundation.Build.Controls.BuildsPageViewModel;
// But debugger shows that if it did, my builds would be here:
var builds = vm_private.MyBuilds;
}
Is there a way to get the list of builds?
More generally, is there a way to get some "window which this context menu belong to"? Currently I'm just looking around in parts of VS I assume would have builds...
I managed to get the build using reflection:
var teamExplorer = (ITeamExplorer)GetService(typeof(ITeamExplorer));
var BuildsPage = teamExplorer.CurrentPage as Microsoft.TeamFoundation.Controls.WPF.TeamExplorer.TeamExplorerPageBase;
var PageViewModel = BuildsPage.ViewModel as Microsoft.TeamFoundation.Controls.WPF.TeamExplorer.TeamExplorerPageViewModelBase;
// PageViewModel is actually Microsoft.TeamFoundation.Build.Controls.BuildsPageViewModel. But, it's private, so get SelectedBuilds through reflection
var SelectedBuilds = PageViewModel.GetType().GetProperty("SelectedBuilds").GetValue(PageViewModel) as System.Collections.IList;
if (SelectedBuilds.Count != 1)
{
cmd.Enabled = false;
return;
}
object BuildModel = SelectedBuilds[0];
// BuildModel is actually Microsoft.TeamFoundation.Build.Controls.BuildModel. But, it's private, so get UriToOpen through reflection
var BuildUri = BuildModel.GetType().GetProperty("UriToOpen").GetValue(BuildModel) as Uri;
// TODO: Use BuildUri...
cmd.Enabled = true;

Resources