Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

telerik -- supercharge your DNN websites
  Ads  
Iron Speed Designer is a software development tool for building database, reporting, and forms applications for .NET without hand-coding.
 


  Sponsors  

Meet Our Sponsors

FCKeditor Project
Salaro -- Skins and more
OnyakTech
CrystalTech Web Hosting™
Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  BC30469: Reference to a non-shared member requires an object reference
Previous Previous
 
Next Next
New Post 8/13/2008 9:02 AM
User is offline Brian Dukes
476 posts
www.engagesoftware.com
8th Ranked


Re: BC30469: Reference to a non-shared member requires an object reference 

That code looks a lot better, I wasn't really sure what you were trying to do with the original code.

You're very close here.  When you call GetUserByName and GetRoleByName, you are getting a UserInfo and RoleInfo object, respectively.  You just need to go one step further and ask those objects what their ID is.  so, UserController.GetUserByName(0, UserName1).UserID and GetRoleByName(PortalSettings.PortalId, RoleName1).RoleID should be all that you need.

Hope that helps,


Brian Dukes
Engage Software
St. Louis, MO
314.966.4000

The leading provider of DotNetNuke support, training and custom module development.
 
New Post 8/13/2008 10:18 AM
User is offline RDO
56 posts
10th Ranked


Re: BC30469: Reference to a non-shared member requires an object reference 

Wonderful Brian, you are a life saver!

Now what about creating the role(s) if they dont already exist?

I tried:

If Roles.RoleExists(RoleName1) = False Then
                Roles.CreateRole(RoleName1)
            End If

I get the error:

A critical error has occurred.
Unable to connect to SQL Server database.

I dont beleve RoleExists is a DNN Method so how can I make this work, and how do I set the Roles.RoleInfo, Info (ServiceFee, BillingPeriod, RoleGroup, etc)

 
New Post 8/14/2008 9:02 AM
User is offline Brian Dukes
476 posts
www.engagesoftware.com
8th Ranked


Re: BC30469: Reference to a non-shared member requires an object reference 

You'll have to create a new RoleInfo object and set it up with a name, portalId, and whatever else you know about the role.  Then call DotNetNuke.Security.Roles.RoleController().AddRole(), providing that RoleInfo object.

Hope it helps,


Brian Dukes
Engage Software
St. Louis, MO
314.966.4000

The leading provider of DotNetNuke support, training and custom module development.
 
New Post 8/14/2008 12:33 PM
User is offline RDO
56 posts
10th Ranked


Re: BC30469: Reference to a non-shared member requires an object reference 

Protected Sub CreateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateButton.Click
            Dim objRoles As New RoleController
            Dim UserName1 As String = User.Text
            Dim RoleName As String = (NS.Text & "2")
            Dim userEmail As String = Membership.GetUser(UserName1).Email
            Dim userId As Integer = UserController.GetUserByName(0, UserName1).UserID
            Dim roleId As String = objRoles.GetRoleByName(PortalSettings.PortalId, RoleName).RoleID
            Dim objRoleInfo As New RoleInfo
            Dim objRoleController As DotNetNuke.Security.Roles.RoleController
            objRoleController = New DotNetNuke.Security.Roles.RoleController
            objRoleInfo.AutoAssignment = False
            objRoleInfo.BillingFrequency = "Month"
            objRoleInfo.BillingPeriod = 6
            objRoleInfo.Description = NS.Text & "2"
            objRoleInfo.IsPublic = False
            objRoleInfo.PortalID = 0
            objRoleInfo.RoleID = roleId
            objRoleInfo.RoleName = RoleName
            objRoleInfo.ServiceFee = "0.00"

            objRoleController.AddRole(objRoleInfo)
            objRoleController.AddUserRole(PortalSettings.PortalId, userId, roleId, Null.NullDate, Null.NullDate)

        End Sub

Causes the error:

 

A critical error has occurred.
Object reference not set to an instance of an object.

 

What does this mean?

 
New Post 8/14/2008 1:59 PM
User is offline RDO
56 posts
10th Ranked


Re: BC30469: Reference to a non-shared member requires an object reference 

Brian, I just realised two other problems.

1. How can I check is the role already exists before it tries to create it? Im assuming that can cause a problem if it tries to create something that is already there.

2. I need to be able to assign a RoleA to everyone in RoleB. I have been playing with GetUsersinRole but cannot get it to work. Is there a better way? How do I add this info to my code so that it adds each user to that role?

Any examples would be wonderful and I am still very new to DNN & vb

Thank you again very much!

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  BC30469: Reference to a non-shared member requires an object reference
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Powered by Adcuent®.Com
Adcuent® Consulting & Technology offers custom development web applications and hosting projects under the brand of Powered by Adcuent®.Com
www.adcuent.com
Easily Build DNN Solutions with XMod
XMod makes it easy to build news articles, house listings, custom feedback forms, product reviews and much more - without programming
www.DNNDev.com
Software Development and Integration with DNN
HNP Solutions focuses on the pragmatic use of technology and process to meet an organization's business objectives. HNP Solutions employs seasoned Enterprise and Solution Architects, Delivery Managers and QA & Business Leads. Our capabilities range from project assessments & recommendations, design & code reviews, to full program implementations. We also work with organizations in need of senior staff augmentation purposes in the areas of Enterprise and Solution architecture.
www.hnpsolutions.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP