Archive
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:
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
andDotNetConfig40.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 the1033
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 toDotNetConfig40 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.
Robot modelling formats for simulation
Several XML-based formats have surfaced over the years that can be used to describe a robot.
Apart from URDF (and SRDF) of ROS origin, the Gazebo simulator has been promoting SDF (an evolution of URDF with emphasis on physics simulation), while MJCF apart from being available as URDF extensions, also has its own format with an XML schema for validation and more advanced simulation features (e.g. tendons).
URDF (ROS)
http://wiki.ros.org/urdf/XML/joint
http://wiki.ros.org/urdf/XML/link
Also related, units of measurement in ROS: http://www.ros.org/reps/rep-0103.html
Can find some well-known robots (like Boston Dynamics’ Atlas) in URDF format at the data subfolder in: https://github.com/bulletphysics/pybullet_robots
SRDF format http://wiki.ros.org/srdf that is mentioned at http://wiki.ros.org/robot_model is also related (adds Semantics like kinematic chain definition etc). As explained there it is combined with URDF in describing a robot:
This does not replace URDF, and is not an extension of URDF.
This is a format for representing semantic information about the robot structure.
A URDF file must exist for this robot as well, where the joints and the links that are referenced are defined
SDF (Gazebo)
http://gazebosim.org/tutorials?tut=build_model
http://sdformat.org
http://sdformat.org/spec
https://bitbucket.org/osrf/gazebo_models/src (various SDF models in XML)
http://gazebosim.org/tutorials/?tut=ros_urdf (Converting from URDF to Gazebo)
http://gazebosim.org/tutorials?tut=simple_gripper (tutorial for simple gripper in SDF)
Gazebo seems to be using ODE (Open Dynamics Engine), so these are related too:
http://www.ode.org/ode-latest-userguide.html#sec_7_3_0 (see images for Joint types)
http://www.ode.org/ode-latest-userguide.html#sec_3_6_0 (ERP & CFM constraint parameters)
MJCF (MuJoCo)
http://www.mujoco.org/ (MuJoCo 1.50 was released on April 23, 2017. Student licenses are now free)
http://www.mujoco.org/book/modeling.html
http://www.mujoco.org/book/modeling.html#CURDF (MJCF is an advanced format but some of its functionality is also available as URDF extensions)
http://www.mujoco.org/book/computation.html#Constraint (MuJoCo has constraints like Connect/Weld/Joint/Tendon/Distance)
https://homes.cs.washington.edu/~todorov/papers/TodorovIROS12.pdf (see paragraph «B. Elements of a MuJoCo model»)
URDF to MJCF conversion is possible (related sample available for MuJoCo):
http://www.mujoco.org/forum/index.php?threads/urdf-mjcf-conversion.3429/
There is ongoing work at Bullet Physics engine to import MJCF, as mentioned at:
https://github.com/bulletphysics/bullet3/releases
Thus, they have collected various MJCF models (XML):
https://github.com/bulletphysics/bullet3/tree/master/data/mjcf
HowTo: format XML output of DataContractSerializer
based on the other samples posted at StackOverflow on how to format XML created by DataContractSerializer, that use XmlWriter, here’s a version (from ClipFlair source code) that works with streams (and Ionic.Zip library in specific).
It also shows how the code is when you don’t apply formatting (using conditional compilation). Just comment out the #define (prefix it with //) to make it write unformatted XML.
#define WRITE_FORMATTED_XML
using System.Xml;
namespace ClipFlair.Windows
{
public partial class BaseWindow : FloatingWindow
{
//...
#if WRITE_FORMATTED_XML
private static XmlWriterSettings XML_WRITER_SETTINGS =
new XmlWriterSettings() { Indent=true, IndentChars=" "};
#endif
//...
public virtual void SaveOptions(ZipFile zip, string zipFolder = "")
//THIS IS THE CORE SAVING LOGIC
{
if (SavingOptions != null) SavingOptions(this, null); //notify any listeners
View.Busy = true;
try
{
ZipEntry optionsXML =
zip.AddEntry(zipFolder + "/" + View.GetType().FullName + ".options.xml",
new WriteDelegate((entryName, stream) =>
{
DataContractSerializer serializer =
new DataContractSerializer(View.GetType());
//assuming current View isn't null
#if WRITE_FORMATTED_XML
using (XmlWriter writer = XmlWriter.Create(stream, XML_WRITER_SETTINGS))
serializer.WriteObject(writer, View);
#else
serializer.WriteObject(stream, View);
#endif
}));
}
catch (Exception e)
{
MessageBox.Show("ClipFlair options save failed: " + e.Message);
}
finally
{
View.Busy = false; //in any case (error or not) clear the Busy flag
}
if (SavedOptions != null) SavedOptions(this, null); //notify any listeners
}
//...
}
}
Fix: The tag XXX does not exist in XML namespace ‘clr-namespace:YYY’
I just had some big trouble troubleshooting the Visual Studio / XAML compiler error message:
The tag XXX does not exist in XML namespace ‘clr-namespace:YYY’
It turned out this occurred because I had a Silverlight library with Assembly name X and default namespace X (at properties pane), but was using it from a demo project with Assembly name X (again!) and default namespace X.
If I removed the ";assembly=X" part from the XAML it worked fine, that is:
xmlns:my="clr-namespace:X"
Fixing the demo project to use Assembly name X.Demo and default namespace X.Demo (at its Properties pane), instead of having the same assembly name, now allows me to also use
xmlns:my="clr-namespace:X;assembly=X"
without problem.
Seems that when you have multiple assemblies with the same name in a project (wonder how the filesystem supports that), all of them are loaded fine and if they have classes with namespace X in them, the namespace gets classes from both assemblies (that’s why the xmlns without assembly=… works). When you specify assembly name in the XAML of a given project, it assumes you mean its own assembly, not any other referenced one with the same name.
BTW, at add references dialog I was using Projects option (to reference the output of other project in solution) and the project I was referencing was named X.Silverlight (can be named anything), I had not added reference the X assembly .dll file directly. Maybe that played its part too in the issue.
There may be other cases too that can cause this error to fire up, see:
http://social.msdn.microsoft.com/Forums/en/wpf/thread/56f933c8-a093-4c47-8e1a-cde4bb1864e9