juju
  • Posts: 35
  • Joined: 05/09/2009
hello YAF guru's,

I have created another website (main.domain.com) which uses the same YAF database of the yaf website (forum.domain.com). My goal is to have a registration page on main.domain.com which uses the same process of the forum.domain.com.

Since both sites are just in a single solution, i was able to import the necessary classes into the main.domain.com web application and add the assemblies into the web.config.

Then I add code to my created_user event similar to that of the register.ascx of forum.domain.com:


MembershipUser user = UserMembershipHelper.GetUser(this.cuwCreateMember.UserName);
YafUserProfile userProfile = YafUserProfile.GetProfile(this.cuwCreateMember.UserName);
userProfile.Save();

RoleMembershipHelper.SetupUserRoles(1, this.cuwCreateMember.UserName);
string displayName = ((TextBox)this.cuwCreateMemberStep.ContentTemplateContainer.FindControl("tbRealName")).Text.Trim();
int? userID = RoleMembershipHelper.CreateForumUser(user, displayName, 1);

LegacyDb.user_save(
            userID,
            1,
            null,
            null,
            null,
            600,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            false,
            null,
            null);


It all builds succesfully but I do get a run time error upon completion of registering a new user:


System.Reflection.TargetInvocationException was unhandled by user code
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
       at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at System.Activator.CreateInstance(Type type)
       at YAF.Classes.Data.MsSqlDbAccess.GetConnectionManager() in F:\FreeProjects\InterMed\CheriferProject\YAF.Classes\YAF.Classes.Data\mssql\MsSqlDbAccess.cs:line 502
       at YAF.Classes.Data.MsSqlDbAccess.GetDatasetBasic(IDbCommand cmd, Boolean transaction) in F:\FreeProjects\InterMed\CheriferProject\YAF.Classes\YAF.Classes.Data\mssql\MsSqlDbAccess.cs:line 604
       at YAF.Classes.Data.MsSqlDbAccess.GetData(IDbCommand cmd, Boolean transaction) in F:\FreeProjects\InterMed\CheriferProject\YAF.Classes\YAF.Classes.Data\mssql\MsSqlDbAccess.cs:line 538
       at YAF.Types.Interfaces.IDbAccessExtensions.GetData(IDbAccess dbAccess, IDbCommand cmd) in F:\FreeProjects\InterMed\CheriferProject\YAF.Types\Interfaces\Extensions\IDbAccessExtensions.cs:line 87
       at YAF.Classes.Data.LegacyDb.group_list(Object boardID, Object groupID) in F:\FreeProjects\InterMed\CheriferProject\YAF.Classes\YAF.Classes.Data\mssql\LegacyDb.cs:line 4401
       at YAF.Core.RoleMembershipHelper.SetupUserRoles(Int32 pageBoardID, String userName) in F:\FreeProjects\InterMed\CheriferProject\YAF.Core\UsersRoles\RoleMembershipHelper.cs:line 275
       at site.cherifer.ph.Default.cuwCreateMember_CreatedUser(Object sender, EventArgs e) in F:\FreeProjects\InterMed\CheriferProject\site.cherifer.ph\Default.aspx.cs:line 43
       at System.Web.UI.WebControls.CreateUserWizard.OnCreatedUser(EventArgs e)
       at System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser()
       at System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e)
       at System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e)
       at System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e)
       at System.Web.UI.WebControls.Wizard.WizardChildTable.OnBubbleEvent(Object source, EventArgs args)
       at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
       at DevExpress.Web.ASPxEditors.ASPxButton.OnCommand(CommandEventArgs e)
       at DevExpress.Web.ASPxEditors.ASPxButton.RaisePostBackEvent(String eventArgument)
       at DevExpress.Web.ASPxClasses.ASPxWebControl.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException: System.NullReferenceException
       Message=Object reference not set to an instance of an object.
       Source=YAF.Classes.Config
       StackTrace:
            at YAF.Classes.Config.get_ConnectionString() in F:\FreeProjects\InterMed\CheriferProject\YAF.Classes\YAF.Classes.Config\Config.cs:line 143
            at YAF.Classes.Data.MsSqlDbConnectionManager.get_ConnectionString() in F:\FreeProjects\InterMed\CheriferProject\YAF.Classes\YAF.Classes.Data\mssql\MsSqlDbConnectionManager.cs:line 78
            at YAF.Classes.Data.MsSqlDbConnectionManager.InitConnection() in F:\FreeProjects\InterMed\CheriferProject\YAF.Classes\YAF.Classes.Data\mssql\MsSqlDbConnectionManager.cs:line 162
            at YAF.Classes.Data.MsSqlDbConnectionManager..ctor() in F:\FreeProjects\InterMed\CheriferProject\YAF.Classes\YAF.Classes.Data\mssql\MsSqlDbConnectionManager.cs:line 55
       InnerException: 


I tried stepping through the code and it runs an exception on:

YAF.Classes.Data
MsSqlDbAccess.cs

at the following lines:


    [CanBeNull]
    public IDbConnectionManager GetConnectionManager()
    {
      return Activator.CreateInstance(this._connectionManagerType).ToClass<IDbConnectionManager>();
    }


But being a no0b i just cant get to wrtap my head around this. Could somebody point me to the right direction?

Thanks in advance.
hmmmm.... click thanks if my posts are useful
Sponsor
juju
  • Posts: 35
  • Joined: 05/09/2009
my apologies guys. after tinkering with this for another five hours or so i finally got it working. here is what i did in case somebody is trying to do the same:

- make sure all the related configuration settings in the app config is also present in the external site;
- add code to call the userprofile and save just enough information to create the a profile record.


(for some reason, after posting any question i have on the YAF forum always leads me to solve the problem myself. it's kind of a lucky mojo i think. i should post questions before i even start solving them 😂
hmmmm.... click thanks if my posts are useful
juju
  • Posts: 35
  • Joined: 05/09/2009
i would like to do a follow up question on this, i got stuck again and since it is still relevant to the original topic posted, it seems appropriate to post it here for continuity.

After going through the motions of setting up the initial controls (username, passwords, emails, etc), i looked at the procedure how the timezone combobox and the country combo was populated. i added the necessary controls and added the following code behind adding to the created_user event:


// get the time zone data source
var timeZones = (DropDownList)this.cuwCreateMember.FindWizardControlRecursive("TimeZones");
timeZones.DataSource = StaticDataHelper.TimeZones();

// get the country data source
DropDownList country = (DropDownList)step.ContentTemplateContainer.FindControl("Country");
country.DataSource = StaticDataHelper.Country();



Unusual enough, it compiles good but when I run it and get to the location page of the creatuserwizard no data is being loaded into the combo boxes.

I traced the method that it gets the data from the "english.xml" file, but I'm still baffled by the behavior.I tried passing in an overloaded parameter -
StaticDataHelper.Country("english.xml")
but it still does not load the country tag from the xml.

Any ideas? Please? C sharp newbie here... Be gentle 😊
hmmmm.... click thanks if my posts are useful
tha_watcha
  • Posts: 4116
  • Joined: 06/03/2010
Make sure you call the DataBind Method after you assign the DataSource

// get the time zone data source
var timeZones = (DropDownList)this.cuwCreateMember.FindWizardControlRecursive("TimeZones");
timeZones.DataSource = StaticDataHelper.TimeZones();
this.timeZones.Databind();

// get the country data source
DropDownList country = (DropDownList)step.ContentTemplateContainer.FindControl("Country");
country.DataSource = StaticDataHelper.Country();
this.country.Databind();


or

// get the time zone data source
var timeZones = (DropDownList)this.cuwCreateMember.FindWizardControlRecursive("TimeZones");
timeZones.DataSource = StaticDataHelper.TimeZones();

// get the country data source
DropDownList country = (DropDownList)step.ContentTemplateContainer.FindControl("Country");
country.DataSource = StaticDataHelper.Country();

this.Databind();

UserPostedImage
juju
  • Posts: 35
  • Joined: 05/09/2009
strange enough.. that was my first reaction- adding

this.timeZones.Databind();


was my initial solution but it still did not populate. I will try it again or maybe i just forgot to compile at first try.

Thank you
hmmmm.... click thanks if my posts are useful
Users browsing this topic
    Forum Jump  
    • You cannot post new topics in this forum.
    • You cannot reply to topics in this forum.
    • You cannot delete your posts in this forum.
    • You cannot edit your posts in this forum.
    • You cannot create polls in this forum.
    • You cannot vote in polls in this forum.

    About Us

    The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

    Powered by Resharper Donate with PayPal button

    Project Twitter Updates

    Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved