According to the possibility of use custom section that must follow a precise
schema, I've implemented my own one. The problem is with the compiler, that
when start to debug my application hang up on the line of the web.config
telling me that the rule aren't stricly followed, but unfortunately it doesn't
say me where the error is located.
The strange thing is that using the schema in design-time, the schema works
fine; for instance I've implemented a multiple-element parameter that is
displayed correctly as well as the
required or optional ones. For what I know, when a schema isn't well formed,
the intellisene doesn't work at all, but in my case it works. Also parsing
the schema and the web.config with the on-line tool available on http://www.gotdotnet.com/team/xmltools/,
the schema results valid. But on F5 press ... Ta-daaaaaaaaaaaaaaa
By the way, here is the code I'm using ... I hope in some useful help.
<configuration>
<configSections>
<section name="FileUploaderSection" type="WebMA.Web.FileUploader.FileUploaderSection"/>
</configSections>
<FileUploaderSection xmlns="http://tempuri.org/FileUploaderDef.xsd">
<allowedFiles>
<Item bufferSize="1024" destPath="\public" fileName="default.aspx"
extension="*"
abortOnError="false" contentType="text/plain"/>
<Item bufferSize="1024" destPath="public" fileName="default1.aspx"
/>
<Item bufferSize="1024" destPath="public" fileName="default2.aspx"
/>
<Item bufferSize="1024" destPath="public" fileName="default3.aspx"
/>
</allowedFiles>
</FileUploaderSection>
e questo è il mio schema.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="FileUploaderSection" targetNamespace="http://tempuri.org/FileUploaderDef.xsd"
elementFormDefault="qualified" xmlns="http://tempuri.org/FileUploaderDef.xsd"
xmlns:mstns="http://tempuri.org/FileUploaderDef.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="allowedFiles">
<xs:complexType>
<xs:sequence>
<xs:element name="Item" type="mstns:singleItem" minOccurs="1"
maxOccurs="unbounded"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="singleItem">
<xs:sequence />
<xs:attribute .......>
...........
</xs:attribute>
</xs:complexType>
</xs:schema>
Bye
Andrea