开发者

C# Execution stops without error when trying to call a method

First of all I am stumped. I have a search-module for a CMS that runs fine on one site, but it won't run as it's supposed to on another site.

I have this code I call both with an Ajax call and simply when loading the search site:

private string GetSearchContent()
    {
        Query q = GetQuery();  

        //for each area, set it up, perform search and render result

        IArea products = new ProductArea(GetEcomExcludedGroupIDs(), GetEcomLanguage()).Search(q);

        IArea pages = new PageArea(GetAreaId())
            .Search(q);

        IArea news = new NewsArea(GetIncludedNewsCategoryIDs())
            .Search(q);            
        ....
    }
开发者_开发知识库

The important part here is the Search function. This is implemented in the classes, but for some reason the code won't be executed.

I have tried splitting the code up so I am sure that is where the error lies. The freaky part is that it does not throw any exceptions, but it just stops executing whenever I try to call the Search function. It doesn't even enter the function.

The Search function looks like this:

public override IArea Search(Query q)
    {
        log.Debug("Product search");
        ....
    }

The function it overrides is simply an abstract function on an interface that declares the function.

I have tried copying the function to the same class that are executing it with no luck, and I have tried accessing other functions on the classes, and that worked fine.

My question is then. What could cause this behavior? I have tried looking around but couldn't really find any others with the same problem. And as mentioned before, the exact same code is running smoothly on another site.

I really hope someone can help me get closer to a fix, or at least to understand the problem.


The question is unanswerable as written. You assert that the Search method never runs, and that the faulty line is this one:

IArea news = new NewsArea(GetIncludedNewsCategoryIDs()).Search(q);

There are a few different things that could be wrong outside of the Search method:

  • The NewsArea constructor throws an exception
  • The GetIncludedNewsCategoryIDs method throws an exception
  • Either of the above could call into unmanaged code and generate a native Win32 exception, which under some circumstances will simple cause the process to terminate rather than ever returning to managed code.

You state that "there is no try-catch" -- all the more reason to disbelieve your assertion that the method just stops without throwing an exception. Try the following for diagnostic purposes:

try
{
    IArea news = new NewsArea(GetIncludedNewsCategoryIDs()).Search(q);
}
catch (Exception e)
{
    Logger.Log("Caught in the act: " + e.ToString());
    throw;
}

If you've run this and still see that the execution stops without logging any exception, then we'll look at other possibilities.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜