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

  • Home
  • SEARCH
  • 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 8939863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:54:42+00:00 2026-06-15T10:54:42+00:00

I am trying to run a simple application that uses drool.net. Whenever I execute,

  • 0

I am trying to run a simple application that uses drool.net. Whenever I execute, the application crashed at builder.AddPackageFromDrl("DroolsApp.Rules.drl", stream); The Error stated that NullReferenceException was unhandled and Object reference not set an instance of an object. I tried to change drl file but the error was still present. Am I missing anything? Also is there any site that provides a detailed tutorial for using drools.net and do I need any specific program to create and edit drl files as I am using a simple notepad.

Thanks in Advance

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using org.drools.dotnet.compiler;
using org.drools.dotnet.rule;
using org.drools.dotnet;
using System.IO;
using System.Reflection;

namespace DroolsApp
{
    class Program
    {   
        static void Main(string[] args)
        {            
            PackageBuilder builder = new PackageBuilder();
            Stream stream = Assembly.GetExecutingAssembly()
            .GetManifestResourceStream("DroolsApp.Rules.drl");
            builder.AddPackageFromDrl("DroolsApp.Rules.drl", stream);
            Package pkg = builder.GetPackage();
            RuleBase ruleBase = RuleBaseFactory.NewRuleBase();
            ruleBase.AddPackage(pkg);            
            executeRules(ruleBase, 5);
            executeRules(ruleBase, 6);
            executeRules(ruleBase, 7);
        }

        public static void executeRules(RuleBase ruleBase, int amount)
        {
            WorkingMemory workingMemory = ruleBase.NewWorkingMemory();
            Quest quest = new Quest();
            quest.Value = amount;
            workingMemory.assertObject(quest);
            workingMemory.fireAllRules();
        }
    }
}   

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DroolsApp
{
    class Quest
    {
        public int Value { set; get; }
    }
}

DRL File:    

package DroolsApp

rule "NumberFive"
    when
        quest : Quest( Value == 5 )
    then
            Console.WriteLine("FIVE");
end 

rule "NumberSix"
    when
        quest : Quest( Value == 6 )
    then
            Console.WriteLine("SIX");
end

Stack Trace:

System.NullReferenceException was unhandled
  Message=Object reference not set to an instance of an object.
  Source=drools.dotnet
  StackTrace:
       at org.drools.dotnet.semantics.DotnetClassTypeResolver.resolveType(String className)
       at org.drools.semantics.java.RuleBuilder.build(ColumnDescr columnDescr)
       at org.drools.semantics.java.RuleBuilder.build(RuleDescr ruleDescr)
       at org.drools.semantics.java.RuleBuilder.build(Package pkg, RuleDescr ruleDescr)
       at org.drools.compiler.PackageBuilder.addRule(RuleDescr ruleDescr)
       at org.drools.compiler.PackageBuilder.addPackage(PackageDescr packageDescr)
       at org.drools.compiler.PackageBuilder.addPackageFromDrl(String fileName, Reader reader)
       at org.drools.dotnet.compiler.PackageBuilder.AddPackageFromDrl(String fileName, Stream drlStream)
       at MinimalDroolsForm.Program.Main(String[] args) in C:\Users\Carl\Desktop\DroolsApp\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
  • 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-06-15T10:54:43+00:00Added an answer on June 15, 2026 at 10:54 am

    It’s for sure an error in drl file. Try to remove all rules and imports, compile them, and then add single line and repeat (it must validate though). Drools.net reacts for compilation errors with NullReferenceException or an error with loading CompiledRules0.dll (because it wasn’t generated). It is also a good thing to add a Pre-build Build Event deleting the previously generated CompiledRules0.dll (when Drools.net fails to generate the file it uses the previous one). Here’s the code:

    cd $(TargetDir)
    del CompiledRules0.*
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create an MVC3 C# simple application that uses facebook to
I'm trying to create a very simple PHP CLI application that can be run
I am trying to make a simple REST Service with .NET 4.0 that uses
I am trying to run a simple SQLITE application on Windows Mobile developed with
I am trying to run a simple multiple processes application in Python. The main
I'm trying to make a simple application that loads and runs some classes during
I'm trying to create a simple application that does a HTTP request/response on a
I'm trying to make a simple application in C# that allows me to kill
I am trying to make a simple web application using ASP.NET and Interop COM.
I am trying to create a single executable of a simple Win32 application that

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.