0

I just can't get a handle on how to correct this one. It cropped up about a week ago, and I don't know what change I made could have caused this. We use SVN and I rolled back changes I made of possible culprits of these errors but I am still getting the following errors when I build my asp.net webforms project:

The namespace <global namespace> already contains a definition for 'TrxStatus'
The namespace <global namespace> already contains a definition for 'MessageStatusType'

These two errors are repeated 5 times (10 errors total) and the source files are code generated for the loads of webservices we have in the project.

The file names are App_Code.34kjg234jh1.cs (made up, but you get the idea) and at the top of each one it tells me where it is being generated from:

App_Code\App_WebReferences\SomeService\SomeWebService.wsdl

If I go into the .wsdl definition I believe they do all live in the same namespace based off of this line: (Note, I am not a .wsdl wiz, so tell me if I am wrong)

<s:schema elementFormDefault="qualified" targetNamespace="http://www.thirdpartysite.com/Soa/Foundation/">
<s:import namespace="http://www.thirdpartysite.com/Soa/Foundation/MessageDefinition.xsd" />

This is an application inherited from our prior developer (its a one developer shop here, so I usually get to poke around in the dark) so I don't know why we have about 7 different web services in the application, all with that namespace definition and ALL with the offending 'TrxStatus' and 'MessageStatusType'.

I don't want to change the namespaces, because it is the right namespace (I believe), but I also need this conflict to go away. I am not sure which direction to go.

I attempted to go into one of the .wsdl files and change TrxStatus to TrxStatus_Whatever but that gave me this error:

Unable to import binding 'MyWebServiceName' from namespace http://www.thirdpartysite.com/SOA/Foundation

Another possible clue is I am getting a ton warnings from the various web services that say something like this:

The 'http://www.thirdpartysite.com/Soa/Foundation/MessageDefinition.xsd:SomeElementName' element is not declared. 

Any suggestions on possible solutions to this? What is the root cause? Please don't tell me I need to re-write all these services....

4

1 回答 1

0

I'm by no measure an expert, in fact I do very little ASP.NET & Services.

BUT. It sounds as if there are conflicting imports (i.e usings) that are pulling in types with the same names.

proj1: A.SomeType proj2: A.SomeType

You can add references to both projects and it play just fine (I believe). But the difficulty comes when you import both namespaces because the type names clash.

You can access the correct type by using the global:: accessor.

You can even use global:: in a using statement.

using A = global::[path to correct project and type here]

Not sure if it'll be much use to you, but there's more info on global:: here:

http://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

于 2013-08-26T14:21:50.767 回答