Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在a";“听众”;在asp.net中不触发,但在控制台应用程序c中工作#_C#_Asp.net_Apache_Events - Fatal编程技术网

C# 在a";“听众”;在asp.net中不触发,但在控制台应用程序c中工作#

C# 在a";“听众”;在asp.net中不触发,但在控制台应用程序c中工作#,c#,asp.net,apache,events,C#,Asp.net,Apache,Events,我已经在控制台应用程序中实现了“ApacheGeode”,并成功地赢得了表单 我已将此解决方案转换为“类库” 当我调用这个类库来设置“缓存侦听器”时,它在控制台应用程序上工作,但在asp.net(MVC)应用程序中不工作 我曾尝试在MVC HomeController inside Index()方法中调用此dll。 这是dll中的内容: internal void RegisterQuoteListener(Cache c, string quoteReqId, Action<s

我已经在控制台应用程序中实现了“ApacheGeode”,并成功地赢得了表单

我已将此解决方案转换为“类库”

当我调用这个类库来设置“缓存侦听器”时,它在控制台应用程序上工作,但在asp.net(MVC)应用程序中不工作

我曾尝试在MVC HomeController inside Index()方法中调用此dll。 这是dll中的内容:

    internal void RegisterQuoteListener(Cache c, string quoteReqId, Action<string, Quote> AddQuote,
                                        Action<string, QuoteAcknowledgement> AddQuoteAck,
                                        Action<string, QuoteCancel> AddQuoteCancel)
    {
        List<string> s = new List<string>();
        s.Add(quoteReqId);

        IRegion<string, Object> q = c.GetRegion<string, Object>("quote");

        try
        {
            q.GetSubscriptionService().RegisterKeys(s);
            q.AttributesMutator.SetCacheListener(new LQuote<string, Object>(this, AddQuote, AddQuoteAck, AddQuoteCancel));
        }
        catch (Exception ex)
        {
            new ApplicationException("Can't register key: " + quoteReqId, ex);
        }
    }



    public override void AfterCreate(EntryEvent<TKey, TVal> ev)
    {
        HandleCreateAndUpdate(ev);
    }

geode.quotereRequest
内部,它设置了一个“侦听器”,该侦听器应该从初始化的缓存向方法触发一个事件。但是该操作从未被调用。

您如何准确地调用控制器中的dll?控制器不是单例,每个请求都会创建一个新实例,因此,如果您将帮助器类的实例存储在控制器的属性上,那么您的设置将不会持久化

理想情况下,您应该使用DI容器,该容器可以将助手类的单例实例注入控制器。您也可以尝试使用静态参数。

以下是答案:

如果您使用的GemFire本机客户端版本低于10.0.0 然后,您可能会在ASP.NET中遇到AppDomain问题。 虽然许多AppDomain问题在9.x中得到了缓解,但有些问题却没有得到缓解 可以在该版本中解决。更新至最新的10.x版本 应该解决你的问题


谢谢你的回复,我会尝试建议并回到这里。我已经编辑了回答你的问题。让一切保持静止是不可行的。这个DI怎么样?我应该如何调用此包装器/帮助器?QuoteRequest()是否同时设置侦听器和inmedialty触发事件?或者只是设置侦听器,然后稍后另一个调用将触发该事件?它设置侦听器并在“ManualResetEvent”等待ManualResetEvent.Set()(resume)在事件触发时被调用,但它没有。
 public ActionResult Index()
    {
        //var a = new Geode().QuoteRequestWrapper("EUR", "GBP", "GBP", DateTime.Now.Date.AddDays(14), 10, "any reference", true);

        //Create Instance
        Geode geode = new Geode();

        //Initialize Cache
        geode.InitializeCache(ip, port, pool);

        //Send Geode message
        geode.GeodePut("region1", Guid.NewGuid().ToString().Substring(0, 8).ToUpper(), "Starting Geode Test");

        //Quote request - single
        geode.QuoteRequest("EUR", "GBP", "GBP", DateTime.Now.Date.AddDays(14), 10, "any reference", true);
        return View();
}