Results 1 to 6 of 6

Thread: Find Source:ContextHandler.cs

  1. #1
    Join Date
    Jun 2010
    Posts
    6

    Default Find Source:ContextHandler.cs

    Hello,

    I am new to Spring.Net, so I hope this is not a total newb question.

    I am writing my first spring application. When I try to run it I get a dialog box asking for me to tell it where ContextHandler.cs is. It seems to think it should be in: l:\projects\spring-net\trunk\src\Spring\Spring.Core\Context\Support\C ontextHandler.cs. I am not sure where it gets this path from. When I point it to the actual location I get an "Error creating context 'spring.root'" error.

    Any ideas?

    Thanks,
    Sammer

  2. #2
    Join Date
    Aug 2005
    Location
    Tampere, Finland
    Posts
    159

    Default

    Hi,

    that is just Visual Studio catching a Spring.NET initialization error and trying to guide you to the source of the error. The funny path it suggests is caused by the build machine and its directory structure.

    You shouldn't mind about that and just concentrate on the error message and trying to fix it

    -Marko

  3. #3
    Join Date
    Jun 2010
    Posts
    6

    Default

    Thanks for the response.

    Here is the actual issue. This is a web application. I have this in my web.config:

    ....
    <sectionGroup name="spring">
    <section name="objects" type="Spring.Context.Support.DefaultSectionHandler , Spring.Core"/>
    <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
    </sectionGroup>
    ....

    And this in my web page code behind button click method:
    protected void doSubmit(object sender, EventArgs e)
    {
    using (IApplicationContext ctx = ContextRegistry.GetContext())
    {
    ....

    It works fine the first time thru, but trying it again throws this:
    No context registered. Use the 'RegisterContext' method or the 'spring/context' section from your configuration file.

    Sammer

  4. #4
    Join Date
    Jun 2010
    Posts
    6

    Default

    One more detail, once I have encountered the error I have to shut down and restart Visual Studio for it to clear.

  5. #5
    Join Date
    Aug 2005
    Location
    Tampere, Finland
    Posts
    159

    Default

    You should access default application context with using construct as it disposes it after the block finishes. Are are returned always the same instance and you effectively delete it with using clause.

    -Marko

  6. #6
    Join Date
    Jun 2010
    Posts
    6

    Default

    Perfect, thanks very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •