我們在與我們的IoC容器類相關的app.config文件中有一個自定義部分。如何在編輯本節的配置文件時獲得智能感知,以及如何擺脫編譯器消息,通知我缺少架構。如何在app.config中爲自定義部分獲取智能感知?
我在這裏發現了這個問題:app.config configSections custom settings can not find schema information,但我不明白它是否適用於我的問題,以及如何使用答案。
我也發現這個頁面How to get Intellisense for Web.config and App.config in Visual Studio .NET,但它說在運行應用程序之前刪除xmlns屬性。這真的是唯一/最好的方式嗎?
下面是一個簡單文件的例子:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="ServiceContainers"
type="LVK.IoC.RegistrationsSectionHandler, LVK"/>
</configSections>
<ServiceContainers>
<Registration type="DatabaseConnection" class="DatabaseConnection">
<Parameter name="connectionString" type="System.String"
value="TYPE=MSSQL2000;SERVER=localhost;DATABASE=db"/>
</Registration>
</ServiceContainers>
</configuration>
基本上我希望能夠輸入<R
的<ServiceContainers>
節點內,並獲得註冊建議我在智能感知下拉列表中,還有適當的屬性。
+1。涉及到自定義配置部分時,架構經常被忽略。當你的管理員或合作伙伴必須對app.config或web.config進行更改時,它們非常有用。 – 2008-12-19 14:59:59
我有更好的解決方案。可能需要VS 2010,不知道:) http://stackoverflow.com/questions/1127315/how-do-i-make-an-extension-xsd-for-the-web-app-config-schema/7977168#7977168 – 2011-11-02 08:01:24