BandIOException when adding custom page layout to Microsoft Band tile (Store binary ONLY) - microsoft-band

I am creating a Microsoft Band app that uses the new custom page layouts. I am using Microsoft Visual Studio Community 2013 update 4. I have everything working properly and the app works great on my test environment (i.e. when I push the app from my computer to my phone). However, once I create the store build and create a beta app package and download it from the store and try to install the Band tile via the app I get an Exception. I repeat, I do not get an exception when I install the Band tile via the app, when the app is pushed from my dev environment, but I do when the same code is used to create an app package and the process repeated, but with the newly downloaded binary.
The Band tile is successfully added to my band, but my band app only has the first of the 5 custom page layouts that I try to add. I know this after much trial and error (dozens of beta app packages uploaded to the App Store).
I have solicited other beta testers and they all receive the same exception.
Here are the Exception details
Microsoft.Band.BandIOException:
Exception of type 'System.Resources.MissingManifestResourceException' was thrown. ---> System.Resources.MissingManifestResourceException:
Exception of type 'System.Resources.MissingManifestResourceException' was thrown.
at
System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at
Microsoft.Band.BandResources.get_CommandStatusError()
at
Microsoft.Band.BandClient.CheckStatus(CargoStatus status, CommandStatusHandling statusHandling)
at
Microsoft.Band.BandClient.DynamicPageLayoutSetLayout(Guid appId, UInt32 layoutIndex, PageLayout layout)
--- End of inner exception stack trace ---
at
Microsoft.Band.BandClient.DynamicPageLayoutSetLayout(Guid appId, UInt32 layoutIndex, PageLayout layout)
at
Microsoft.Band.BandClient.AddTileOutsideSync(BandTile tile)
at
Microsoft.Band.BandClient.<>c__DisplayClass9b.<AddTile>b__9a()
at
Microsoft.Band.BandClient.RunUsingSynchronizedFirmwareUI(Action insideSync, Action afterSync)
at
Microsoft.Band.BandClient.AddTile(BandTile tile, Guid applicationId, IReadOnlyList`1 installedTiles)
at
Microsoft.Band.BandClient.<>c__DisplayClass6f.<<AddTileAsync>b_6c>d__71.MoveNext()
-- End of stack tracke from previous location where exception was thrown ---
After much all the trial and error I have simplified the problem to the following code. It produces the error when the binary is retrieved from the App Store and the method is executed. However, it doesn't produce any errors when the binary is pushed from my local computer via Microsoft Visual Studio 2013 Environment and the method is executed. Additionally, if I remove the line that adds the custom page layout and send my app through the store and test, there is no exception thrown.
public async Task CreateBandTile() {
try
{
Guid tileId = new Guid("2D3A78E2-84BB-4E56-AFEB-B160B2433E20");
IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync();
IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]);
BandTile myTile = new BandTile(tileId)
{
Name = "My Band Tile",
TileIcon = await LoadIcon("ms-appx:///Assets/IconLarge.png"),
SmallIcon = await LoadIcon("ms-appx:///Assets/IconSmall.png"),
IsBadgingEnabled = false
};
FlowPanel page = new FlowPanel(
new TextBlock()
{
ElementId = 1,
Rect = new PageRect(0, 0, 100, 30),
Font = TextBlockFont.Small
}
)
{
Rect = new PageRect(0, 0, 245, 30)
};
// *** If I remove the following line, no exception is thrown ***
myTile.PageLayouts.Add(new PageLayout(page));
// Remove the Tile from the Band, if present.
await bandClient.TileManager.RemoveTileAsync(tileId);
// Create the Tile on the Band.
await bandClient.TileManager.AddTileAsync(myTile);
}
catch (Exception)
{
throw;
}
}
What am I doing wrong here? Maybe I am the first developer to send an app through the MS app store that uses custom layouts. I feel like there is a bug here that is on Microsoft's end.

The bug has been resolved with the release of the new Microsoft Band SDK.

Related

How to correlate two AppInsights resources that communicate through NServiceBus?

Currently, I have dozens of .NET services hosted on various machines that show up as Resources on my AppInsights Application Map, which also shows their dependencies with respect to each other, based on the HTTP requests they make.
However, the relationships between services that communicate through NServiceBus (RabbitMQ) are not shown. Now, I am able to show the messages that are either sent or handled by a service via calls to TelemetryClient.TrackXXX(), but not connect Resources on the map using this information.
I have even gone so far as to attach the parent operation ID from the NSB message sender to the message itself, and assign it to the telemetry object in the receiver, but there is still no line drawn between the services in the Application Map.
To reiterate, this is what I'm getting in the Application Map:
(NSB Message Sender) --> (Message sent/handled)
And this is what I want:
(NSB Sender) --> (Receiver)
The services in question are .NET Core 3.1.
I cannot provide the code, as this is for my work, but any help would be greatly appreciated. I've searched everywhere, and even sources that seemed like they would help, didn't.
(not signed in, posting from work)
Alright, I finally got it. My approach to correlate AppInsights resources using their NSB communication is to mimic HTTP telemetry correlation.
Below is an extension method I wrote for AppInsights' TelemetryClient. I made a subclass named RbmqMessage:NServiceBus.IMessage, given my applications use RBMQ, and gave it the following properties for the sake of correlation (all set in the service that sends the message) :
parentId: equal to DependencyTelemetry.Id
opId: value is the same in the sender's DependencyTelemetry and the receiver's RequestTelemetry. Equal to telemetry.context.operation.id
startTime: DateTime.Now was good enough for my purposes
The code in the service that sends the NSB message:
public static RbmqMessage TrackRbmq(this TelemetryClient client, RbmqMessage message)
{
var msg = message;
// I ran into some issues with Reflection
var classNameIdx = message.ToString().LastIndexOf('.') + 1;
var messageClassName = message.ToString().Substring(classNameIdx);
var telemetry = new DependencyTelemetry
{
Type = "RabbitMQ",
Data = "SEND "+messageClassName,
Name = "SEND "+messageClassName,
Timestamp = DateTime.Now,
Target = "RECEIVE "+messageClassName //matches name in the service receiving this message
};
client.TrackDependency(telemetry);
msg.parentId = telemetry.Id;
msg.opId = telemetry.Context.Operation.Id; //this wont have a value until TrackDependency is called
msg.startTime = telemetry.Timestamp;
return msg;
}
The code where you send the NSB message:
var msg = new MyMessage(); //make your existing messages inherit RbmqMessage
var correlatedMessage = _telemetryClient.TrackRbmq(msg);
MessageSession.Publish(correlatedMessage); //or however the NSB message goes out in your application
The extension method in the NServiceBus message-receiving service:
public static void TrackRbmq(this TelemetryClient client, RbmqMessage message)
{
var classnameIdx = message.ToString().LastIndexOf('.')+1;
var telemetry = new RequestTelemetry
{
Timestamp = DateTime.Now,
Name = "RECEIVE "+message.ToString().Substring(classNameIdx)
};
telemetry.Context.Operation.ParentId = message.parentId;
telemetry.Context.Operation.Id = message.opId;
telemetry.Duration = message.startTime - telemetry.Timestamp;
client.TrackRequest(telemetry);
}
And finally, just track and send the message:
var msg = new MyMessage();
_telemetryClient.TrackRbmq(msg);
MessagePipeline.Send(msg); //or however its sent in your app
I hope this saves someone the trouble I went through.

Xamarin Forms (VS2019) + iOS Intents UI: How to access Assets from Extension (IntentsUI)

I used the Xamarin version of SoupChef for Siri Intents. I was able to access the Container's Assets from the SoupChefIntentsUI.IntentViewController by requesting the bundle by identifier (using the BundleIdentifier of the main App) and then I just loaded the image by passing the bundle
CGSize DisplayOrderConfirmation(Order order, OrderSoupIntent intent, OrderSoupIntentResponse response){
/* unrelated code */
//this line work in the SoupChef example but
//On Xamarin.Forms this returns null
var containerBundle = NSBundle.FromIdentifier("com.something.SoupChef");
//always returns null because it seems it looks into the IntentsUI.Assets
var iconNull = UIImage.FromBundle("AppIcon");
//it returns the icon from the SoupChef.Assets
var iconNotNull = UIImage.FromBundle("AppIcon", containerBundle, configuration: null);
/* unrelated code */
}
I was also able to retrieve the AppIcon by creating the NSBundle doing something like this (in case you didn't want to assume that the bundle identifier names don't follow the Apple standard where the Container and the extensions have the same bundle identifier with the exception of the last segment)
CGSize DisplayOrderConfirmation(Order order, OrderSoupIntent intent, OrderSoupIntentResponse response){
/* unrelated code */
Class GetClassForType (Type type)
{
IntPtr myClassHandle = Class.GetHandle (typeToLookup);
if (myClassHandle != IntPtr.Zero)
return new Class (myClassHandle);
else
return null;
}
//this returns the bundle identifier of the SoupChef app
//(not the SoupChefIntentUI) on the SoupChef example
//on Xamarin.Forms (my project) it returns the IntentsUI identifier
var containerBundle = NSBundle.FromClass(GetClassForType(typeof(SoupChef.OrderIntent)));
//the icon is returned
var icon = UIImage.FromBundle("AppIcon", containerBundle, configuration: null);
/* unrelated code */
}
My problem is that I want to do the same thing on a different project that is using Xamarin.Forms, and the two previous ways that worked for me on the SoupChef project don't work here.
Is there a way to access the Assets set on the App.iOS.Assets or do I have to move them to the shared project where I have the models and other things that both the App.iOS and its Extensions are using?
I noticed that the Bindings (the project where the OrderIntent is) in the SoupChef example has the same namespace as the Container App ("SoupChef"), so I assigned the same namespace in my project with Xamarin.Forms and still nothing.

Zebra Print issue using asp.net with c#

I am using the PrintDocument for printing directly to the network printer using asp.net with and C#. The application hosted in IIS with Windows authentication. I am not getting the error and also the PrintStatus is Printing. But we can not see the printed document in the printer and also there is no errors in the printer.
System.Drawing.Printing.PrintDocument printdoc = new System.Drawing.Printing.PrintDocument();
printdoc.DefaultPageSettings.PaperSize = new PaperSize("Custom", 4, 3);
printdoc.OriginAtMargins = true;
// Set the printer name
PrinterSettings printer = new PrinterSettings();
printer.PrinterName = SqlDatabaseUtility.GetZebraPrinterName();
string fullName = CheckPrinterConfiguration(printer.PrinterName);
if (!String.IsNullOrEmpty(fullName))
{
printdoc.PrinterSettings.PrinterName = fullName;
// Handle printing
if (printdoc.PrinterSettings.IsValid)
{
printdoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printdoc_PrintPage);
printdoc.PrinterSettings.Copies = 2;
printdoc.Print();
}
}
Just a theory, but the PrintDocument class is a descendant of Component and so implements IDisposable.
In the same way that you don't leave SqlConnection instances undisposed, you should call Dispose() on your printdoc instance so that any unmanaged resources held by the PrintDocument instance - such as a handle to the printer device, perhaps - get released.
Put a using clause around your printing block as below. It might help with your problem, but even if it does not it is proper practice.
using (System.Drawing.Printing.PrintDocument printdoc = new System.Drawing.Printing.PrintDocument())
{
...
}
The next line of enquiry would be to follow up on the "user permissions" suggestion in the comment. Assuming that your code works if you run it in a test console application, a quick test for this would be to change the user account of your web app's Application Pool to be your own account. If your web app starts printing, then you know that permissions are the problem.

Xamarin Forms - Error in iOS Attempting to JIT compile

I have a xamarin forms app. When I compile and test on my Pixel3, everything seems to be working properly. When I load it up in my iOS device running iOS13.something, I get the following error when I try to make my second call to a web service in my app. The error is shown below.
Assertion at /Users/builder/jenkins/workspace/archive-mono/2019-08/ios/release/mono/mini/interp/interp.c:2160, condition `is_ok (error)' not met, function:do_jit_call, Attempting to JIT compile method '(wrapper other) void object:gsharedvt_out_sig (object&,single&,int&,intptr)' while running in aot-only mode. See https://learn.microsoft.com/xamarin/ios/internals/limitations for more information. assembly: type: member:(null)
The code is a bit of a mess, but has been working in the past.
var uri = String.Format("{0}//{1}/{2}?PlayerToken={3}", protocol, servername, tournamentsInClubUrl, userToken);
var httpC = new HttpClient();
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, uri);
requestMessage.Headers.Add("AppKey", AppKey);
var body = await httpC.SendAsync(requestMessage); <-- Error happens here.
var str = await body.Content.ReadAsStringAsync();
var res = JsonConvert.DeserializeObject<List<PicVideoApp.Models.TournamentInfo>>(str);
httpC.Dispose();
httpC = null;
return res;
I assume that I am doing something wrong, but danged if I can see it. Any ideas are appreciated.
It runs properly in the iOS Simulator.
TIA.
From shared error info , you need to use C# delegate to call native functions .
To call a native function through a C# delegate, the delegate's declaration must be decorated with one of the following attributes:
UnmanagedFunctionPointerAttribute (preferred, since it is cross-platform and compatible with .NET Standard 1.1+)
MonoNativeFunctionWrapperAttribute
For example :
[MonoNativeFunctionWrapper]
delegate void SomeDelegate (int a, int b);
//
// the ptrToFunc points to an unmanaged C function with the signature (int a, int b)
void Callback (IntPtr ptrToFunc)
{
var del = (SomeDelegate) Marshal.GetDelegateForFunctionPointer (ptrToFunc, typeof (SomeDelegate));
// invoke it
del (1, 2);
A similar error was thrown at me in iOS when I used dynamic types in my code. I was able to solve it by enabling the 'Mono Interpreter' in iOS build settings. Hope that helps in your case.

DotRas unauthorized access exception when adding phonebook an entry

I am devoloping an application with dotras dll. In the application my main goal is to connect to the internet with 3g USB modem. I am adding my code below :
RasPhoneBook book = new RasPhoneBook();
book.Open();
dialer = new RasDialer();
dialer.StateChanged += new EventHandler<StateChangedEventArgs> (dialer_StateChanged);
RasDevice device = RasDevice.GetDeviceByName("ZTE", RasDeviceType.Modem);
RasEntry entry = RasEntry.CreateDialUpEntry("MyEntry", "*99#", device);
entry.EncryptionType = RasEncryptionType.Optional;
entry.Options.ModemLights = true;
entry.NetworkProtocols.IP = true;
entry.NetworkProtocols.Ipx = false;
book.Entries.Add(entry);
dialer.PhoneBookPath = book.Path;
dialer.EntryName = "MyEntry";
dialer.Dial();
When I tried to add the phonebook my entry it's returning an exception :
UnauthorizedAccessException was Unhandled
The caller does not have required permission to perform the action requested.
I'm new about DotRas. So which permissions does it neeeded to add an entry to the phonebook?
Any ideas?
I have found the answer. The reason why I need to elevate privileges for the application is due to the application opening the All User's profile phone book. This is indicated by my call to book.Open()
If you encountered a problem like this remember you can always store the phone book next to your application, which will remove the need to elevate permissions.
The code should be :
RasPhoneBook book = new RasPhoneBook();
book.Open(".\\MyAppPhoneBook.pbk");

Resources