1

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 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.

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

the syntax /n was enough for me to add the namespace. No need for : in my case
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.