Fix: “The Global element ‘xx’ has already been declared” warnings in config files after .NET framework upgrade in Visual Studio solution

Had just converted to target .NET framework 4.7.2 a Visual Studio solution full of 4.5 libraries, console apps and an MVC 5.0 (recently converted from 4.0) web app and all seemed to build fine, but then noticed that with web.config of the MVC web app open in the editor, it was showing lots of warnings of the form:

The Global element ‘xx‘ has already been declared in …

and marking them in the text with blue underscores under some whitespace

Seems others have had this issue too with configuration files (both ASP.net and Entity Framework ones) after changing target .NET framework:

https://stackoverflow.com/questions/11816916/fix-the-global-element-configuration-has-already-been-declared

Luckily the solution was hidden in that thread, just had to pick the best one (read on below)

– at https://stackoverflow.com/a/52274659/903783 one reads (see related screenshot there):

I noticed this issue with my VS2017.

Changing DotNetConfig.xsd to use "Automatic" solved the problem.

This doesn’t seem to work permanently (only worked once for a while for me)

– at https://stackoverflow.com/a/28114738/903783 is says:

With the symptoms as described in the question, and using Visual Studio 2013 (Update 4), I could see in the XML Schemas [sic] dialog that both DotNetConfig.xsd and DotNetConfig40.xsd were selected for use.

I’m using a .NET Framework 4.0 project.

The two XSD files conflict with each other, each defining the same elements, causing the warnings to be emitted.

These schema files are contained in the %programfiles(x86)%\Microsoft Visual Studio 12.0\xml\Schemas\ folder.

DotNetConfig.xsd is in the 1033 sub-folder and appears to be the newer, more complete version.

No matter what settings I selected in XML Schemas, I could not deselect, or remove DotNetConfig40 nor DotNetConfig. I tried "Remove", and changing the Use parameter from "Use this schema" to "Automatic" and then "Do not use this schema".

No matter what was selected, for either file, when I would return to the dialog, both would be selected for use. I also tried the trick of moving to another row before pressing "OK" to no avail.

Finally, I renamed the DotNetConfig40.xsd file to DotNetConfig40 DO NOT USE.xsd to prevent it from being loaded. This immediately solved the problem.

This does work (adapting the path for VS2017), but one isn’t sure (unless they check the file dates maybe) which file to keep, in my case it was 1033/DotNetConfig.xsd and DotNetConfig45.xsd, nor are they sure this won’t cause any side-effects in other solutions/projects.

– Finally, at https://stackoverflow.com/a/33823331/903783 it read:

I struggled with this for a while as well. Turns out, my version of the problem originated from the hidden {PROJECTNAME}.SUO file created by Visual Studio.

My guess is, VS will cache the XSD schema associations in this file. The warnings popped up after I changed the target framework, and they disappeared after I deleted the SUO file and restarted VS.

This fixed it permanently. Deletion of the .suo ended up with the DotNetConfig.xsd and removed the DotNetConfig45.xsd from the XML schemas list for the projects in the solution. In fact I deleted just a .suo file with no filename part, just a file extension, found by typing “.suo” at the search filter in the top-right of the solution’s folder window in Windows 10 File Explorer.

How-to: get int value via ADO.net SqlDataReader using column name

Based on Sam Holder’s answer at https://stackoverflow.com/questions/7388475/reading-int-values-from-sqldatareader/54296026, just contributed an extension method for fetching Int32 values via ADO.net’s SqlDataReader, without jumping through hoops (aka first fetch column ordinal [number] by name, then fetching the int value passing the column ordinal).

Would be nice if Microsoft was providing such things out of the box.

namespace adonet.extensions
{
  public static class AdonetExt
  {
    public static int GetInt32(this SqlDataReader reader, string columnName)
    {
      return reader.GetInt32(reader.GetOrdinal(columnName));
    }
  }
}

and use it like this

using adonet.extensions;

//…

int farmsize = reader.GetInt32("farmsize");

assuming there is no GetInt32(string) already in SqlDataReader – if there is any, just use some other method name instead

Microsoft AI solutions

* AI business solutions: https://partner.microsoft.com/en-US/solutions/practice-areas/artificial-intelligence

* AI platform: https://azure.microsoft.com/en-us/overview/ai-platform/

at the section «Open and comprehensive platform» (scroll down) and see the three tabs AI tools/AI frameworks/AI related infrastructure

* Azure (cloud) Machine Learning: https://azure.microsoft.com/en-us/overview/machine-learning/

– Machine Learning service (TensorFlow, PyTorch, or Jupyter etc.)
https://azure.microsoft.com/en-us/services/machine-learning-service/
https://docs.microsoft.com/en-us/azure/machine-learning/service/
– Machine Learning Studio (visual drag-drop/flow based)
https://azure.microsoft.com/en-us/services/machine-learning-studio/
https://docs.microsoft.com/en-us/azure/machine-learning/studio/
– Data Science VM (collection of third-party Machine Learning tools)
https://docs.microsoft.com/en-us/azure/machine-learning/data-science-virtual-machine/

* Azure DataBricks (Apache Spark-based BigData analytics): https://azure.microsoft.com/en-us/services/databricks/

* Visual Studio AI extensions:

https://docs.microsoft.com/en-us/azure/machine-learning/data-science-virtual-machine/

* Visual Studio Code (cross-platform IDE) AI extensions:

https://visualstudio.microsoft.com/downloads/ai-tools-vscode

* Bots (Conversational):

https://dev.botframework.com/

https://blogs.technet.microsoft.com/uktechnet/2018/02/02/an-introduction-to-the-microsoft-bot-framework-2/

https://app.pluralsight.com/library/courses/microsoft-bot-framework-getting-started-update/table-of-contents

* Cognitive Services: (pre-trained models for Speech, Face recognition, generating Q&A from unstructured text etc.)

https://azure.microsoft.com/en-us/services/cognitive-services/

https://app.pluralsight.com/library/courses/microsoft-azure-developer-creating-integrating-ai-azure-services/table-of-contents

* AI blog: https://azure.microsoft.com/en-us/blog/topics/artificial-intelligence/

* more resources for developers:

https://partner.microsoft.com/en-us/isv-resource-hub/develop-or-migrate-your-app

Fix: jqGrid search operator menu items jumping around on hover

A colleague noticed earlier on today, that on the Chrome browser they were using, the search operator menu items of a jqGrid on a web app’s UI were jumping around on hover, making it practically impossible to select one.

image   image

Seems this had started occurring on that ASP.net MVC web application, after a recent update to the latest jQuery-UI NuGet package.

Probably the issue wouldn’t occur if it wasn’t using the older free version of jqGrid. Will probably transition it eventually to free-jqGrid, the free fork (and quite evolved since forked) of the older free version of jqGrid, since jqGrid’s newer version is now commercial.

For the time being, I ended up adding this fix to Content/Site.css of the ASP.net MVC webapp:

/* jqGrid search operator menu item hover (uses jQuey-UI) */

a.ui-corner-all.g-menu-item.ui-state-hover {
    border: 1px #cccccc !important; /* fix for Chrome: removed "solid" (was causing hovered items to resize and menu to relayout, making it too hard to select them */
    /*border: 1px solid #cccccc;*/ /* this is used by jQuery-UI for .ui-state-hover */

    color: blue; /* showing blue color for hovered over menu text, should show better than a hover border since selected item already has a border itself */
}

This also has the added extra that on hover it shows the hovered item’s text in blue:

image

HowTo: change color of validation messages in ASP.net MVC

If you need to customize the colors (or do more restyling) of validation messages in ASP.net MVC, the following snippet from a discussion on ASP.net forums should be useful:

Add to Content/Site.css:

/* styles for validation helpers */

.field-validation-error {
    color: #b94a48;
}

.field-validation-valid {
    display: none;
}

input.input-validation-error {
    border: 1px solid #b94a48;
}

select.input-validation-error {
    border: 1px solid #b94a48;
}

input[type="checkbox"].input-validation-error {
    border: 0 none;
}

.validation-summary-errors {
    color: #b94a48;
}

.validation-summary-valid {
    display: none;
}

Other useful replies from there:

@Html.ValidationSummary(true,"",new {@style= "color: red"})

The method for MVC 5 + Bootstrap is:
@Html.ValidationSummary(true, "", new { @class = "text-danger" })

OpenStreetMaps as an alternative to Google Maps in Joomla!

If you use Joomla! (CMS / Content Management System), you could switch to the free OpenStreetMaps instead of the recently-turned-much-more-expensive Google Maps, thanks to the OSModul extension for Joomla!:

https://extensions.joomla.org/profile/extension/maps-a-weather/maps-a-locations/osmodul/

At the bottom of this page there is an example that uses a pin icon similar to how a location would appear in Google Maps. And here is an example with multiple pins (shown as ships).

A shortcoming in comparison to Google Maps is that OpenStreetMaps doesn’t show by itself many Points of Interest (POI) on the map for one to get oriented easier. For example the maps for the location at (38.29399, 21.78592) shows up a little bare: https://www.openstreetmap.org/query?lat=38.29399&lon=21.78592 compared to the same location shown on Google Maps: https://www.google.com/maps/place/38°17’38.4"N+21°47’09.3"E/@38.29399,21.78592

So it is best to add some such characteristic locations apart from one’s location pin, as shown at: https://gitlab.com/schlumpf/osmodul/wikis/Additional%20Markers%20Pins

More information on the OSModul extension for Joomla! can be found at:

https://gitlab.com/schlumpf/osmodul

https://gitlab.com/schlumpf/osmodul/wikis/How%20to%20use

%d bloggers like this: