智能感知与命名空间的自定义配置部分问题 [英] Intellisense for custom config section problem with namespaces

查看:163
本文介绍了智能感知与命名空间的自定义配置部分问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚推出一个自定义配置部分,创建了一个附带的模式文档进行智能感知并把它添加到Web.config的架构特性按<一个href="http://stackoverflow.com/questions/742905/enabling-intellisense-for-custom-sections-in-config-files/2044410#2044410">Michael葡萄汁的回答的另一个类似的问题。

I have just rolled a custom configuration section, created an accompanying schema document for Intellisense and added it to the Web.config's Schemas property as per Michael Stum's answer to another similar question.

不幸的是,还可能是由于我在创建XSD用手工有限的知识,智能感知依赖于的xmlns 属性指着我的XSD文件的命名空间是present在自定义的配置元素。然而,在运行项目时,我得到的无法识别的属性的xmlns。需要注意的是属性名称是区分大小写错误。

Unfortunately, and possibly due to me creating the XSD by hand with limited knowledge, the Intellisense relies on an xmlns attribute pointing to my XSD file's namespace being present in the custom config element. However, when running the project I get an Unrecognized attribute 'xmlns'. Note that attribute names are case-sensitive error.

我很可能只是修改我的XSD文件来定义的xmlns 属性的元素,但我想知道如果这仅仅是一个绷带固定到一个更大的问题。我必须承认,我没有XML命名空间的一个很好的理解,所以这可能是一个oppportunity直上几件事情让我。

I could probably just modify my XSD file to define the xmlns attribute for that element, however I am wondering if this is just a bandaid fix to a larger problem. I must confess I don't have a very good understanding of XML namespaces so this might be an oppportunity to set me straight on a few things.

下面是我的XSD文件的根目录的属性 XS:模式元素:

Here is the attributes for my XSD file's root xs:schema element:

<xs:schema id="awesomeConfig"
           targetNamespace="http://awesome.com/schemas"
           xmlns="http://awesome.com/schemas"
           elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
    ...
</xs:schema>

而就在Web.config文件中创建的元素,Visual Studio 2008中自动附加:

And on creating the element in the Web.config file, Visual Studio 2008 automatically appends:

<awesomeConfig xmlns="http://awesome.com/schemas"></awesomeConfig>

所以我有误解的 XS的含义是:?架构属性在所有的,或者是妥善解决那么简单,因为它似乎

So have I misunderstood the meaning of the xs:schema attributes at all, or is the proper solution as simple as it seems?

推荐答案

您的架构需要省略目标名称属性。实际上,这将使模式内容到默认的命名空间。

Your schema will need to omit the targetNamespace attribute. In effect, this will put the schema contents into the default namespace.

这是必要的,因为.NET配置系统从来没有批准的元素是在一个名称空间。

That's necessary because the .NET configuration system has never permitted elements to be in a namespace.

这篇关于智能感知与命名空间的自定义配置部分问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆