2012-08-26 14 views
0
错误

突然间,我开始在我ServiceStack MVC服务应用得到如下错误:给出的关键字并没有发现ServiceStack

{"The given key was not present in the dictionary."}  
System.Exception {System.Collections.Generic.KeyNotFoundException} 

和堆栈跟踪:

at System.ThrowHelper.ThrowKeyNotFoundException() 
    at System.Collections.Generic.Dictionary`2.get_Item(TKey key) 
    at ServiceStack.WebHost.Endpoints.Utils.FilterAttributeCache.GetRequestFilterAttributes(Type requestDtoType) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\Utils\FilterAttributeCache.cs:line 44 
    at ServiceStack.WebHost.Endpoints.EndpointHost.ApplyRequestFilters(IHttpRequest httpReq, IHttpResponse httpRes, Object requestDto) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\EndpointHost.cs:line 201 
    at ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\RestHandler.cs:line 79 
    at ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.ProcessRequest(HttpContext context) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\Support\EndpointHandlerBase.cs:line 150 
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

我已经不知道错误或错误是什么。我的应用程序正在工作,现在不工作。

任何想法如何解决这个问题?编辑1:当我浏览我的浏览器中的服务网址时,调试器永远不会到达我的服务类和Run方法。

+0

没有在编程世界突然发生。您在源代码/网站主机中更改了哪些内容? – walther

+0

说真的,我在DTO模型或App_Start \ AppHost.cs或其他方面没有改变任何东西。如果你想知道,我可以说我已经在同一个解决方案中改变了另一个应用程序中的方法。但是没有别的。我使用SVN跟踪更改和版本。 –

+0

您的web.config或web服务器是否已更改? –

回答

1

好吧,挺奇怪的! 以下是我采取的行动,但没有奏效。

  • 重新启动IIS和VS 2010
  • 编译代码和调试于2010年VS
  • 编译代码,并与IIS的内容更换并重新启动IIS。

下面是我的行动,并在项目开始重新工作。

  • 创建一个新的MVC项目。
  • 通过NuGet安装ServiceStack MVC。
  • 现有复制代码新的项目。
  • 重命名新项目中现有代码中的命名空间。
  • VS2010和项目的调试开始像魅力一样工作。

当我公布该项目在IIS上的现有的网站,我得到了以下错误:

AppHost instance has been already set 

然而,传递错误,我已经删除了现有的网站,并创建了一个新的一个。 比,我已经复制新网站的新项目输出。

所有开始像魅力再次工作。

但我仍然不知道为什么我得到了错误。

我希望这将有助于谁可能有同样的问题。

1

我在路线中使用错误的模型时收到此错误。

所以:

Routes.Add<ModelA>("/path/to/service"); 

应该

Routes.Add<ModelB>("/path/to/service"); 
+0

我在想同样的事情,但即使在移除其他模型和路由后,即使Hello服务示例也无法正常工作。 –

+0

我得到了问题中详述的异常,因为我对路线定义了错误的模型 – mattk