I'm trying to use Assembly to get app version, but it doesn't have GetExecutingAssembly() method on Universal App, how can I do it?
string version = "V " + Assembly.GetExecutingAssembly().FullName.Split(',')[1].Split('=')[1];
You can get through to the assembly via reflection:
string version = this.GetType().GetTypeInfo().Assembly.GetName().Version.ToString(4);
(from Chris Sienkiewicz's Blog)
I had to use the following to get the version string for a Windows 10 Universal App:
var version =
Application
.Current
.GetType()
.AssemblyQualifiedName
.Split(' ')[2]
.Split('=')[1]
.Replace(",", "");
Related
I am using IBM mobilefirst adapter to get data from server in my windows phone 8.1 application. when I am invoking the worklight adapter using c# code, my parameters are visible in url, however I want to send it as body. How to achieve this?
Following code I use for invoking adapter.
WLProcedureInvocationData invocationData = new WLProcedureInvocationData("CreditCardAdapter", "getAllRegisterCard", true);
//invocationData.setParameters(new Object[] { custId, version });
Object[] parameter = { custId, version };
String myContextObject = "InvokingAdapterProceduresWP8";
invocationData.setParameters(parameter);
WLRequestOptions options = new WLRequestOptions();
WLClient.getInstance().invokeProcedure(invocationData, new AllRegisterCardsInvokeListener(), options);
Your requirement cannot be achieved using MFPF 7.1 native C# Silverlight SDK.
However, this can be achieved using WLResourceRequest API that is available in MFPF 7.1 native Windows Universal SDK.For details, refer to the API documentation available here.
Even though I have an app version set as 3.0.4 both in WMAppManifest as Package.appxmanifest, Windows.ApplicationModel.Package.Current gives me 1.0.0.0
Any clues? This is how I'm trying to retrieve
var myPackage = Windows.ApplicationModel.Package.Current;
var ver = myPackage.Id.Version;
string appVer = string.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
If you have WMAppManifest in your project, your app is a Silverlight one, so the best way si to parse the WMAppManifest file and get the version from there, here is a sample: https://github.com/igorkulman/Kulman.WP8/blob/master/Kulman.WP8/Code/ManifestHelper.cs
You can set your app version in the AssemblyInfo.cs file like this :
[assembly: AssemblyVersion("1.0.*")]
To retrieve it do this :
var nameHelper = new AssemblyName(Assembly.GetExecutingAssembly().FullName);
string sMyAppVersion = nameHelper.Version.ToString();
If this is a 8.1 universal app. Go to Package.appxmanifest file and click the packaging tab. There you can verify what values you are passing for Version (Major, Minor,Build,Revision)
Hope this helps.
I am developing a Windows Phone 8.1 Application and there is a need to get the Application Process ID from code. Any API with which I can get that?
You can use GetCurrentProcess followed by DuplicateHandle (and later CloseHandle) but I'm curious what you need it for... there's not much you can do with it in a Store app so maybe this won't complete your scenario.
Finally got the solution.
The Dll's for Desktop apps and Phone apps are different though the function names will be same.
When tried to import Kernal.dll lib in WIn Phone 8.1 and used p/invoke code, an exception, DllNotFoundException will be thrown. Instead in Win Phone 8.1 instead use "api-ms-win-core-processthreads-l1-1-1.dll"
To get the process ID in Win Phone 8.1 :
1)Create binding to WIN32 lib:
[DllImport("api-ms-win-core-processthreads-l1-1-1.dll", CharSet = CharSet.Unicode, ExactSpelling = false, PreserveSig = true)]
internal static extern uint GetCurrentProcessId();
2)Call the function:
uint id= GetCurrentProcessId();
For the complete set of Win Phone 8 supported API's see the MSDN link:
https://msdn.microsoft.com/library/windows/apps/jj662956(v=vs.105).aspx#BKMK_ListofsupportedWin32APIs
So when I was watching this video from BUILD I thought it's gonna be easy...
But I can't seem to get the tile of my WP Silverlight 8.1 app to change by doing the following.
const string xml = "<tile>"
+ "<visual>"
+ "<binding template='TileSquareText01'>"
+ "<text id='1'>testing 123</text>"
+ "</binding> "
+ "</visual>"
+ "</tile>";
var xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
var tileNotification = new TileNotification(xmlDoc);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
Please note I've also created a Windows RunTime Windows Phone 8.1 with exactly the same code and it works just fine.
On msdn, it clearly states that TileUpdateManager supports Windows Phone Silverlight 8.1. So I don't really know what's missing here.
In your manifest, make sure the notification type is set to WNS. If you set it to MPNS, then you have to use notifications the old way.
More information here: http://msdn.microsoft.com/en-us/library/dn642085(v=vs.105).aspx
in my Silverlight Windows Phone 7/8 projects I always used these methods/classes to get informations about the user phone:
Microsoft.Phone.Info.DeviceStatus.DeviceFirmwareVersion;
System.Environment.OSVersion.Version;
Microsoft.Phone.Info.DeviceStatus.DeviceName;
Microsoft.Phone.Info.DeviceStatus.DeviceManufacturer;
But now in Windows Phone 8.1 runtime they are missing. Are there some alternatives? My app doesn't use networking.
Thanks and sorry for bad english.
You can use the EasClientDeviceInformation class
e.g.
var deviceInfo = new EasClientDeviceInformation();
var manufacturer = deviceInfo.SystemManufacturer;
var name = deviceInfo.SystemProductName;
var firmwareVersion = deviceInfo.SystemFirmwareVersion;
var osVersion = "8.1"; // Only 8.1 so far. No os version method exists afaik in 8.1
Universal/WinRT apps only work in wp 8.1, so the OS version can only be 8.1. When they make wp8.2 or wp9, they'll probably add a way to check what OS version is installed...
If you're looking for the firmware version, you can get it with:
Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
var firmwareVersion = deviceInfo.SystemFirmwareVersion;