You were previously added to the Hyper-V Administrators security group, but the permissions have not taken effect. Please sign out of your computer for the permissions to take effect. Android sdk with Visual Studio – xamarin – Part 2

Part 1

The popup about permission was the reason to write part-2, but later I realized there are many more.

After completing activities on Part 1, I now hit the run button to got a pop up saying.

You were previously added to the Hyper-V Administrators security group, but the permissions have not taken effect. Please sign out of your computer for the permissions to take effect.

Yes, this is something related to permission, I read the  “sign out of your computer” as “restart the computer“.

When I came again after restarting.

I hit the run button to see the output on 5” Kitkat (4.4) Virtual device.

Again popup episode started.

Popup-1 : Microsoft Visual Studio

The emulator requires an Internet connection to start. Do you want to configure the emulator to connect to the Internet?

Your computer might lose network connectivity while these changes are applied. This might affect existing network operations.
—————————
Yes No


I clicked on Yes

Popup-2 appeared : Visual Studio Emulator for Android

Click “Retry” to run the emulator in elevated mode.

You do not have permission to modify internal Hyper-V network adapter settings, which are required to run the emulator

[Retry] [Close]

I retried and see emulator phone screen, saying “OS starting..”

Output Window Progress…

1>—— Build started: Project: App1, Configuration: Debug Any CPU ——
1> App1 -> D:\Misc\android\App1\App1\bin\Debug\App1.dll
1> Processing: obj\Debug\res\layout\main.xml
1> Processing: obj\Debug\res\values\strings.xml
1> Processing: obj\Debug\res\layout\main.xml
1> Processing: obj\Debug\res\values\strings.xml
2>Starting deploy 5″ KitKat (4.4) XXHDPI Phone …
2>Starting emulator 5″ KitKat (4.4) XXHDPI Phone …
2>Validating emulator arguments…
2>Determining if emulator is already running…
2>Preparing virtual machine…
2>Launching emulator…
2>An error occured. See full exception on logs for more details.
2>Could not launch ‘VS Emulator 5″ KitKat (4.4) XXHDPI Phone’ device. Exit code 10.
2>An error occured. See full exception on logs for more details.
2>Could not launch ‘VS Emulator 5″ KitKat (4.4) XXHDPI Phone’ device. Exit code 10.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

OMG, It stuck again and displayed me another popup.

The emulator is unable to verify that the virtual machine is running:

Something happened while starting a virtual machine: ‘VS Emulator 5-inch KitKat (4.4) XXHDPI Phone.lima’ failed to start. (Virtual machine ID 618636A2-0A76-46A5-A5BA-0CD352B1BEE5)

‘VS Emulator 5-inch KitKat (4.4) XXHDPI Phone.lima’ could not initialize. (Virtual machine ID 618636A2-0A76-46A5-A5BA-0CD352B1BEE5)

Not enough memory in the system to start the virtual machine VS Emulator 5-inch KitKat (4.4) XXHDPI Phone.lima with ram size 2048 megabytes. (Virtual machine ID 618636A2-0A76-46A5-A5BA-0CD352B1BEE5)

I ran dxdiag and ensured that my system has 4GB RAM (4096 MB), it was double then requirement of 2048 megabytes.

Now what, am I in a war zone between Google and Microsoft? should I gave up or keep trying, lets give it a last try. This time we will run the Visual Studio in elevated mode via “Run as Administrator” option.

I have failed today, following is the output of my work on post 1 and this post.vsandriod

Visual Studio is saying:

Visual Studio Emulator for Android
The emulator is unable to verify that the virtual machine is running:
Not enough memory is available in the system to start an emulator that uses 2048 MB of startup RAM. Please close other applications and try to launch the emulator again.
If closing other applications doesn’t help, please follow the instructions on this KB article: http://support.microsoft.com/kb/2911380/en-us

The suggested work around is to add a guaranteed MemoryReserve in Registry for Virtualization. Guaranteed means when You run emulator this amount of memory should be always free. I added 1024 as decimal .

Serious problems might occur if you modify the registry incorrectly. Before you modify it, back up the registry for restoration in case problems occur.

To work around this problem in a system that is running many programs that are using lots of memory, try to close those programs and then restart the emulator.

If the emulator still does not start, you can disable the Hyper-V runtime memory monitoring functionality by adding a MemoryReserve registry. To do this, follow these steps:

  1. Start Registry Editor.
  2. Locate the following registry subkey:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization
  3. Right-click the Virtualization folder, point to New, and then click DWORD Value.
  4. Type MemoryReserve, and then press Enter.
  5. Double-click MemoryReserve, enter 2048 in the Value data box, select the Decimal option, and then click OK.
  6. Close Registry Editor.

In systems that experience this problem and that have fewer than 8 GB of RAM installed, a MemoryReserve value of 2048 (2 GB) is recommended. A value of zero (0) causes this registry setting to be ignored.

Note You must restart the computer for this registry setting to take effect.

To close the chapter, I added the desired DWORD MemoryReserve.

When I came again after restarting, the same out of memory story.

I modified the MemoryReserve in Registry for Virtualization to Zero, still , the same out of memory story.

It seems that we need 8 GB of RAM to run default emulator.

Then I decided to create an Galaxy AVD, this time it was a success.

1>Build succeeded.
1>Deploy successfully on AVD_for_Galaxy_Nexus_by_Google.

nexus avd.png

 

What is ASP.NET Core 1.0 and .NET Core 1.0 and what is future of ASP.NET 5 and 4.6!

ASP.NET 5 is now ASP.NET Core 1.0.

.NET Core 5 is now .NET Core 1.0.

The name is has changed, nothing more than this!

Why new name 1.0?

Because the concept is new, its not having same architecture as previous version of ASP.net till 4.6.

However till now, the .NET Core 1.0 is not mature as earlier .NET Frameworks were, this is in testing and development phase. Earlier ASP.NET version are more mature and very well tested for developing a new project.

ASP.NET Core 1.0 is a 1.0 release which has Web API and MVC but not SignalR and Web Pages. It does not have VB and F# till now, they will be added in near future.

ASP.NET Core 1.0 a new framework, but earlier ASP.NET 4.6 version will remain there, and will be fully supported, but ASP.NET Core 1.0 is new, very new…

SQL SERVER – Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

Some errors when encountered take most of us for a spin. In this category the error related to “Timeout” surely falls. If you are a web developer and receive the same there are a hundred combinations why this can possibly happen. The web results can sometimes lead us in completely opposite direction because we have…

Source: SQL SERVER – Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

Calling an oData Batch using .net HttpClient class

You have full code here, no theory!

Private Async Function SaveEntityAsBatch() As Threading.Tasks.Task
Using Client As New HttpClient()
Dim APIhostUri As String = “http://localhost:2025/”
Dim APIResponse As HttpResponseMessage
Client.BaseAddress = New Uri(APIhostUri)
Dim content As HttpContent

‘Required if you need dates serialization

Dim microsoftDateFormatSettings As JsonSerializerSettings = New JsonSerializerSettings With {
.DateFormatHandling = DateFormatHandling.IsoDateFormat,
.DateParseHandling = DateParseHandling.DateTimeOffset, .DateTimeZoneHandling = DateTimeZoneHandling.Utc
}

‘ Batch Process
Dim boundary As String = “–changeset_Data—”
Dim batchContent As New MultipartContent(“mixed”, “–batch” & boundary)

‘Project
Dim RqP As New HttpRequestMessage(HttpMethod.Put, “URL(id)/”)
RqP.Content = New StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(projectRequest, microsoftDateFormatSettings))
If RqP.Content.Headers.Contains(“Content-Type”) Then RqP.Content.Headers.Remove(“Content-Type”)
RqP.Content.Headers.Add(“Content-Type”, “application/json”)
Dim ReqContent As New HttpMessageContent(RqP)
If ReqContent.Headers.Contains(“Content-Type”) Then ProjectContent.Headers.Remove(“Content-Type”)
ReqContent.Headers.Add(“Content-Type”, “application/http”)
ReqContent.Headers.Add(“Content-Transfer-Encoding”, “binary”)
ReqContent.Headers.Add(“client-request-id”, “12345678”)
ReqContent.Headers.Add(“return-client-request-id”, “True”)
ReqContent.Headers.Add(“Content-ID”, “1”)
ReqContent.Headers.Add(“DataServiceVersion”, “3.0”)
If ReqContent.Headers.Contains(“contentTypeMime-Part”) Then ReqContent.Headers.Remove(“contentTypeMime-Part”)
ReqContent.Headers.Add(“contentTypeMime-Part”, “Content-Type:application/http;”)

batchContent.Add(ReqContent)

‘Report1

Dim RqR As New HttpRequestMessage(HttpMethod.Put, “URL2/”, PtsAPIhostUri)
RqR.Content = New StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(report, microsoftDateFormatSettings))
If RqR.Content.Headers.Contains(“Content-Type”) Then RqR.Content.Headers.Remove(“Content-Type”)
RqR.Content.Headers.Add(“Content-Type”, “application/json”)
Dim ReqContent2 As New HttpMessageContent(RqR)

If ReqContent2.Headers.Contains(“Content-Type”) Then ReportContent.Headers.Remove(“Content-Type”)
ReqContent2.Headers.Add(“Content-Type”, “application/http”)
ReqContent2.Headers.Add(“Content-Transfer-Encoding”, “binary”)
ReqContent2.Headers.Add(“client-request-id”, “99999”)
ReqContent2.Headers.Add(“return-client-request-id”, “True”)
ReqContent2.Headers.Add(“Content-ID”, “2”)
ReqContent2.Headers.Add(“DataServiceVersion”, “3.0”)

If ReqContent2.Headers.Contains(“contentTypeMime-Part”) Then ReqContent2.Headers.Remove(“contentTypeMime-Part”)
ReqContent2.Headers.Add(“contentTypeMime-Part”, “Content-Type:application/http;”)
batchContent.Add(ReqContent2)
Dim batchRequest As HttpRequestMessage = New HttpRequestMessage(HttpMethod.Post, APIhostUri & “/$batch/”)
batchRequest.Content = batchContent
Dim APIResponseBatch = Await Client.SendAsync(batchRequest)
Dim streamProvider = APIResponseBatch.Content.ReadAsMultipartAsync().Result()

For Each cnt As HttpContent In streamProvider.Contents
Console.WriteLine(cnt.ReadAsStringAsync().Result)
Next

End Using
End Function

I got following errors in given sequences and I continued to add the header and finally I was able to two PUT request in Batch.

Error #1

The ‘Content-Type’ header value ‘application/http; msgtype=request’ is invalid. When this is the start of the change set, the value must be ‘multipart/mixed’; otherwise it must be ‘application/http’.

Error #2

The content type ‘multipart/mixed’ specifies a batch payload; however, the payload either does not include a batch boundary or includes more than one boundary. In OData, batch payload content types must specify exactly one batch boundary in the ‘boundary’ parameter of the content type.

Error #3

Nested change sets in a batch payload are not supported.

Error #3 took most of the time to find out this URL https://msdn.microsoft.com/en-us/library/azure/dn878159.aspx from MSDN, which speaks about adding following Header Content Types

ReqContent2.Headers.Add(“client-request-id”, “99999”)
ReqContent2.Headers.Add(“return-client-request-id”, “True”)
ReqContent2.Headers.Add(“Content-ID”, “2”)
ReqContent2.Headers.Add(“DataServiceVersion”, “3.0”)

After adding above four types to header Error #3 was gone and my Batch was working.

The URL from MSDN says;

Add Tasks requests in Batch service support the following concepts:

  • Each request must contain a unique Content-ID MIME part header. This header is returned with the result of the operation in the response, and can be used to match an individual request with its response.
  • The Batch service returns a HTTP Status Code 400 (Bad Request) if any request contains an invalid set of headers or contains operations which are not supported in the batch.
  • The Batch service returns a HTTP Status Code 202 (Accepted) for a valid Add Tasks request. The server will then stream the results of individual operations.
  • The Batch service can re-order the responses of these Add Task requests. The Content-Id MIME part header needs to be used by the Client to match the request corresponding to the response. The response contains the results and error information for each operation.If the server times out or the connection is closed during an Add Tasks request, the request may have been partially or fully processed, or not at all. In such cases, the user should re-issue the request. Note that it is up to the users to correctly deal with failures when re-issuing a request. For example, the users should use the same task names during retry, so that if the prior operation succeeded, the retry will not create extra tasks unexpectedly.
  • An Add Tasks request can include at most 100 operations.
  • All the tasks in an Add Tasks request must belong to the same workitem and job.

Conflicting extensions for PHP development have been detected: Visual Studio

So you want to dedug PHP within Visual Studio.

You went ahead and installed extension 1 PhpTools from downloaded msi “PhpTools.xxxx.msi” from visualstudiogallery.

And for complete the installation, you also installed extension 2(like I did) Vs.php from installer “php vsphp_en_xxxx_web_installer.exe downloaded from URL

Then Visual Studio throws up below exception.

—————————
Microsoft Visual Studio
—————————
Conflicting extensions for PHP development have been detected:
– VS.Php
Continuing using of Visual Studio may result in an unpredictible behaviour. To fix this issue, please uninstall conflicting extension above and restart Visual Studio.

—————————
OK
—————————

Why???

Because both these extensions are not supported by Visual Studio at same time, as they are conflicting in nature.

Why conflicting?  Because both extensions extend same features of Visual Studio and studio is saying that configuration of extension 1 has been or may be overwritten by extension 2.

So we need to uninstall one of these to use another.

What is ryujit?

It is a code name for a new x64bit JIT compiler being developed by Microsoft.

A new, next-generation x64 JIT compiler that compiles code twice as fast is ready to change your impressions of 64-bit .NET code

The traditonal 64-bit JIT currently in .NET isn’t always fast to compile your code, meaning you have to rely on other technologies such as NGen or background JIT to achieve fast program startup.

This new JIT is twice as fast, meaning apps compiled with RyuJIT start up to 30% faster (Time spent in the JIT compiler is only one component of startup time, so the app doesn’t start twice as fast just because the JIT is twice as fast.) Moreover, the new JIT still produces great code that runs efficiently throughout the long run of a server process.