when internet connection is available application insights for wpf application works fine and I am able to track page and events in azure portal but I want to know is it possible to store telemetry data somewhere in system when their is no internet connection and retrieve it when system is online and track those actions which I performed when their was no internet connection.
I suggest you take a look at Application Insights for Desktop Applications, it has nice code examples of using Application Insights with desktop applications in general, and also how to work/use the Persistence Channel. Taken from mentioned link:
public MainWindow()
{
TelemetryConfiguration config = TelemetryConfiguration.CreateDefault();
config.InstrumentationKey = "954f17ff-47ee-4aa1-a03b-bf0b1a33dbaf";
config.TelemetryChannel = new PersistenceChannel();
config.TelemetryChannel.DeveloperMode = Debugger.IsAttached;
telemetryClient = new TelemetryClient(config);
telemetryClient.Context.User.Id = Environment.UserName;
telemetryClient.Context.Session.Id = Guid.NewGuid().ToString();
InitializeComponent();
}
And then:
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
...
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
ExceptionTelemetry excTelemetry = new ExceptionTelemetry((Exception)e.ExceptionObject);
excTelemetry.SeverityLevel = SeverityLevel.Critical;
excTelemetry.HandledAt = ExceptionHandledAt.Unhandled;
telemetryClient.TrackException(excTelemetry);
telemetryClient.Flush();
}
Update
To track page views, you can use one of TelemetryClient's TrackPageView overloads, for example:
telemetryClient.TrackPageView("MyPageName");
Hope it helps!
Related
I'm able to get the services (services.msc) for my computer. But i want the list of services to be displayed from other computer (should remotely login).
NOTE: I don't want the services.msc list for the remote machine's. I want a particular services (console application (.msc)) which is placed on the desktop.
Can anyone please help me achieving this? I'm trying since 4days but couldn't able to get it. Below is my code where i have used to fetch the services from my own computer:
private void button1_Click(object sender, EventArgs e)
{
ServiceController[] se = ServiceController.GetDevices();
ServiceController[] services = ServiceController.GetServices();
int i = 0;
foreach (ServiceController service in services)
{
dataGridView1.Rows.Add();
dataGridView1.Rows[i].Cells["dgvcServiceName"].Value = Convert.ToString(service.ServiceName);
dataGridView1.Rows[i].Cells["dgvcStatus"].Value = Convert.ToString(service.Status);
dataGridView1.Rows[i].Cells["dgvcDescription"].Value = Convert.ToString(service.DisplayName);
i += 1;
}
Please suggest me the way to get it. Thanks again.
use System.ServiceProcess.ServiceController.GetServices("MachineName")
to get the list of services on a remote system.
what you are doing is ServiceController.GetServices().
which will get the services from the local system.
I'm trying to get Application Insights to work with my WPF application, but whenever I try to call any of the Track functions, I get a nullreferenceexception with this stacktrace
at Microsoft.ApplicationInsights.TelemetryClient.Track(ITelemetry telemetry)
at Microsoft.ApplicationInsights.TelemetryClient.TrackTrace(TraceTelemetry telemetry)
at Microsoft.ApplicationInsights.TelemetryClient.TrackTrace(String message)
I added an application in Azure so that I got an instrumentationKey (hidden in the code below), added the nuget package and entered this code:
var config = new TelemetryConfiguration();
client = new TelemetryClient(config);
config.InstrumentationKey = "myKey";
client.InstrumentationKey = "myKey";
client.TrackTrace("testing testing");
client.Flush();
The crash occurs at the 5:th line above, and It occurs no matter which version of the nuget package I use.
I've heard some people mention an ApplicationInsights.config, but no such file has been generated for me.
Use TelemetryConfiguration.Active instead of create a new instance.
No need to set InstrumentationKey on client instance. When you set the Active configuration, it will used that key for every new client instance. Only explicit set the key on the telemetry client if you're sending that specific telemetry to a custom / different key than the configuration.
TelemetryConfiguration.Active.InstrumentationKey = "myKey";
client = new TelemetryClient();
client.TrackTrace("testing testing");
client.Flush();
Just ran into the same issue. We got it working with code like:
// setup the client
TelemetryClient tc = new TelemetryClient();
tc.InstrumentationKey = "key copied from portal";
// Set session data:
tc.Context.User.Id = Environment.UserName;
tc.Context.Session.Id = Guid.NewGuid().ToString();
tc.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
tc.TrackTrace("some data....");
tc.Flush(); // only for desktop apps
You can see more details at Application Insights on Windows Desktop apps, services and worker roles
I have added a vanilla mobile service, selecting the defaults all the way. It is a .Net backend, using a new 20MB DB on an existing server I use in the North Europe DC. I created a blank Windows Store App, added the MobileServices nuget package and then followed the instructions to connect my MobileService to my app by adding the MobileServicesClient to my App.xaml class. Then I added a button with an event handler. The handler calls an async function to insert a TodoItem object into the database.
App.xaml.cs
public static MobileServiceClient MobileService = new MobileServiceClient(
"https://???.azure-mobile.net/",
"???");
I have replaced the URI and Token with ???. The one I used came from my Azure Portal for this Mobile Service.
MainPage.xaml.cs
private void Button_Click(object sender, RoutedEventArgs e)
{
CreateItem();
}
private async void CreateItem()
{
TodoItem item = new TodoItem { Text = "Sort This", Complete = false };
try
{
await App.MobileService.GetTable<TodoItem>().InsertAsync(item);
}
catch(MobileServiceInvalidOperationException ex1)
{
Debug.WriteLine(ex1.Message);
}
catch(Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
When I run this code and click the button a MobileServiceInvalidOperationException is raised:
"{"The request could not be completed. (Not Found)"}"
I am using VS2013, with Service Pack 2 installed and WindowsAzure.MobileServices 1.2.3.
The MobileService is running as I can navigate to https://MyMobileService.azure-mobile.net/ but, if I click Check It Out, I am asked to Authenticate (MyMobileService is not the actual Uri).
The post request looks ok, but the response is a 404.
I have been working on this all day, including using Windows Phone, with no luck...
I know I must be doing something wrong, or there is an issue with Azure in Northern Europe, but I can't sort it out.
Any help much appreciated.
Jason.
I had the same issue awhile ago. I switch from .net backend to javascript. Also, make sure your mobileservice and db schema match.
I am developing a WP8.1 app, when I try using ShareMediaTask to share a picture it shows me a list of apps where I will share the picture. Facebook, Twitter and other apps like Whatsapp are not included in the list; it shows me only share to OneNote. Taking note that I debug from device with Facebook and Twitter installed on it.
If someone could help me thankfully.
This is my simple code :
ShareMediaTask shareMediaTask = new ShareMediaTask();
shareMediaTask.FilePath = fileName;
shareMediaTask.Show();
Do I have to add something ?!
You'll want to take a look at Sharing content for Windows Runtime apps. Sharing is different between Silverlight and Runtime apps.
Here is a basic sample on how to share files:
When you are ready to share:
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager,
DataRequestedEventArgs>(this.ShareStorageItemsHandler);
And then populating the data:
private async void ShareStorageItemsHandler(DataTransferManager sender,
DataRequestedEventArgs e)
{
DataRequest request = e.Request;
request.Data.Properties.Title = "Share StorageItems Example";
request.Data.Properties.Description = "Demonstrates how to share files.";
// Because we are making async calls in the DataRequested event handler,
// we need to get the deferral first.
DataRequestDeferral deferral = request.GetDeferral();
// Make sure we always call Complete on the deferral.
try
{
StorageFile logoFile =
await Package.Current.InstalledLocation.GetFileAsync("Assets\\Logo.png");
List<IStorageItem> storageItems = new List<IStorageItem>();
storageItems.Add(logoFile);
request.Data.SetStorageItems(storageItems);
}
finally
{
deferral.Complete();
}
}
Only apps that implement sharing will show up in the list. Currently Twitter and Facebook have not released an app that implements sharing.
For more information of receiving shared content, see this doc.
Ok, here is the situation. I would like to deploy a silverlight application to an enterprise portal. Users will access the application by logging in to the portal and navigating to the page where it is hosted. That's the easy part.
This silverlight 4 application is designed to be run in Out of Browser mode (OOB). My question is, is it possible to have the Silverlight OOB update process retrieve updates from behind the enterprise portal's authentication?
When I call App.Current.CheckAndDownloadUpdateAsync();, how do I supply credentials so that this HTTP request will succeed?
Any ideas? Is the update process extensible?
Thanks for your help.
With Silverlight 4 this should be a possible scenario
In both classes WebClient and WebRequest you can use Credentials..
private void DownloadAdditionalThings()
{
WebRequest.RegisterPrefix("http://", System.Net.Browser.WebRequestCreator.ClientHttp);
var client = new WebClient();
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("username", "password");
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(new Uri("http://blog.gfader.com/"));
}
private void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
string result = e.Result;
}