0

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(IEnumerable1 source, Func2 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.

ojek
  • 9,680
  • 21
  • 71
  • 110
  • At least you need to post your `Scyk.MvcApplication.Application_Start()`... but based on the exception I guess some dll missing on the server. Make sure the the `Bin` directory contains the same files on the server and locally. And you should also check the plugins used by `XSockets` – nemesv Mar 31 '13 at 12:16
  • @nemesv: I don't think anything is missing since I am publishing everything on visual studio, so it should contain everything already. – ojek Mar 31 '13 at 12:31
  • What version of XSockets are you using? Guessing 2.3? – Uffe Mar 31 '13 at 15:54
  • @Uffe: Yeah, and I just wrote you a mail about it. :) – ojek Mar 31 '13 at 15:56
  • I have to go with the same tip as nemesv. You are probably missing some assemblies, but also check that you do not use the plugindirectory if you use the reference option. So if you have all your XSocketsPlugins in the bin, then set the config for the plugincatalog = "" – Uffe Mar 31 '13 at 16:51

3 Answers3

1

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).

  1. Install-Package WebActivator -Version 1.5.3
  2. 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

Uffe
  • 2,275
  • 1
  • 13
  • 9
0

Is the Application pool in integrated mode?

Peter Kiss
  • 9,309
  • 2
  • 23
  • 38
  • What is that? Why does that matter? – ojek Mar 31 '13 at 12:44
  • It's one of the two pipeline modes (processing modes) in IIS (the other is the classic, this was prior IIS7) and ASP.NET MVC requires an apppool with integrated pipeline mode. In the stack trace: EnsureAppStartCalledForIntegratedMode – Peter Kiss Mar 31 '13 at 14:23
0

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.

Jeremy
  • 3,880
  • 3
  • 35
  • 42