Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 752 Vote(s) - 3.57 Average
  • 1
  • 2
  • 3
  • 4
  • 5
web.config, configSource, and "The 'xxx' element is not declared" warning

#1
I have broken down the horribly unwieldy web.config file into individual files for some of the sections (e.g. connectionStrings, authentication, pages etc.) using the configSource attribute.

This is working fine, but the individual xml files that hold the section 'snippets' cause warnings in VS.

For example, a file named roleManager.config is used for the role manager section, and looks like this:

<roleManager enabled="false">
</rolemanager>

However I get a blue squiggle under the roleManager element in VS, and the following warning: `The 'roleManager' element is not declared`

**I guess this is something to do with valid xml and schemas etc. Is there an easy way to fix this? Something I can add to the individual files?**

Thanks

P.S. I have heard that it is bad practice to break the web.config file out like this. But don't really understand why - can anyone illuminate me?
Reply

#2
I think that you get the blue squiggles since the schema of your web.config file doesn't declare these custom config sections that you've 'broken out' into individual files.

In investigating this, I see that some of my solutions have the same issue, but the config sections that are provided from microsoft DON'T have the squiggles. eg: we have extracted the appsettings and connectionstrings out into their own files, and they don't get the squiggles, but our custom ones do.

I tried to view the microsoft schema at schemas.microsoft.com/.netconfiguration/v2.0, but I get a 404 when trying to download it.

What I'm trying to say is if you get a copy of the MS schema and alter it to include your external config files, you should be able to get rid of the dreaded squiggles!

HTH,
Lance
Reply

#3
Searching a workaround to this matter using Custom Config Files, I found this solution. Dont know if is the correct one.

The problem is that VS cant find a schema to validate your .config (xml). If you are using "native" configuration elements or when you create your custom .config files you must set to every xml document a schema.

By default (in VS9 for example) all xml files use \Microsoft Visual Studio 9.0\Xml\Schemas\DotNetConfig.xsd
but you can add more schemas to use.

Before assigning a schema you must create it.

**To create a new Schema based on your own custom.config:**

1. open your custom config file
2. in menubar XML->Create Schema
3. save it

**To assign your schema:**

1. open your custom config file
2. in properties panel: click on the browse button [..]
3. set the 'Use' column to your recently created schema

you can assign as many you want. or have one schema for all your different custom .config files

(Sorry, but my English is not so good)
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through