Windows 10 taskbar problems

Last July i updated my Windows 8.1 to 10, occasionally i noticed that on the taskbar was not present the alimentation icon; when was happening this problem Win 10 was not responding and i resolved the thing with a brute shutdown.
My installation is very slow to start, and i tried some operations; as a last resort yesterday i tried a registry defragmentation but this time the taskbar was dead: clicking on the start menu nothing, i was able to right clic the taskbar and change the properties.
From the other hand , the icons on desktop were working.
Before inserting the Windows 10 DVD and format, i tried to launch from Task Manager (fortunately i was able to right-clic the taskbar) an cmd console (Run New Task) with administrative privileges, and at the prompt:

sfc /scannow

nothing..
Then i tried to reinstall all using PowerShell , launching powershell and inside the powershell prompt with the command:

Get-AppXPackage -AllUsers | Foreach{Add-AppxPackage -DisableDevelopmentMode -register "$($_InstallLocation.)\AppXManifest.xml"}

Some complains about the fact that some installed software was more recent than the registry version, but my taskbar is now working.
Ok, still slow to start…but my new notebook should be ready this week.

Categories: Uncategorized

String or binary data would be truncated

Doing an INSERT INTO a SQL Server 2014 table from a complex join with UNION i got this error.
There were many fields, very difficult to understand at a first sight where was the problem.
Fortunately in SQL Management Studio right clicking the database with Tasks->Import data i inserted the SQL with UNION in the Data Source, and the destination table in the Destination.
The curious thing: in SQL Management Studio the INSERT INTO failed and no records imported, the same operation in the SQL Server Import and Export Wizard instead succeed but with warnings, which are useful to understand which fields causes truncation:
01-03-2016 14-49-13

Categories: SQL Server, SSIS

Windows 10 Mobile update crash

On my Lumia 925, originally sold with Windows 8.1, i installed the official Windows 10: at a certain point i made an hard reset and the phone automatically downloaded Windows 10.
The hard reset was done when i was not able to install updates on the Windows 10 preview (from Windows Insider); now there were an update for the official Windows 10 ending for 107, if i remember well, but the phone was not able to complete the install.
I noticed that continuously tapping on the screen, in order to avoid the phone standby, the procedure was able to end, but after the reboot the screen showed 2 gears and then a big sad smile , as this ->     : – (
No way to reset hard or soft, at every reboot the gears and then after a few seconds the dreaded smile: i was already thinking to buy a new phone.
But i discovered the Windows Device Recovery Tool, that after the downloading of 1,65 gb installed a working Windows 8.1 on my phone; and then using the Windows Phone Developer Registration 8.1 (installed with Windows Phone SDK 8.1) i re-registered the device in order to publish on it my apps developed with Visual Studio 2013.
Thanks to Google sync i lost nothing of interest, but anyway i will be suspicious about updating the 925 to Windows 10..

Cannot resolve the collation conflict

Making an UNION between two SQL Server 2014 views i got the error

Cannot resolve the collation conflict between “SQL_Latin1_General_CP1_CI_AS” and “Latin1_General_CI_AS”

There are many fields, a problem.. fortunately there is an easy solution with

SELECT
col.name, col.collation_name
FROM
sys.columns col
WHERE
object_id = OBJECT_ID('<yourview>')

With this query we get something as (fields name hidden for privacy):
01-03-2016 16-10-38
I tried with the first view and then with the another view in UNION, here is immediately visible which are the problematic fields (the few ones with another collation, in this case “Latin1_General_CI_AS”) .
Then for these fields we can add the collation, as in this case where there is also an CASE WHEN:

CASE WHEN TABDDETB = '' OR TABDDETB IS NULL THEN
   'Not specified' COLLATE SQL_Latin1_General_CP1_CI_AS
   ELSE TABDDETB COLLATE SQL_Latin1_General_CP1_CI_AS
END AS category

and the error is solved.

Categories: SQL Server

Microsoft Xamarin

Microsoft has acquired Xamarin.
Interesting project, but you must have a solid mobile business for each major environment (Ios-Android-Windows Phone): even for MSDN subscribers the editions are still not cheap, Xamarin Business is 799$ for developer.

Categories: Android, WinPhone

Firefox needs UTF8 for GeoXml3


I’m developing an WebAPI2 solution with Angular that receives, from Android devices, GPS points.
So Latitude , Longitude , Speed etc. are saved in a SQL Server 2014 table; from the web site the headquarter would follow the real time navigation.
The chosen approach was to write an KML file from the db data, and show this KML in a GoogleMaps window.
Having local files (not on another domain) the best solution is to use the GeoXml3 library, which is relatively easy to use (examples here and here).
For the javascript part, no problem: there is an simple setTimeout that calls via jQuery an WebAPI2 method that re-write the kml (the name is the record ID), and then adding an random number to the querystring the boss can follow the persons wandering somewhere, seeing the kml line that slowly progress on the map.
But there was an problem: On IE10 , 11, Chrome, Edge all ok; instead on Firefox (Windows or Ubuntu or Android tablet) no kml shown.
Sometimes the things are discovered in a very casual manner…i tried to save the KML with another name using Notepad++ , and change the code in order to not use the API call and instead try to show immediately this second file where i wanted to test some change, in order to understand what was wrong : bingo, KML immediately visible!
This was a real head scratching…the files (the generated from the system, and the one saved from the previous) in Notepad++ was absolutely the same, no visible difference.
So i tried to compare them with WinMerge and surprise, the generated file was full of strange characters before every normal character, immediately i realized “oops, the encoding?” and only after i noticed in Notepad++ that in the Encoding menu the file saved from Notepad++ itself was UTF8 encoded, and the one produced from the C# code was without encoding.
In the WebAPI2 method effectively i used Unicode: so now, all the browsers shows the KML writing the file as:

private async Task WriteTextAsync(string filePath, string text)
{
    //byte[] encodedText = Encoding.Unicode.GetBytes(text);
    byte[] encodedText = Encoding.UTF8.GetBytes(text);
    //
    using (FileStream sourceStream = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.None, bufferSize: 1048576, useAsync: true))
    {
        await sourceStream.WriteAsync(encodedText, 0, encodedText.Length);
    };
}

2016, the Cloud era

Categories: Uncategorized

Regex grouping for automatic coding

Sometimes is requested to do ugly and repetitive tasks.
For example there were some .aspx pages where in a DataGrid was written the DataField for monthly columns, but not the HeaderText (i don’t know why..).
Copy & paste, ok only 13 columns: but a lot of .aspx pages.
So i thinked to an substitution using regular expressions.
Tipically we have a string delimited with a double quotation mark, that we can express as

DataField=(["'])(.*?)\1

Or

DataField=(["'])(.*?)(["'])

Both are explainable as: the string begin with a ‘ or an ” , there could be an variable amount of chars or numbers and then there is a final ‘ ( or “)
The trick is in the parenthesis () , that isolates an regex group.
I use an old but valid tool, the Rad Software Regular Expressions Designer (the website is no more available), the basilar syntax is
0regex
If we introduce an group
1regex
We have surrounded with () the [“‘] expression, and there is a group ‘1’ referred to the char “.
The \1 is a regex reference to the first group (if you delete the parenthesis around [“‘] there is an error while evaluating the regex).
By using
2regex
We isolate the text between the ” couple.
Using the regex expression $<number> we can refer to these groups, so in Notepad++ i used
notepad
And for every DataField with the Replace All is created the HeaderText with the same month name.

Categories: RegEx, VB.NET

Delete hidden VM Image

I was experimenting with Azure, and i created an VM Windows Server 200 R2, for a customer demo.
Giving the fact that the customer is not ready for the cloud … :-)… , i deleted the vm in order to not leave unuseful objects in the portal.
The problem was that i made an vm image, in order to eventually reset to the initial conditions, and after the vm was deleted in the Azure portal there was still the Storage account:
27-11-2015 09-58-32
Then i tried to delete also this storage, but i received
27-11-2015 09-58-51
Let’s search for this vm image.. but apparently this vm image was a ghost: where to find it? In the CONTAINERS tab for the storage account there is nothing, and even exploring the preview portal i found nothing about vm images.
Ok , i’m a beginner with Azure, but should be provided some interface in order to easily discover these things.
After a while i discovered that when you create a new VM from the Gallery
27-11-2015 09-59-53
In the Gallery there are also your VM images:
27-11-2015 10-00-14
And so you can re-read the VM name
With the Powershell command Get-AzureVMImage , filtered by the name , effectively there were all the info about:
27-11-2015 10-14-12
Fortunately Azure PowerShell gives more opportunities than the portal: at this point i deleted the image with Remove-AzureVMImage
27-11-2015 10-16-14
So finally i was able to get rid of the Storage account from the Azure portal:
27-11-2015 10-17-00

Categories: Azure
Follow

Get every new post delivered to your Inbox.