Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 438283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:39:46+00:00 2026-05-12T20:39:46+00:00

I am using codeplex NVelocity library on .net and i want to catch an

  • 0

I am using codeplex NVelocity library on .net and i want to catch an error when I execute Evalute method on VelocityEngine instance and one of the parameter in template text was not found.

How can I obtain this?

I find IInvalidReferenceEventHandler interface in NVelocity.App.Event namespace but I dont’t find any information how to use it. Any help will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:39:46+00:00Added an answer on May 12, 2026 at 8:39 pm

    I’ve found the solution.

    I’ve made EventHandler class:

    public class NVelocityEventHandler : IInvalidReferenceEventHandler, IMethodExceptionEventHandler
    {
            #region IInvalidReferenceEventHandler Members
    
            public object InvalidGetMethod(NVelocity.Context.IContext context, string reference, object object_Renamed, string property, NVelocity.Util.Introspection.Info info)
            {
                return "InvalidGetMethod:" + reference;
            }
    
            public object InvalidMethod(NVelocity.Context.IContext context, string reference, object object_Renamed, string method, NVelocity.Util.Introspection.Info info)
            {
                return "InvalidMethod:" + reference;
            }
    
            public bool InvalidSetMethod(NVelocity.Context.IContext context, string leftreference, string rightreference, NVelocity.Util.Introspection.Info info)
            {
                return true;
            }
    
            #endregion
    
            #region IMethodExceptionEventHandler Members
    
            object IMethodExceptionEventHandler.MethodException(Type claz, string method, Exception e)
            {
                return "MethodException:" + method;
            }
    
            #endregion 
    }
    

    Then I use it in the code below:

    StringWriter writer = new StringWriter();
    NVelocity.App.VelocityEngine eng = new NVelocity.App.VelocityEngine();
    try
    {
        NVelocityEventHandler te = new NVelocityEventHandler();
        EventCartridge ec = new EventCartridge();
        ec.AddEventHandler(te);
        VelocityContext vc = new VelocityContext((IDictionary)parameters);
        ec.AttachToContext(vc);
        eng.Evaluate(vc, writer, "templatestring", template);
    }
    catch (ParseErrorException pe)
    {
        return pe.Message;
    }
    catch (MethodInvocationException mi)
    {
        return mi.Message;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the DotNetZip Library (http://dotnetzip.codeplex.com/) is there a way to move files from one
I just recently started using this library (the one from CodePlex), but I ran
I'm using one of the themes in CodePlex and I want to add some
So, i'm looking at the TekPub sample for ASP.NET MVC2 ( http://mvcstarter.codeplex.com/ ) using
I'm using Mobile Device Browser File ( http://mdbf.codeplex.com/ ) for my ASP.NET MVC 2
I'm using an MDI solution (see http://wpfmdi.codeplex.com/ ) and MVVM. I use one RelayCommand
I'm using the RazorEngine library ( http://razorengine.codeplex.com/ ) in an MVC 3 web application
I recently started using AutoFixture library (http://autofixture.codeplex.com/) for Unit Testing and I quite like
I'm using the WPF themes available on http://wpf.codeplex.com but I'd like to apply one
I am using the powercollections library from http://powercollections.codeplex.com/ The first test passes, however the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.