Windows Phone 8 emulator error – Something happened while creating a switch

It’s already answered, but something easier worked for me (and without uninstalling VirtualBox): “Go into Hyper V. Go into the Virtual Switch Manager. Create a virtual switch called ‘Windows Phone Emulator Internal Switch’. Make it’s connection type Internal. Now launch the emulator. It should work.” I had to reboot the machine before running the emulator, … Read more

Install Visual Studio 2013 on Windows 7

The minimum requirements are based on the Express edition you’re attempting to install: Express for Web (Web sites and HTML5 applications) – Windows 7 SP1 (With IE 10) Express for Windows (Windows 8 Apps) – Windows 8.1 Express for Windows Desktop (Windows Programs) – Windows 7 SP1 (With IE 10) Express for Windows Phone (Windows … Read more

Calling async method on button click

You’re the victim of the classic deadlock. task.Wait() or task.Result is a blocking call in UI thread which causes the deadlock. Don’t block in the UI thread. Never do it. Just await it. private async void Button_Click(object sender, RoutedEventArgs { var task = GetResponseAsync<MyObject>(“my url”); var items = await task; } Btw, why are you … Read more

How to post data using HttpClient?

You need to use: await client.PostAsync(uri, content); Something like that: var comment = “hello world”; var questionId = 1; var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>(“comment”, comment), new KeyValuePair<string, string>(“questionId”, questionId) }); var myHttpClient = new HttpClient(); var response = await myHttpClient.PostAsync(uri.ToString(), formContent); And if you need to get the response after post, … Read more

Controls on Pivot disappear

Quite old question, but still unanswered. It seems like it’s because of Application_Deactivated event handler, which runs when application is sent to background: private void Application_Deactivated(object sender, DeactivatedEventArgs e) { diagLog(“Deactivated, reason: ” + e.Reason); } In this event handler you should set RunningInBackground = true Hope that helps

How to send a Post body in the HttpClient request in Windows Phone 8?

UPDATE 2: From @Craig Brown: As of .NET 5 you can do: requestMessage.Content = JsonContent.Create(new { Name = “John Doe”, Age = 33 }); See JsonContent class documentation UPDATE 1: Oh, it can be even nicer (from this answer): requestMessage.Content = new StringContent(“{\”name\”:\”John Doe\”,\”age\”:33}”, Encoding.UTF8, “application/json”); This depends on what content do you have. You … Read more

How to upload file to server with HTTP POST multipart/form-data?

Basic implementation using MultipartFormDataContent :- HttpClient httpClient = new HttpClient(); MultipartFormDataContent form = new MultipartFormDataContent(); form.Add(new StringContent(username), “username”); form.Add(new StringContent(useremail), “email”); form.Add(new StringContent(password), “password”); form.Add(new ByteArrayContent(file_bytes, 0, file_bytes.Length), “profile_pic”, “hello1.jpg”); HttpResponseMessage response = await httpClient.PostAsync(“PostUrl”, form); response.EnsureSuccessStatusCode(); httpClient.Dispose(); string sd = response.Content.ReadAsStringAsync().Result;

DateTime.ToString(“MM/dd/yyyy HH:mm:ss.fff”) resulted in something like “09/14/2013 07.20.31.371”

Is it because some culture format issue? Yes. Your user must be in a culture where the time separator is a dot. Both “:” and “/” are interpreted in a culture-sensitive way in custom date and time formats. How can I make sure the result string is delimited by colon instead of dot? I’d suggest … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)