Application Insights VS2015 failed to add applicationinsights.config

If you ever deal with the problem

in Visual studio 2015 and Windows 10 you only have to create a file and name it  ApplicationInsights.config with the code below. That’s because vs and nuget cannot create this file in the root folder of your project.

You must enter your specific InstrumentationKey for the application that you have registered through Azure portal for Insights.

The trick is that you must select Build Action as Content and Copy always to output folder

vs2015insights

UnauthorizedAccessException C# File.IO Async

I had to upgrade one application and put some extra functionality. So i added an async function that handles a .txt file and edit some fields.

So i used this code

 

But i also had a function in MainPage that asynchronously was reading the same file

 

Both functions were async so we could not determine when each function was running and which will be executed first.

So when i tried to run the app i came across with UnauthorizedAccessException because both function maybe were trying to access the file the same time. So i have to make one function wait. You can achieve that by many ways. I used the below function.

 

 

But i want to execute this code only once. So i used localSettings

 

 

Change Image Source Dynamically C# – Windows Store apps

You can change dynamically with c# the Image Source of an image with the following code

Where

 

Override the default style of an element – Windows 8.1 aps

One simple way to override the default style of an element on Windows Store aps can be done by changing the default styles. So first of all google for those styles and when you find them just edit and paste in

App.xaml

For example i wanted to make a ToggleSwitch Black. So i found all the available styles and i just modified those i wanted. Then in App.xaml you could see that