ChatProvider not initialized

Last post 06-16-2010, 8:11 AM by Eric. 17 replies.
Sort Posts: Previous Next
  •  05-19-2010, 11:05 AM 61146

    ChatProvider not initialized

    We are trying to install the live support stand alone version.  We have the demo working on our local machine in C but are having trouble getting it to work in VB.
     
    We are getting the error
     
    CuteChat.AppChatIdentity identity = CuteChat.ChatProvider.Instance.GetLogonIdentity();
    We have installed the global file at the root and are wondering what we are missing?
     
     
    Graham
     
     
     
     
  •  05-19-2010, 11:28 AM 61147 in reply to 61146

    Re: ChatProvider not initialized

    Graham,
     
    Can you enable the details of the specific error message of the page?

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  05-20-2010, 1:03 AM 61159 in reply to 61146

    Re: ChatProvider not initialized

    northerncs:
    We are trying to install the live support stand alone version.  We have the demo working on our local machine in C but are having trouble getting it to work in VB.
     
    We are getting the error
     
    CuteChat.AppChatIdentity identity = CuteChat.ChatProvider.Instance.GetLogonIdentity();
    We have installed the global file at the root and are wondering what we are missing?
     
     
    Graham
     
     
    Hi northerncs,
     
    do you missing steps below?
     
    -----------------------------------------------------------------------
    Initialize an instance of provider when the application starts:

    CuteChat.ChatProvider.Instance = new MyChatProvider();
    CuteChat.ChatSystem.Start(new CuteChat.AppSystem());
     
    -----------------------------------------------------------------------
     
    Regards,
     
    ken
  •  05-20-2010, 8:26 AM 61177 in reply to 61147

    Re: ChatProvider not initialized

    I have the following code in the Global.asax at the website root.

    CuteChat.ChatProvider.Instance=new ExampleProvider();

    CuteChat.ChatSystem.Start(new CuteChat.AppSystem());



    And I get this error 

    Server Error in '/' Application.

    ChatProvider not initialized

    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.Exception: ChatProvider not initialized

    Source Error:

    Line 35: 	 {
    Line 36: 	    // Put user code to initialize the page here
    Line 37: 		CuteChat.AppChatIdentity identity = CuteChat.ChatProvider.Instance.GetLogonIdentity();	
    Line 38: 	}
    Line 39: </script>

    Source File: c:\Inetpub\wwwroot\ncsreseller\kfactorfilter\kfactorfilter.com\www\livesupport\banner.ascx    Line: 37

    Stack Trace:

    [Exception: ChatProvider not initialized] CuteChat.ChatProvider.get_Instance() +130 ASP.livesupport_banner_ascx.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\ncsreseller\kfactorfilter\kfactorfilter.com\www\livesupport\banner.ascx:37 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Control.LoadRecursive() +141 System.Web.UI.Control.LoadRecursive() +141 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
     
     
     
     
  •  05-20-2010, 8:30 AM 61178 in reply to 61177

    Re: ChatProvider not initialized

    I am trying to implement the example solution into a VB project.  Is this the cause of the errors?
  •  05-20-2010, 9:32 AM 61180 in reply to 61178

    Re: ChatProvider not initialized

    This issue has nothing to do with your programming language, you can download integration package, the download url is http://cutesoft.net/downloads/folders/chat_current_releases/entry28676.aspx, after unzip it, you can find one vb chat provider example in folder "CuteChatIntegrationPackage\ChatProvider examples", you can refer to it.
     
    Regards,
    Eric
  •  05-20-2010, 12:09 PM 61189 in reply to 61180

    Re: ChatProvider not initialized

    I am trying to get live support to work.
     
     
    Before posting to this forum I did get the demo to work in c# but I am integrating this into a VB application.  For some reason I can't get the livesupport to integrate with VB.  I copied all the files from the C# application into the VB one and it gives me the error mentioned at the top of this thread.
     
    That is why I am wondering if having the global file written in C# will interfer.  Trying to figure out what I am missing as the code is identical.
     
    Graham
  •  05-20-2010, 3:28 PM 61192 in reply to 61189

    Re: ChatProvider not initialized

    Can you post your full "Global.asax" and chat provider here?
     
    Regards,
    Eric
  •  05-20-2010, 7:41 PM 61193 in reply to 61192

    Re: ChatProvider not initialized

    Here is the global.asax

     

    <%@ Application Language="C#" ClassName="GlobalAsax" %>

    <%@ Import Namespace="CuteChat"%>

    <%@ Import Namespace="System.Data"%>

    <%@ Import Namespace="System.Data.Common"%>

    <script runat=server>

    public override void Init()

    {

    base.Init();

    lock(typeof(CuteChat.ChatSystem))

    {

    if(!CuteChat.ChatSystem.HasStarted)

    {

    CuteChat.ChatProvider.Instance=new ExampleProvider();

    CuteChat.ChatSystem.Start(new CuteChat.AppSystem());

    }

    }

    }

    public class ExampleProvider : ChatProvider

    {

    static string PasswordField="Password";

    static string LowerNickName="LOWER(NickName)";

    static string LowerLoginName="LOWER(LoginName)";

    static ExampleProvider()

    {

    if(System.Configuration.ConfigurationSettings.AppSettings["DatabaseType"]=="MSAccess")

    {

    PasswordField="[Password]";

    LowerNickName="NickName";

    LowerLoginName="LoginName";

    }

    }

     

     

    static string SqlEncode(string value)

    {

    if(value==null)return "NULL";

    return "'"+value.ToString().Replace("'","''")+"'";

    }

     

    #region //TODO:integration code for friend list:

    // public override AppDataManager CreateDataManagerInstance(AppPortal portal)

    // {

    // return new MyDataManager(portal);

    // }

    //

    // class MyDataManager : AppDataManager

    // {

    // public override void AddContact(ChatIdentity identity, string userid)

    // {

    // string myname=ChatProvider.Instance.FromUserId(identity.UniqueId);

    // string friendname=ChatProvider.Instance.FromUserId(userid);

    // MyCommunityDatabase.AddFriend(myname);

    // this.OnContactAdded(identity,userid,friendname);

    // }

    // public override void RemoveContact(ChatIdentity identity, string userid)

    // {

    // //get the username from cutechat's userid

    // string myname=ChatProvider.Instance.FromUserId(identity.UniqueId);

    // string friendname=ChatProvider.Instance.FromUserId(userid);

    //

    // //my custom implementation

    // MyCommunityDatabase.RemoveFriend(myname,friendname);

    //

    // //tell cutechat that the relative have been removed.

    // this.OnContactRemoved(identity,userid);

    // }

    // public override IChatUserInfo[] GetContacts(ChatIdentity identity)

    // {

    // string myname=ChatProvider.Instance.FromUserId(identity.UniqueId);

    // string[] friends=MyCommunityDatabase.GetFriends(myname);

    // IChatUserInfo[] arr=new IChatUserInfo[friends.Length];

    // for(int i=0;i<friends.Length;i++)

    // {

    // string friendid=ChatProvider.Instance.ToUserId(friends[i]);

    // arr[i]=base.GetUserInfo(friendid);

    // }

    // return arr;

    // }

    //

    // public override void AddIgnore(ChatIdentity identity, string userid)

    // {

    // base.AddIgnore (identity, userid);

    // }

    // public override void RemoveIgnore(ChatIdentity identity, string userid)

    // {

    // base.RemoveIgnore (identity, userid);

    // }

    // public override IChatUserInfo[] GetIgnores(ChatIdentity identity)

    // {

    // return base.GetIgnores (identity);

    // }

    //

    //

    // public MyDataManager(AppPortal portal):base(portal)

    // {

    // }

    // }

    #endregion

    public override string GetConnectionString()

    {

    if(System.Configuration.ConfigurationSettings.AppSettings["DatabaseType"]=="MSAccess")

    {

    string accessfile=System.Configuration.ConfigurationSettings.AppSettings["MSAccessFilePath"];

    accessfile=System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory,accessfile);

    return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+accessfile+";User Id=Admin;Password=;";

    }

    return System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];

    }

    /// <summary>

    /// Get the information of the current user

    /// </summary>

    public override AppChatIdentity GetLogonIdentity()

    {

    HttpContext context=HttpContext.Current;

    if(context!=null)

    {

    if(context.User.Identity.IsAuthenticated)

    {

    string loginName=context.User.Identity.Name;

    string cachekey="NickName:"+loginName;

    string userid=ToUserId(loginName);

    string nickName=null;

    bool exists=GetUserInfo(loginName,ref nickName);

    if(!exists)

    return null;

     

    return new AppChatIdentity(nickName,false,userid,context.Request.UserHostAddress);

    }

    }

    return null;

    }

    /// <summary>

    /// find the username by the displayname

    /// </summary>

    public override string FindUserLoginName(string nickName)

    {

    if(nickName==null)return null;

     

    using(IDbConnection conn=CreateConnection())

    {

    conn.Open();

    using(IDbCommand cmd=conn.CreateCommand())

    {

    cmd.CommandText="SELECT LoginName FROM SampleUsers WHERE "+LowerNickName+"="+SqlEncode(nickName.ToLower());

    using(IDataReader sdr=cmd.ExecuteReader())

    {

    if(sdr.Read())

    {

    return sdr.GetString(0);

    }

    }

    }

    }

     

    return null;

    }

    /// <summary>

    /// get the information from the user

    /// This function is very important and be called very frequently.

    /// </summary>

    public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)

    {

    string password=null;

    return GetUserInfo(loginName,ref nickName,ref password,ref isAdmin);

    }

    /// <summary>

    /// validate the user , and set the cookie

    /// </summary>

    public override bool ValidateUser(string loginName, string pwd)

    {

    string nickName=null;

    string password=null;

    bool isAdmin=false;

    bool exists=GetUserInfo(loginName,ref nickName,ref password,ref isAdmin);

    if(!exists)return false;

    if(password!=pwd)return false;

    System.Web.Security.FormsAuthentication.SetAuthCookie(loginName,false,"/");

    return true;

    }

     

     

    /// <summary>

    /// This function is very important and be called very frequently.

    /// </summary>

    public static bool GetUserInfo(string loginName,ref string nickName,ref string password,ref bool isAdmin)

    {

    loginName=loginName.ToLower();

    Hashtable table=(Hashtable)System.Web.HttpRuntime.Cache["UserInfo:"+loginName];

    if(table==null)

    {

    using(System.Data.IDbConnection conn=Instance.CreateConnection())

    {

    conn.Open();

    using(System.Data.IDbCommand cmd=conn.CreateCommand())

    {

    cmd.CommandText="SELECT * FROM SampleUsers WHERE "+LowerLoginName+"="+SqlEncode(loginName);

    using(System.Data.IDataReader sdr=cmd.ExecuteReader())

    {

    if(!sdr.Read())

    return false;

    table=new Hashtable(new CaseInsensitiveHashCodeProvider(),new CaseInsensitiveComparer());

    for(int i=0;i<sdr.FieldCount;i++)

    table[sdr.GetName(i)]=sdr.IsDBNull(i)?null:sdr.GetValue(i);

    }

    }

    }

    System.Web.HttpRuntime.Cache["UserInfo:"+loginName]=table;

    }

    nickName=table["NickName"].ToString();

    password=table["Password"].ToString();

    isAdmin=(1==Convert.ToInt32(table["IsAdmin"]));

    return true;

    }

     

    public static void CreateUser(string loginName,string nickname,string password)

    {

    using(System.Data.IDbConnection conn=Instance.CreateConnection())

    {

    conn.Open();

    using(System.Data.IDbCommand cmd=conn.CreateCommand())

    {

    cmd.CommandText="INSERT INTO SampleUsers (LoginName,NickName,"+PasswordField+",Email,IsAdmin) VALUES ("+SqlEncode(loginName)+","+SqlEncode(nickname)+","+SqlEncode(password)+",'',0)";

    cmd.ExecuteNonQuery();

    }

    }

     

    loginName=loginName.ToLower();

    System.Web.HttpRuntime.Cache.Remove("UserInfo:"+loginName);

    }

    public static void DeleteUser(string loginName)

    {

    using(IDbConnection conn=Instance.CreateConnection())

    {

    conn.Open();

    using(IDbCommand cmd=conn.CreateCommand())

    {

    cmd.CommandText="DELETE FROM SampleUsers WHERE "+LowerLoginName+"="+SqlEncode(loginName.ToLower());

    cmd.ExecuteNonQuery();

    }

    }

    loginName=loginName.ToLower();

    System.Web.HttpRuntime.Cache.Remove("UserInfo:"+loginName);

    }

    public static DataTable LoadUsers()

    {

    DataTable table=new DataTable("Users");

    using(IDbConnection conn=Instance.CreateConnection())

    {

    conn.Open();

    using(IDbCommand cmd=conn.CreateCommand())

    {

    cmd.CommandText="SELECT * FROM SampleUsers";

    using(IDataReader reader=cmd.ExecuteReader())

    {

    for(int i=0;i<reader.FieldCount;i++)

    {

    table.Columns.Add(reader.GetName(i),reader.GetFieldType(i));

    }

    object[] vals=new object[reader.FieldCount];

    while(reader.Read())

    {

    reader.GetValues(vals);

    table.Rows.Add(vals);

    }

    }

    }

    }

    table.AcceptChanges();

    return table;

    }

    public static void UpdateNickname(string loginName,string nickName)

    {

    loginName=loginName.ToLower();

    using(System.Data.IDbConnection conn=Instance.CreateConnection())

    {

    conn.Open();

    using(System.Data.IDbCommand cmd=conn.CreateCommand())

    {

    cmd.CommandText="UPDATE SampleUsers SET NickName="+SqlEncode(nickName)+" WHERE LOWER(LoginName)="+SqlEncode(loginName);

    cmd.ExecuteNonQuery();

    }

    }

    System.Web.HttpRuntime.Cache.Remove("UserInfo:"+loginName);

    }

    public static void UpdatePassword(string loginName,string password)

    {

    loginName=loginName.ToLower();

    using(System.Data.IDbConnection conn=Instance.CreateConnection())

    {

    conn.Open();

    using(System.Data.IDbCommand cmd=conn.CreateCommand())

    {

    cmd.CommandText="UPDATE SampleUsers SET "+PasswordField+"="+SqlEncode(password)+" WHERE "+LowerLoginName+"="+SqlEncode(loginName);

    cmd.ExecuteNonQuery();

    }

    }

    System.Web.HttpRuntime.Cache.Remove("UserInfo:"+loginName);

    }

     

    public static void UpdateIsAdmin(string loginName,bool isAdmin)

    {

    loginName=loginName.ToLower();

    using(IDbConnection conn=Instance.CreateConnection())

    {

    conn.Open();

    using(IDbCommand cmd=conn.CreateCommand())

    {

    cmd.CommandText="UPDATE SampleUsers SET IsAdmin="+(isAdmin?1:0)+" WHERE "+LowerLoginName+"="+SqlEncode(loginName);

    cmd.ExecuteNonQuery();

    }

    }

    System.Web.HttpRuntime.Cache.Remove("UserInfo:"+loginName);

    }

    }

     

    </script>
     
     
     

    chat provider

    I call it using this.  Not sure what you all need for this portion.  I used the stand alone demo.

    <script src='<%=ResolveUrl("~/CuteSoft_Client/CuteChat/")%>Support-Image-Button.js.aspx'></script>

     
     
  •  05-21-2010, 12:29 AM 61207 in reply to 61193

    Re: ChatProvider not initialized

    Hi northerncs,
     
    Is your site online? If so, can you set up ftp access for me? I will check it and get back to you as soon as possible.
     
     
     
    Regards,
     
    ken
  •  05-21-2010, 7:57 AM 61223 in reply to 61207

    Re: ChatProvider not initialized

    One other thing.  When i try to connect with the software it says, Login Form return OK, but login failed!
     
    I uploaded the CuteChat tables to SQL server and added the default username and password.
  •  05-24-2010, 3:52 AM 61257 in reply to 61223

    Re: ChatProvider not initialized

    northerncs:
    One other thing.  When i try to connect with the software it says, Login Form return OK, but login failed!
     
    I uploaded the CuteChat tables to SQL server and added the default username and password.
     
    Hi northerncs,
     
    File "CuteSoft_Client/CuteChat/SupportService.asmx" does not work on your site.
     
    So, please make sure your site can run asmx file correct.
     
    Regards,
     
    ken
  •  05-25-2010, 8:34 AM 61291 in reply to 61257

    Re: ChatProvider not initialized

     
    When I go to the directory in question the samples appear to work.  I only have a basic knoledge of SOAP and XML posts.
     
    When you go to the above page do you get an error?
  •  05-26-2010, 3:14 AM 61313 in reply to 61291

    Re: ChatProvider not initialized

    northerncs:
     
    When I go to the directory in question the samples appear to work.  I only have a basic knoledge of SOAP and XML posts.
     
    When you go to the above page do you get an error?
     
    Hi northerncs,
     
    I change your Global.asax, like below.
     
     public override bool ValidateUser(string loginName, string pwd)
     {
      string nickName=null;
      string password=null;
      bool isAdmin=false;
      bool exists=GetUserInfo(loginName,ref nickName,ref password,ref isAdmin);
      if(!exists)return false;
      if(password!=pwd)return false;

      System.Web.Security.FormsAuthentication.SetAuthCookie(loginName,false,"/");

      return true;
     }
     
    Change to
     
    public override bool ValidateUser(string loginName, string pwd)
     {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return true;
            }
            else { return false; }
     }
     
    ---------------------------------------------------------------------------------------
    Now, please create a test account to test it. and make sure the account is administrator.
     
    Regards,
     
    ken
  •  05-26-2010, 1:21 PM 61343 in reply to 61313

    Re: ChatProvider not initialized

    I have the default install with the default credentials.

    Table SampleUsers
     Fields 
    LoginName NickName, Password, Email, IsAdmin
    admin
    admin
    admin
    admin@localhost.com
    1
     
    It says "You entered an invalid password".
     
    Is it expecting the password to be encrypted in the database?
  •  05-27-2010, 4:51 AM 61380 in reply to 61343

    Re: ChatProvider not initialized

    northerncs:
    I have the default install with the default credentials.

    Table SampleUsers
     Fields 
    LoginName NickName, Password, Email, IsAdmin
    admin
    admin
    admin
    admin@localhost.com
    1
     
    It says "You entered an invalid password".
     
    Is it expecting the password to be encrypted in the database?
     
    Hi northerncs,
     
    Just confirm something.
     
    Do you have your own membership database? Or just use our demo database (install by CuteLiveSupport.sql)?
     
    If you using our demo database, just need to use the "Global.asax" in our demo. Do not need create your own chat provider.
     
    I suggest you deploy our demo as a separate application to test.
     
    If it works,  then integrate your own membership.
     
    Regards,
     
    Ken
  •  06-16-2010, 8:11 AM 61803 in reply to 61380

    Re: ChatProvider not initialized

View as RSS news feed in XML