Custom Type Within ArrayList Inside Of The User Profile In C#?

Jan 22, 2010

I'm getting the following error when trying to save a custom class within my ArrayList within my user profile:

There was an error generating the XML document. ---> System.InvalidOperationException: The type Com.xxx.MyDataClass was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.

My web.config has something like:

<profile enabled="true" automaticSaveEnabled="false" defaultProvider="xxxxxxProvider">
<properties>
<add name="MyData" type="System.Collections.ArrayList"/>
</properties>
</profile>

I am trying to store my class called (something like) MyDataClass in an ArrayList into MyData. When I save I get the error above. The class MyDataClass has just two members for now, both set as 'string'.

I assume I have to tell the class has to serialize itself but I'm not sure how.

Here's the class:

namespace Com.xxxx.DataClasses
{
public class MyDataClass : ISerializable
{
public string elem1;
public string elem2;
public string Elem1
{
get { return elem1; }
set { elem1 = value; }
}
public string Elem2
{
get { return elem2; }
set { elem2 = value; }
}
....

UPDATE: FIXED

I was able to fix this issue via the following:

First of all here is a good resource: http://msdn.microsoft.com/en-us/library/d8b58y5d.aspx

I changed the profile entries to be:

<profile enabled="true" automaticSaveEnabled="false" defaultProvider="xxxxxxProvider">
<properties>
<add name="MyData" type="mypackage.MyDataClass" serializeAs="binary"/>
</properties>
</profile>

and then I created MyDataClass to contain a List<> of MyDataClassInfo objects similar to:

namespace Com.xxxx.DataClasses
{
[Serializable]
public class MyDataClass
{
List<MyDataClassInfo> myDataClassInfo;
public MyDataClassInfo()
{
myDataClassInfo = new List<MyDataClassInfo>;
}
public List<MyDataClassInfo> MyDataClassInfo
{
get;
set;
}
}

[Serializable]

public class MyDataClassInfo
{
public string elem1;
public string elem2;
public string Elem1
{
get { return elem1; }
set { elem1 = value; }
}
public string Elem2
{
get { return elem2; }
set { elem2 = value; }
}
....

The key here was 1) using the serializeAt="binary" and 2) using a class which contained a list instead of a list within the profile.

View 2 Replies


Similar Messages:

State Management :: Multidimentional Arraylist / Create A Arraylist Which Will Able To Store User Info?

Jul 16, 2010

i want to create a arraylist which will able to store user info like (username,machineIP,port ) for each user in the list & retrive this data when needed . any one tell me how i can do it or any alternative way without database or xml file.

View 6 Replies

Web Forms :: Profile Service Error - Unable To Load User Profile In Iis?

Jan 3, 2011

I am using profile services to store some attributes of users registered in the website. Now I am making a display profile page for a user. The problem is that the profile loads easily when I am running the site from VS 2010, but it gives the following error when I run it from IIS7 on my local machine:

System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

[Code]....

[code]....

View 4 Replies

Security :: Creating A Profile For A New User Is Updating Other Profile

Feb 4, 2010

I am logged in as user1, and while creating a user in which I have additional information which would store first and last name into the profile database. I have the following code

[Code]....

But because I just have profile like that, it is updating the profile of user1 not the new user i just created

[Code]....

View 5 Replies

Get The Int And String Data Type From Arraylist Using C#?

Dec 18, 2010

my arraylist contains the multiple value with different data type (string & int).now how can we retrive the data from arraylist

View 11 Replies

Custom Server Controls :: Unable To Use A Web User Control Inside Another Web User Control

Mar 10, 2011

I have a web user control that represents a simple message box. It is used to display simple messages like "Item has been deleted", or "The item was saved successfully".

On the other hand, I have another web user control that represents the item in the form of an editable form (I made this a user control because this is used in two different pages). I want to embed an instance of the message box user control inside the editable form. I am writing this right after the @Control directive:

[Code]....

Instead of using @Register directives, I register the user controls in web.config and so far this has worked just fine.

With the above markup, the project compiles, but whenever I try to navigate to a page that contains this construct, I get an HttpParseException exception. Furthermore, Visual Studio states that the tack w7rc9:MessageBox doesn't represent a known control.

What am I doing wrong?

View 2 Replies

User Controls :: Display User Profile Image Of Logged In User?

May 7, 2015

I would like users to upload a profile picture when they register, and to then show that picture in a picture box control when they are logged in based  on that specific user.

View 1 Replies

Configuration :: Error - Value Cannot Be Null. Parameter Name: Type About Profile

Oct 13, 2010

i have a WebSite project which i published, in the machine where i published the WebSite everything works smooth. when i moving it to the server, i got the Error:

Value cannot be null.Parameter name: type

Description:

An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null.Parameter name: type

and the details of it:

[code]...

How can i fix it?

View 1 Replies

Web Forms :: Create A Profile In Which The User Can Create And Edit His Profile?

Jun 25, 2010

I got the followig task.Create a website (Profile.aspx) in which the User can create and edit his profile.Well, I know how to write in a database, but how do I get the UserName oder the UserID to make a PrimaryKey?If the user is logged in a session will be started. In this session is the UserName but I don't know how to read out the UserName with ASP.NET to make an PrimaryKey. If I would try to read out the UserName with C# I must save it in an variable and give it somehow to my form.

asp:sqldatasource id="SqlDataSource1" runat="server"
connectionstring="<%$
ConnectionStrings:MyConnectionString %>"[code]....

View 4 Replies

Web Forms :: When New User Register / Get Pre-designed Page From Where User Can Update Profile?

Apr 20, 2010

I am working on Social Networking Website. My problem is that

when new user will register he/she will get Pre-designed Profile page from where user can update profile.

View 5 Replies

User Controls :: Upload Image And Display On User Profile Page?

Jan 8, 2014

I am making a Human resource Management system in which i have to make  employee profiles, there is a page in which i am entering employee name and uploading a rofile picture and i want the next page to show that image on a left corner of every employee...after clicking on the submit button of the previous page !

View 1 Replies

Data Controls :: User To User Profile View Showing Error

Apr 27, 2016

 When a user wants to view another user profile on user profile page this error will show up

 ERROR

Server Error in '/' Application.
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:
Line 72: protected void OnDataBound(object sender, EventArgs e)
Line 73: {
Line 74: string userName = (FormView1follow.Row.Cells[0].FindControl("hfUserName") as HiddenField).Value;
Line 75: string friendsUserName = (FormView1follow.Row.Cells[0].FindControl("hfFriendsUserName") as HiddenField).Value;
Line 76: string followStatus = (FormView1follow.Row.Cells[0].FindControl("hfFollowStatus") as HiddenField).Value;

 HTML

<div class="text-center">
<asp:FormView ID="FormView1follow" runat="server" OnDataBound="OnDataBound" Width="100%">
<ItemTemplate>
<asp:HiddenField ID="hfUserName" runat="server" Value='<%# Eval("UserName") %>' />
<asp:HiddenField ID="hfFriendsUserName" runat="server" Value='<%# Eval("FriendUserName") %>' />

[Code] .....

View 1 Replies

How To Add A Default Value To A Custom Profile Property

Jun 16, 2010

I know you can add defaultValues using the web.config like this:

<profile>
<properties>
<add name="AreCool" type="System.Boolean" defaultValue="False" />
</properties>
</profile>

but I have the Profile inherited from a class:

<profile inherits="CustomProfile" defaultProvider="CustomProfileProvider" enabled="true">
<providers>
<clear />
<add name="CustomProfileProvider" type="CustomProfileProvider" />
</providers>
</profile>

Heres the class:

Public Class CustomProfile
Inherits ProfileBase
Public Property AreCool() As Boolean
Get
Return Me.GetPropertyValue("AreCool")
End Get
Set(ByVal value As Boolean)
Me.SetPropertyValue("AreCool", value)
End Set
End Property
End Class

I don't know how to set the default value of the property. Its causing errors because without a default value, it uses an empty string, which cannot be converted to a Boolean. I tried adding <DefaultSettingValue("False")> _ but that didn't seem to make a difference.

I'm also using a custom ProfileProvider (CustomProfileProvider).

View 2 Replies

Get Custom Properties Common Profile?

Aug 16, 2010

How do I get access to my custom strong-named properties of the common profile (page.profile) in ASP.NET for a classes that does not derive from page? I thought I could just pass in httpcontext.profile but I'm missing the custom properties.

There should be some class type that I can pass in? It appears the class type is ProfileCommon and is auto-generated.

View 1 Replies

C# - How To Edit User's Profile Variable (from Web.config) While Specifying User

Sep 24, 2010

This is how I edit the profile variables for a currently logged in user:

Profile.variablename = "this";

How can I do the same thing, but specifying the username whose profile variable I want to change, as opposed to just the currently logged in user?

Something like Profile.variablename.("username", "this") is what I'm looking for.

I'm using C# asp.net.

View 1 Replies

Web Forms :: How To Get User Profile Property Name For All User Programmatically

Aug 25, 2010

I have to find User Profile property name programatically, not for a particular user, I have to find all properties name for all users at a time(not to iterate one by one) to display in webparts as columns.

View 1 Replies

Security :: Accessing Custom Profile Properties?

Mar 5, 2010

We have added some custom profile properties to the web.config - what we want to do is have the code access them once (when user logs in) and cache this so that the code doesn't have to hit the database each time we call Profile.<our custom profile property name>

What we see is a call to GetProperties or GetProfile each time we access Profile. <our custom profile property name> - whats the recommended way to do this?

View 4 Replies

Security :: Link To Profile Inside Loginview?

Sep 23, 2010

I need to have a link inside my asp:Loginview that says "My profile" and links to the users profile. Am I ignorant :S ?

View 4 Replies

Web Forms :: Custom Table Profile Provider Not Working

Feb 9, 2010

I am trying to use: [URL] I have downloaded the converted to VB files and inserted them in my app_code folder. I created the SQL table and ran both SQL stored procedures Now for the web.config, I already have a connection to my database for the aspnet memberships since I have it on my own database, so I used that for the connection and I did this:

[Code]....

But I get run time errors when I try to set a profile. The error I get is in the SqlTableProfileProvider.vb and it says "Incorrect syntax near ','." Which is really not enough information but that is all what it gives me

<profile defaultProvider="TableProfileProvider">
<providers>
<add name="TableProfileProvider"
type="SqlTableProfileProvider"
connectionStringName="LocalSQLServer"
table="UserProfile"
applicationName="DatabaseProfileProviderTest"/>
<add name="StoredProcedureProfileProvider"
type="SqlStoredProcedureProfileProvider"
connectionStringName="LocalSQLServer"
setProcedure="setCustomProfileData"
readProcedure="getCustomProfileData"........................

View 1 Replies

Web Forms :: Custom Table Profile Provider Has Different UserID?

Feb 11, 2010

I created the Table Profile Provider with the VB.NET and it works perfectly but I have one issue with it.. My Table (UserProfile) can't be linked with any other tables because the UserID on userprofile is different than any other table yet when I do profile.firstname on the vb code it works perfectly. Say for example I have a username called john If I do select * from aspnet_users where username = 'john' The results would come to 2 rows, 1 which has a userid and applicationid that is used on ALL the tables in my database EXCEPT for userprofile The second one would have a applicationid and userid that is only use on my userprofile table.

View 1 Replies

Web Forms :: Work With Custom Profile Data Table?

Aug 30, 2010

I would like to insert a user's selection of their organization (from a drpt down list) int their profile during the "Create new user" process. Unfortunately, when I tried to do it, I got an error saying that profile columns could not be inserted for anonymous users. The following code doesn't work:

[Web.Config]
[Code]....

[VB]
[Code]....

View 4 Replies

Security :: Custom Profile Data Intellisense Without Using C# Provider?

Jul 19, 2010

I've been experimenting with the ASP.NET profile system and I like how easy it is to add data to the profile programmatically and how to access it again, all in a single line.

However, I've see the input that it sticks in the database and I'm not too keen on it.

I'd really like to create my own separate tables, so everything is nice and logical and easy to access, but I'd still like to be able to access this "profile" data as easily as I could with the ASP.Net profile system.

Should I create some kind of class in a separate class file that does all the hard work, then I can access the information from intellisense?

View 2 Replies

Security :: Save Custom Property Into Member Using Profile?

Jan 14, 2011

I have been struggling to save custom property data into member using createuserwizard. I add some extra fields into createuserwizard using wizardsteps and What I would like to accomplish is to save extra data of that fields and see that data on admin backend of member section of umbraco cms.

What I have done so far in brief:

Created a user control using asp.net createuserwizard and save it to umbraco.

I also added a macro into usercontrol which pulls its data from dropdown list multiple render control data type which has some prevalues.

After selecting values and creating user, none of the selected values of dropdown list multiple render control data type are selected on admin backend but address are successfully saved.

Code behind file:Roles.AddUserToRole(UserName.Text, "BasicUsers");var profile = System.Web.Profile.ProfileBase.Create(UserName.Text);profile["sector"] = Sector.SelectedItem.Value;profile["address"] = Address.Text;profile.Save();

That relevant code snippet above works well like profile["address"] = Address.Text; but I am unable to save with other renders controls as Dropdown list multiple.

View 4 Replies

Security :: Configuration Error From Custom Profile Provider

Jun 3, 2010

I'm still trying to learn how all of this works, and I apologize if this is a simple fix, but I'm getting frustrated and I could use some help.

I found an XML profile provider that I'm trying to use, and when I set it up, it works fine on my local machine. However when I upload it to the server, I get an error and I don't really know what it means:

Server Error in '/' Application.

Configuration Error
Description:
An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: CustomProviders.XmlProfileProvider..ctor()

Source Error:

[Code]....

Source File: E:kundenhomepages28d241331304web.config Line:
38

The full profile section from the web.config file is:

<profile enabled="true" defaultProvider="XmlProfileProvider">
<providers>
<clear/>
<add applicationName="FamilySite" name="XmlProfileProvider" type="CustomProviders.XmlProfileProvider"/>
</providers>
<properties>
<add name="FirstName" />
<add name="LastName" />
<add name="HomeTown" />
<add name="ShowEmail" type="System.Boolean"/>
</properties>
</profile>

View 2 Replies

Security :: Displaying Profile Properties Using Custom SqlTableProfileProvider?

Mar 19, 2010

We've been using the custom SQL table profile provider offered on the MSDN site.No problem configuring the new provider and saving profile values into our custom table while using the Create User Wizard.However, we cannot seem to be able to display the profile properties, using

[Code]....

The user is logged in, and there are no problems displaying all membership values and role values.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved