I am trying to use Mobile Broadband API Interfaces to get mobile device information like IMEI,etc., on Windows RT tablet.
You can find the API reference here
I am planning to do a console application to retrieve information as shown in an example below. But I am unable to find the MbnApi namespace in WinRT.
I am aware that it is not available in WinRT. If any of you know or have the Managed Code or DLL for the same, please point me in the right direction.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MbnApi;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
IMbnInterfaceManager infMgr = (IMbnInterfaceManager)mbnInfMgr;
MbnConnectionManager mbnConnectionMgr = new MbnConnectionManager();
IMbnConnectionManager ImbnConnectionMgr = (IMbnConnectionManager)mbnConnectionMgr;
IMbnConnection[] connections = (IMbnConnection[])ImbnConnectionMgr.GetConnections();
foreach (IMbnConnection conn in connections)
{
IMbnInterface mobileInterface = infMgr.GetInterface(conn.InterfaceID) as IMbnInterface;
MBN_INTERFACE_CAPS caps = mobileInterface.GetInterfaceCapability();
MBN_PROVIDER provider = mobileInterface.GetHomeProvider();
Console.WriteLine("Device Id :" + caps.deviceID);
Console.WriteLine("DataClass: " + caps.cellularClass);
Console.WriteLine("Manufacturer: " + caps.manufacturer);
Console.WriteLine("Model : " + caps.model);
Console.WriteLine("Firmware Version: " + caps.firmwareInfo);
}
Console.ReadKey(true);
}
}
}
As you say, Windows Mobile Broadband API is only available on the Windows Desktop.
Here's what you're looking for in the Metro/WinRT area: Win RT Mobile Broadband APIs.
There is also some useful information about device enumeration, and other things you might need here.
Related
I'm trying to build a service to export a rdlc Localreport from one of my actions in my webapi. Webapi is built on .net core 3.1
I know that reportviewer is not compatible with .net core, so to try and mitigate that I've got a class library project added to my project based on .net framework 4.7.2. Added the reference to the class library to my .net core webapi, so far so good. I'm able to call methods from my class library, no problem.
Now try adding LocalReport to a class in my class library....
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Reports
{
public class RenderAction
{
public void GetOrderReport()
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
string p = Path.GetDirectoryName(path);
string reportPath = Path.Combine(p, "Reports","Order.rdlc");
if (!File.Exists(reportPath)) { return; }
var report = new LocalReport();
}
}
}
intellisense prompted to install Microsoft.Reporting.Viewer so I did so... When calling my function in runtime, I get the following error when creating the new instance of localreport:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'Void System.AppDomainSetup.set_ActivationArguments(System.Runtime.Hosting.ActivationArguments)'.
Source=Microsoft.ReportViewer.Common
StackTrace:
at Microsoft.Reporting.ReportRuntimeSetupHandler.InitAppDomainPool(Evidence sandboxEvidence, PolicyManager policyManager)
at Microsoft.Reporting.LocalService..ctor(ILocalCatalog catalog, Evidence sandboxEvidence, PolicyManager policyManager)
at Microsoft.Reporting.ControlService..ctor(ILocalCatalog catalog)
at Microsoft.Reporting.WebForms.LocalReport..ctor()
at Myproject.Reports.RenderAction.GetOrderReport() in C:\Users\RudiGroenewald\source\repos\Myproject-Api-Common\Myproject_Api_Common\Myproject_Reports\RenderAction.cs:line 24
at Myproject.Api.Common.Controllers.ReportsController.Get() in C:\Users\RudiGroenewald\Source\Repos\Myproject-Api-Common\Myproject_Api_Common\Myproject_Api_Common\Controllers\ReportsController.cs:line 22
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeActionMethodAsync>g__Logged|12_1>d.MoveNext()
It seems like some sort of dll version mismatch or something... a bit stumped really.
Is it just not possible to get this working? My alternative is to have a full .net webapi, just for reportwriting, which I prefer not to do. Any thoughts on what I'm doing wrong?
Trying to gain some basic understanding of how this process works as I am receiveing the Correlation failed error. Let me first begin my describing the issue I'm encountering...
QAT is not working properly and is configured as follows:
I have an Identity Server running behind a load balancer for QAT.
All requests sent to the load balancer are https.
The traffic being forwarded to each application server (2 seperate servers in this case) is http.
The Netscaler is adding all necessary X-Forwarded items to the header.
I have another application that also sits behind the load balancer for QAT.
There are 2 seperate servers hosting this application which the netscaler will forward the traffic to.
This application is configured to use the X-Forwarded info from the netscaler.
It is designed to authenticate using the above-mentioned Identity Server.
My issue is that I end up with a never ending loop between the second application and the Identity Server when I deploy to QAT. This is strange to me as my SYS environment works perfectly. My sys environment has a seperate instance of Identity Server and the second Application mentioned (except that there is only a single instance of each application being forwarded to). This also goes through the netscaler and does all the X-Forwarded magic mentioned earlier.
In both situations the setup is identical. The only difference is that QAT has multiple servers hosting each app and SYS only has 1 server hosting each app.
My question is why would this behave differently?
Why would this work in sys but not in qa?
I think at this point we can rule out the callback path, cookie settings, etc... b/c it work in SYS.
Could it be that I need to implement some sore of Data Protection Key middleware in both the identity server and the other applciation? On that note, I really dont understand the Data Protection Keys. Would both the identity server and the seperate application need to store their Keys in the same location (whether that be in the database or filesystem) in order to be able to decrypt the information stored in the cookie...
Any help is greatly appreciated.
It was definitely the Data Protection Keys that were the issue. My solution was simple. Save the encryption key as part of the deployment process, Create an IXmlRepository, and then add that to the startup. Easy Peasy.
using Microsoft.AspNetCore.DataProtection.Repositories;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
namespace Myapp.Encryption.Repositories
{
public class EncryptionRepository : IXmlRepository
{
private String Key { get; set; }
public EncryptionRepository()
{
var year = Convert.ToString(DateTime.Now.Year + 2);
var key = "<key id=\"983440f7-626b-46e4-8bfa-7c3d6d9d4619\" version=\"1\">" +
" <creationDate>2019-11-13T17:42:58.889085Z</creationDate>" +
" <activationDate>2019-11-13T17:42:58.3843715Z</activationDate>" +
" <expirationDate>" + year + "-02-11T17:42:58.3843715Z</expirationDate>" +
" <descriptor deserializerType=\"Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60\">" +
" <descriptor>" +
" <encryption algorithm=\"AES_256_CBC\" />" +
" <validation algorithm=\"HMACSHA256\" />" +
" <masterKey p4:requiresEncryption=\"true\" xmlns:p4=\"http://schemas.asp.net/2015/03/dataProtection\">" +
" <value>{{Your Encryption Key }}</value>" +
" </masterKey>" +
" </descriptor>" +
" </descriptor>" +
"</key>";
Key = key;
}
public IReadOnlyCollection<XElement> GetAllElements()
{
var collection = new List<XElement>();
collection.Add(XElement.Parse(Key));
return collection;
}
public void StoreElement(XElement element, String friendlyName)
{
// Not required as key is hard coded
}
}
}
services.AddSingleton<IXmlRepository, EncryptionRepository>();
services.AddDataProtection().AddKeyManagementOptions(a => a.XmlRepository = (services.BuildServiceProvider()).GetService<IXmlRepository>());
I tried authenticating with Google Admin Api-sdk But We get some file missings error which should be created by the Dlls, we are using.
Even after adding all the recommended dlls after going through many article for the same, I din get over to this. Here is the code im using.
protected void Page_Load(object sender, EventArgs e)
{
const string serviceAccountEmail = "<id>#developer.gserviceaccount.com";
const string serviceAccountCertPath = #"E:\Test.p12";
const string serviceAccountCertPassword = "notasecret";
const string userEmail = "admin#mydomain.com";
var certificate = new X509Certificate2(serviceAccountCertPath, serviceAccountCertPassword, X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser },
User = userEmail
}.FromCertificate(certificate));
var service = new DirectoryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "User Provisioning",
});
User newuserbody = new User();
UserName newusername = new UserName();
newuserbody.PrimaryEmail = "Harsh#test.com";
newusername.GivenName = "Harsh";
newusername.FamilyName = "Sharma";
newuserbody.Name = newusername;
newuserbody.Password = "test#123";
User results = service.Users.Insert(newuserbody).Execute();
}
}
}
I am using this code for new user provisioning but Google.Apis.Admin.Directory.directory_v1.cs not found while debugging due to this authentication got failed. Please anybody let me know to to get Google.Apis.Admin.Directory.directory_v1.cs file. As much i know i have already added all the dlls added.
The Namespaces i am using are as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using Google.Apis.Admin.Directory.directory_v1;
using Google.Apis.Admin.Directory.directory_v1.Data;
using DotNetOpenAuth.GoogleOAuth2;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using Google.Apis.Auth.OAuth2.Requests;
using Google.Apis.Auth.OAuth2.Responses;
As per the documentation, you need to download an extra NuGet package for each API you want to use. These packages contain the generated code for that particular API.
thanks all for replying,
I managed to run it successfully, I had all the reference, Code was upto the mark as well.
The Only problem was with the admin setting there in the google admin panel.
I manage to correct them as per my request to google API's and it worked fine.
I have a Windows Phone 8 app that I recently upgraded to 8.1 Silverlight. I'd like to use the new tile templates. Right now I have a ScheduledTaskAgent that uses ShellTile.
In order to use the new live tiles I changed the notification service to WNS in my WMAppManifest.xml. I removed the code to register the old background task and added this code instead:
var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync();
if (backgroundAccessStatus == BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity ||
backgroundAccessStatus == BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity)
{
foreach (var task in BackgroundTaskRegistration.AllTasks)
{
if (task.Value.Name == "LiveTileBackgroundTask")
{
task.Value.Unregister(true);
}
}
BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder();
taskBuilder.Name = "LiveTileBackgroundTask";
taskBuilder.TaskEntryPoint = "BackgroundTasks.LiveTileBackgroundTask";
taskBuilder.SetTrigger(new TimeTrigger(15, false));
var registration = taskBuilder.Register();
}
I created a Windows Phone 8.1 Windows Runtime Component called BackgroundTasks that contains a BackgroundTask called LiveTileBackgroundTask:
public sealed class LiveTileBackgroundTask : IBackgroundTask
{
public void Run(IBackgroundTaskInstance taskInstance)
{
BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
const string xml = "<tile>"
+ "<visual>"
+ "<binding template='TileWideText01'>"
+ "<text id='1'>Text Field 1 (larger text)</text>"
+ "<text id='2'>Text Field 2</text>"
+ "<text id='3'>Text Field 3</text>"
+ "<text id='4'>Text Field 4</text>"
+ "<text id='5'>Text Field 5</text>"
+ "</binding> "
+ "</visual>"
+"</tile>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
TileNotification tileNotification = new TileNotification(doc);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
deferral.Complete();
}
}
I added a reference to this assembly in my Windows Phone project.
I also added a Background task declaration in my Package.appxmanifest that has BackgroundTasks.LiveTileBackgroundTask as an Entry point. I selected Timer and System event as supported task types.
When I run the app though, nothing happens. No live tile appears. I ran through the background task and everything goes well without any exceptions.
You say "No live tile appears". The code you've posted does not create a live tile - it just updates one. You have to manually pin it - the primary tile cannot be pinned through code.
If that's not the problem, maybe you're not looking at the wide tile? This template is for a wide tile, so the square tile won't be updated by this. I'd suggest using the NotificationsExtensions library. It was originally for Windows Store apps, but I think it would work for WP as well. (I've used it, but just for a test, not for real, so there may be issues.) It allows you to easily specify the template and params for both wide and square tiles.
And finally, to have a wide tile, you have to manually edit the Package.appxmanifest file. You must add the Wide310x150Logo attribute to the DefaultTile element.
That's all I can think of. Hope it helps.
Continuous background execution is not supported for Silverlight 8.1
apps
Windows Phone 8 apps can continue to run in the background after the
user navigates away from the app under certain conditions. This
feature is not available for Silverlight 8.1 apps. If you need this
feature, you should continue to use a Windows Phone 8 app. For more
information, see Running location-tracking apps in the background for
Windows Phone 8.
Platform compatibility and breaking changes for Windows Phone Silverlight 8.1 apps
Windows Phone 8.1 Windows Runtime Component can only be used with Windows Phone 8.1 Runtime(Store) app
I want to comunicate with Console XML RPC server from my silvelight application. Is it possibile?
Steps:
1. Start the Console XML RPC server
Code for Console XML RPC server is this:
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using CookComputing.XmlRpc;
public class StateNameServer : MarshalByRefObject, IStateName
{
public string GetStateName(int stateNumber)
{
return "whatever";
}
}
class _
{
static void Main(string[] args)
{
IDictionary props = new Hashtable();
props["name"] = "MyHttpChannel";
props["port"] = 5678;
HttpChannel channel = new HttpChannel(props,null,new XmlRpcServerFormatterSinkProvider());
ChannelServices.RegisterChannel(channel,false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(StateNameServer),"statename.rem",WellKnownObjectMode.Singleton);
Console.WriteLine("Press <ENTER> to shutdown");
Console.ReadLine();
}
}
Run Silverlight application
I used the code from http://code.google.com/p/xmlrpc-silverlight/
I created new Silverlight application to which I have attached the code from that link. When I start web site (in localhost with port 1139) which executes my SL app happens SecurityException.
void ResponseResponse(IAsyncResult result)
{
XmlRpcHelperRequestState state = result.AsyncState as XmlRpcHelperRequestState;
try
{
state.Response = (HttpWebResponse)state.Request.EndGetResponse(result);
...
}
catch (Exception e)
{
// comes here with SecurityException
}
finally
{
...
}
}
I am using VS2008 Professional,XP Professional, .net 3.5, Silverlight3. I will gladly provide any additional information (or code) which is needed.
I suspect that this is a case of a missing clientaccesspolicy.xml file.
Since your silverlight app will have been launched from another authority it will attempt to access this file the http://localhost:5678/. Since you little test doesn't support that file Silverlight blocks this cross "domain" activity.