I have the same problem as described in this connect issue
http://connect.microsoft.com/VisualStudio/feedback/details/577382/classes-generated-by-xml-data-generator-tool-are-not-contained-within-the-specified-namespace
"An XSD file using the XML Data Generator Tool within a C++/CLI project will create a set of classes that are NOT within a namespace. The classes should be within the namespace specified by the Namespace property of the XML Data Generator Tool. This was detected when upgrading a VS2008 project to VS2010."
I see the /namespace option is on the command line of the XML Data Generator tool but still开发者_Go百科 it does not write the namespace.
In VS 2008
// This source code was auto-generated by xsd, Version=2.0.50727.3038.
//
namespace IOLib {
using namespace System;
ref class CPDS;
In VS 2010
// This source code was auto-generated by xsd, Version=4.0.30319.1.
//
using namespace System;
ref class CPDS;
Is there a way to force xsd tool to write the namespace too.
for xsd.exe
the parameter /n:
is used to specify the namespace. Don't put a space between the parameter and the value.
Example:
xsd myschema.xsd /c /n:MyNamespace
Visual Studio uses MSBuild to build the targets specified in the solution. They seem to be abandoning C++ in favor of VB and C#. VS 2010 uses settings in
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets`
file. The XSD section is missing an entry namely "Namespace". I set mine to
Namespace ="%(Xsd.Namespace)"
and compliled the xsd and the classes are now in the namespace I specify in the projects property pages.
精彩评论