vb.net asp.net path to config files

JerryCic
2007-11-16
2013-04-22
  • JerryCic
    JerryCic
    2007-11-16

    Hi!

    I converted console app to vb.net 2005--- Success
    I then created a simple windows form version--- Success
    Now i am trying to write an Asp.net version --- no go.

    I have a web app called "Freind"
    I am using vb.net as code behind.

    I have a web form with a listbox, a textbox and a button. (simple)

    Here is my code behind:
    ************************************************************************
    Imports System
    Imports AIMLbot

    Partial Class _Default
        Inherits System.Web.UI.Page
        Dim myBot As New AIMLbot.Bot()
        Dim myUser As New User("webUser", myBot)

        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim r As New Request(TextBox1.Text, myUser, myBot)
            Dim res As Result = myBot.Chat(r)
            Me.ListBox1.Items.Add("You said: " + TextBox1.Text)
            Me.ListBox1.Items.Add("Response: " + res.Output)
            Me.ListBox1.SelectedIndex = Me.ListBox1.Items.Count - 1
        End Sub

        Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
            If Me.IsPostBack = False Then
                myBot.loadSettings("C:\Inetpub\wwwroot\Friend\Bin\config\")
                myBot.isAcceptingUserInput = False
                myBot.loadAIMLFromFiles()
                myBot.isAcceptingUserInput = True
            End If
        End Sub
    End Class
    ************************************************************************************

    The error occurs at the line:

    myBot.loadSettings("C:\Inetpub\wwwroot\Friend\Bin\config\")

    No matter what i put in there for a parameter or no parameter, i get the following error:
    ************************************************************************************
    Unable to find the specified file.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.IO.FileNotFoundException: Unable to find the specified file.

    Source Error:

    Line 17:     Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
    Line 18:         If Me.IsPostBack = False Then
    Line 19:             myBot.loadSettings("C:\Inetpub\wwwroot\Friend\Bin\config\")
    Line 20:             myBot.isAcceptingUserInput = False
    Line 21:             myBot.loadAIMLFromFiles()

    Source File: c:\inetpub\wwwroot\Friend\Default.aspx.vb    Line: 19

    Stack Trace:

    [FileNotFoundException: Unable to find the specified file.]
       AIMLbot.Utils.SettingsDictionary.loadSettings(String pathToSettings) +186
       AIMLbot.Bot.loadSettings(String pathToSettings) +52
       _Default.form1_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Friend\Default.aspx.vb:19
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Control.LoadRecursive() +131
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833
    ****************************************************************************************
    Any suggestions?

    Thanx
    Jerry Cic

     
    • JerryCic
      JerryCic
      2007-11-17

      I figured out that inside an asp.net environment environment.currentdirectory resolves to "c:\windows\system32\inetsrv" so i placed my config and aiml folders there. This worked.

      But!!!
      my next dillemma is :
      ****************************************************************
      Input string was not in a correct format.
      Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

      Exception Details: System.FormatException: Input string was not in a correct format.

      Source Error:

      Line 10:         'Dim r As New Request(TextBox1.Text, myUser, myBot)
      Line 11:         Dim r As New Request("Hello", myUser, myBot)
      Line 12:         Dim res As Result = myBot.Chat(r)
      Line 13:         Me.ListBox1.Items.Add("You said: " + TextBox1.Text)
      Line 14:         Me.ListBox1.Items.Add("Response: " + res.Output)

      Source File: c:\inetpub\wwwroot\Friend\Default.aspx.vb    Line: 12

      Stack Trace:

      [FormatException: Input string was not in a correct format.]
         System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2808723
         System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) +113
         System.Double.Parse(String s, NumberStyles style, NumberFormatInfo info) +188
         System.Convert.ToDouble(String value) +68
         AIMLbot.Bot.get_TimeOut() +57
         AIMLbot.Utils.Node.evaluate(String path, SubQuery query, Request request, MatchState matchstate, StringBuilder wildcard) +152
         AIMLbot.Bot.Chat(Request request) +687
         _Default.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\Friend\Default.aspx.vb:12
         System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
         System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
         System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
         System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
         System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
         System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
      ***************************************************************************

      Here is my code behind:

      Imports System
      Imports AIMLbot

      Partial Class _Default
          Inherits System.Web.UI.Page
          Dim myBot As New AIMLbot.Bot
          Dim myUser As New User("myID", myBot)

          Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
              'Dim r As New Request(TextBox1.Text, myUser, myBot)
              Dim r As New Request("Hello", myUser, myBot)
              Dim res As Result = myBot.Chat(r)
              Me.ListBox1.Items.Add("You said: " + TextBox1.Text)
              Me.ListBox1.Items.Add("Response: " + res.Output)
              Me.ListBox1.SelectedIndex = Me.ListBox1.Items.Count - 1
          End Sub

          Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
              If Me.IsPostBack = False Then
                  myBot.loadSettings()
                  myBot.isAcceptingUserInput = False
                  myBot.loadAIMLFromFiles()
                  myBot.isAcceptingUserInput = True
              End If
          End Sub
      End Class

      Any Suggestions?

      Thanx
      Jerry Cicierega
      (781) 820-9298

       
    • Hi,

      It appears that the value in your settings.xml bot configuration file for the timeout is not correct. Check that "timeout" is a number that can be converted into a double. For example "3000" will make the timeout 3 seconds (3000 milliseconds).

      Furthermore, please only use version 2.5 of the code as the current trunk is currently in heavy re-development and definitely won't work.

      Version 3 will be out "when its ready" (as they say), but this won't be too long. I would be disappointed if it wasn't ready before the new year.

      Best of luck with your project and let me know how you get on.

      Nicholas

       
    • JerryCic
      JerryCic
      2007-11-21

      Hi!

      Thanx for your help so far.

      I opted to implement the Bot server as an sql poller of requests. And have writen an asp.net page to function as a client app. The bots live in the server. The sql database is the go between.

      It works! Yeah! But it seems to take a few seconds before the bots response is displayed on the users page.

      So i would like to tweak the personality of the bot. From my vantage point, This is an overwhelming job.
      I am building a bot for my wife that behaves more like a wise old lady rather than a dry bot.
      Are there any existing aiml sets that may be closer to what i want that may be a better starting point?
      Or where do I begin?

      I've looked at the Settings config file. And that alone is a task to get it right. So the thought of getting into all the other aiml files is to vast to consider. I have assumed that all the aiml files are loaded into the bot at instantiation.
                  myBot.loadSettings()
                  myBot.isAcceptingUserInput = False
                  myBot.loadAIMLFromFiles()
                  myBot.isAcceptingUserInput = True
      That means that the system is very complicated.

      Any suggestions?

      Thanx
      Jerry Cicierega

       
    • Jerry,

      You might want to look at my example Web-service application in the downloads area. It is very basic but provides you with a recipe for starting up the bot within the application's process (you do it in Globals.aspx) so the bot is available from within the asp.net page's lifetime - i.e. you could call it to fill in the output text box during OnPreRender (for example). That might help with your performance issues.

      Concerning AIML sets. Take a look at the original alicebot.org site. I know Rich (Wallace) has published various AIML sets. The one provided with Program# is the standard one from this site. You might be interested to know that I'm currently working on an AIML editor that uses version 3 of AIMLBot.dll. However, there are other AIML editors out there (AIMLPad????) that might suit your purposes.

      Regarding loading of AIML files:

      On instantiation the bot can't possibly know where to find the files it needs. I suppose I could override the constructor - I'll certainly consider it for v.3.0 - but I decided to do it the way it is for the sake of greater control. I'd rather the developer decide when to populate the bot's brain and grab the settings as this might be time intensive (imagine how long it might take to load 10,000+ AIML categories).

      I always welcome feedback and if I can be persuaded I'll make any useful change to make developer's lives easier. How would you do it? (Now is a good time for feedback as I'm in the middle of developing version 3 and the code is quite elastic atm.)

      Best wishes,

      Nicholas