Sequence contains no matching element
I have a web application written in ASP.NET MVC. Everything is okay, in visual studio app works just fine, but as soon as I put it on the IIS server, it gives me this error: Sequence contains no matching element
.
This is stack trace that it gives me:
[InvalidOperationException: Sequence contains no matching element]
System.Linq.Enumerable.Single(IEnumerable 1 source, Func
2 predicate) +4134530 XSockets.Plugin.Framework.Helpers.PluginHelpers.GetInstance(ImportedType importedType) +143 XSockets.Plugin.Framework.Composable.Compose(T obj) +656 XSocketsServer..ctor() +170
Scyk.MvcApplication.Application_Start() +173
[HttpException (0x80004005): Sequence contains no matching element]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12864673
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Sequence contains no matching element]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601
Can anyone help me here? I have no idea what is wrong, especially when everything is okay in visual studio...
Edit: my App_Start():
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
new XSocketsServer();
}
I am starting xsockets server in there, but anyways, if I comment out this XSocketsServer, it still gives me the same error.
I managed to reproduce the error. This seems to occur if you do not choose "rebuild solution" before starting the debugger. I can´t answer how you got the error on a IIS with precompiled assemblies though...
However, the workardound below should work (tested it quickly just now).
Use the PostApplicationStartMethod to start the server after App_Start has run.
[assembly: WebActivator.PostApplicationStartMethod(typeof(MyApplication.App_Start.XSocketsStart), "Start")]
And the class...
namespace MyApplication.App_Start
{
public static class XSocketsStart
{
public static void Start()
{
//Start the server.... In this case named Instance.
new Instance();
}
}
}
EDIT: Added a note about it on the public site: WorkAround
Regards Uffe
应用程序池是否处于集成模式?
Check to see if you're debugging as 32bit or 64 and how the server is setup. If the server is running 64bit you may have to enable 32bit applications in order to "reach" your third party dll.
链接地址: http://www.djcxy.com/p/38862.html上一篇: 指定参数超出有效值范围(参数名称:站点)
下一篇: 序列不包含匹配的元素