QQ客服热线
首页 > 信息资讯 > 技术专栏

技术专栏

异常消息: 已添加项。字典中的关键字:“RegEx”所添加的关键字:“RegEx” 解决方法
2014年5月12日
摘要: 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

已添加项。字典中的关键字:“RegEx”所添加的关键字:“RegEx”

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.ArgumentException: 已添加项。字典中的关键字:“RegEx”所添加的关键字:“RegEx”

源错误: 

 

执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。


堆栈跟踪: 
 

[ArgumentException: 已添加项。字典中的关键字:“RegEx”所添加的关键字:“RegEx”]
   System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) +9355915
   System.Collections.Hashtable.Add(Object key, Object value) +11
   System.Configuration.Provider.ProviderCollection.Add(ProviderBase provider) +90
   UrlRewritingNet.Configuration.Provider.UrlRewritingProviderCollection.Add(ProviderBase provider) in E:\web2014\TCwebWeddKing\Libraries\UrlRewritingNet.UrlRewriter\Configuration\Provider\UrlRewritingProviderCollection.cs:19
   UrlRewritingNet.Web.UrlRewriting.Initialize() in E:\web2014\TCwebWeddKing\Libraries\UrlRewritingNet.UrlRewriter\Web\UrlRewriting.cs:58
   UrlRewritingNet.Web.UrlRewriting.get_Providers() in E:\web2014\TCwebWeddKing\Libraries\UrlRewritingNet.UrlRewriter\Web\UrlRewriting.cs:96
   UrlRewritingNet.Web.UrlRewriting.CreateRewriteRule(String providerName) in E:\web2014\TCwebWeddKing\Libraries\UrlRewritingNet.UrlRewriter\Web\UrlRewriting.cs:110
   UrlRewritingNet.Web.UrlRewriting.CreateRewriteRule() in E:\web2014\TCwebWeddKing\Libraries\UrlRewritingNet.UrlRewriter\Web\UrlRewriting.cs:103
   UrlRewritingNet.Web.UrlRewriteModule.Init(HttpApplication context) in E:\web2014\TCwebWeddKing\Libraries\UrlRewritingNet.UrlRewriter\Web\UrlRewriteModule.cs:326
   System.Web.HttpApplication.InitModulesCommon() +172
   System.Web.HttpApplication.InitModules() +43
   System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +828
   System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +304
   System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +327

 解决方法:修改UrlRewritingNet.UrlRewriter\Configuration\Provider\UrlRewritingProviderCollection.cs

public class UrlRewritingProviderCollection : ProviderCollection
    {
        public override void Add(ProviderBase provider)
        {
            if (provider == null)
                throw new ArgumentNullException("provider");
            if (!(provider is UrlRewritingProvider))
            {
                string msg = string.Format("Provider must implement type {0}", typeof(UrlRewritingProvider).ToString());
                throw new ArgumentException(msg, "provider");
            }
            if (base.Count == 0)
            {
                base.Add(provider);//增加判断是否已经插入Hash表
            } 
        }
        public void CopyTo(UrlRewritingProvider[] providers, int index)
        {
            base.CopyTo(providers, index);
        }
        new public UrlRewritingProvider this[string name]
        {
            get
            {
                return (UrlRewritingProvider)base[name];
            }
        }
    }

来自TCNET 转载请保留www.nbtcnet.com

返回列表