I've been receving this error "System.InvalidOperationException: The
namespace, , is a duplicate." and have been unable to locate the exact
cause of the exception.
I've written a webservice with the new AJAX extensions for .NET. The
webservice is marked up with
a ScriptService attribute tag along with each method being marked up
as a ScriptMethod.
Calls from the my client to the webservice still works correctly but I
get an error if I try to hit the webservice page directly. So during
compile time, there is something going on that's preventing IIS from
displaying the webservice page.
Any help will be much appreciated.
Here's some code sample of the webservice:
[WebService( Namespace="mynamespace" )]
[WebServiceBinding( ConformsTo=WsiProfiles.BasicProfile1_1 )]
[GenerateScriptType( typeof( CustomItem ) ) ]
[ScriptService]
public class MyWebService : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod( ResponseFormat = ResponseFormat.Xml)]
public CustomItem CreateNewItem(string name)
{
// do stuff here
return new CustomItem();
}
}
Please post the entire exception, complete with stack trace and inner
exceptions. If necessary, write out ex.ToString().
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer-
Hide quoted text -
- Show quoted text -
Here's the full exception throw by IIS:
------]
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The namespace, ,
is a duplicate.
[InvalidOperationException: The namespace, , is a duplicate.]
System.Xml.Serialization.XmlSchemaExporter.ExportSpecialMapping(SpecialMapping
mapping, String ns, Boolean isAny, XmlSchemaElement element) +762724
System.Xml.Serialization.XmlSchemaExporter.ExportRootIfNecessary(TypeScope
typeScope) +298
System.Xml.Serialization.XmlSchemaExporter.ExportMembersMapping(XmlMembersMapping
xmlMembersMapping, Boolean exportEnclosingType) +416
System.Web.Services.Description.SoapProtocolReflector.CreateLiteralMessage(Message
message, MessageBinding messageBinding, XmlMembersMapping members,
Boolean wrapped, Boolean rpc) +465
System.Web.Services.Description.SoapProtocolReflector.CreateMessage(Boolean
rpc, SoapBindingUse use, SoapParameterStyle paramStyle, Message
message, MessageBinding messageBinding, XmlMembersMapping members)
+103
System.Web.Services.Description.SoapProtocolReflector.ReflectMethod()
+360
System.Web.Services.Description.ProtocolReflector.ReflectBinding(ReflectedBinding
reflectedBinding) +2760
System.Web.Services.Description.ProtocolReflector.Reflect() +739
System.Web.Services.Description.ServiceDescriptionReflector.ReflectInternal(ProtocolReflector[]
reflectors) +621
System.Web.Services.Description.ServiceDescriptionReflector.Reflect(Type
type, String url) +117
System.Web.Services.Protocols.DocumentationServerType..ctor(Type
type, String uri) +159
System.Web.Services.Protocols.DocumentationServerProtocol.Initialize()
+336
System.Web.Services.Protocols.ServerProtocolFactory.Create(Type
type, HttpContext context, HttpRequest request, HttpResponse response,
Boolean& abortProcessing) +99
[InvalidOperationException: Unable to handle request.]
System.Web.Services.Protocols.ServerProtocolFactory.Create(Type
type, HttpContext context, HttpRequest request, HttpResponse response,
Boolean& abortProcessing) +258
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
+90
[InvalidOperationException: Failed to handle request.]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response)
+237
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext
context, String verb, String url, String filePath) +104
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext
context, String requestType, String url, String pathTranslated) +127
System.Web.HttpApplication.MapHttpHandler(HttpContext context,
String requestType, VirtualPath path, String pathTranslated, Boolean
useAppConfig) +175
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+120
System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +155
------ end
------------------------
This message seems to be coming from the server when it tries to serialize
the CustomItem being returned. It appears to have something to do with
processing the root of the serialized XML. You should take a look at your
attributes on the CustomItem class and its members.
If that doesn't help you, then please post your CustomItem class.