Search code examples
c#asp.netwsdl

VS2013 Import Namespace "syntax error"


I am customizing a WSDL help file for a webservice. Currently on my .aspx I have a bunch of imports at the top:

<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Xml.Serialization" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Schema" %>
<%@ Import Namespace="System.Web.Services" %>

The error list current has 102 errors (the maximum it can display) and they all point to line 1 (see above, System.Collections) with many different errors like "syntax error", "end of statment expected" and "declaration expected".

The service still works fine, and the namespaces are all being used properly. Should the namespaces be moved elsewhere? I want to handle this properly but couldn't find any information.


Solution

  • You need a page directive first

    <%@ Page Language="C#" %>
    

    More info about page directives. Basically, this should be on line 1 before the imports.