users.config content deleted (xsi:nil="true")


I encountered a wierd issue with v 1.4 lately.
For no obvious reason the users.config file is cleared - all that stays in it is:
<?xml version="1.0"?>
<ArrayOfXmlUser xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:nil="true" />
The more often i access the Provider with Membership.GetUser() e.g. on each PageLoad
the more frequent my users.config is "sanitized" like shown above.
I came up with this ugly code on PageLoad for narrowing the issue - not 4 good coding practice ;-)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Membership.GetUser() IsNot Nothing Then
        If Roles.IsUserInRole(Membership.GetUser().UserName.ToString, "Administratoren") Or Roles.IsUserInRole(Membership.GetUser().UserName.ToString, "Contentverwalter") Then
            lTest.Text = "user is in role"
            lTest.Text = "user is NOT in role"
        End If
        lTest.Text = "i believe i just deleted myself ;-O"
    End If
End Sub
Load the Page a few times and users.config is history :-O

file attachments

Closed Feb 16, 2009 at 9:51 AM by velio


velio wrote Jan 21, 2008 at 4:36 PM

Wierd indeed.
I'm going to check it out.

wrote Jan 21, 2008 at 4:36 PM

wrote Jan 22, 2008 at 6:33 PM

wrote Feb 29, 2008 at 1:38 PM

Projekt2501 wrote Feb 29, 2008 at 1:46 PM

I have the same issue here. Content of the user.config is gone.

velio wrote Mar 1, 2008 at 6:48 AM

I'll fixe this next days.

Projekt2501 wrote Mar 1, 2008 at 11:33 AM

Thanks you very much :) Best Regards

wrote Mar 4, 2008 at 10:34 AM

wrote Mar 4, 2008 at 11:15 AM

Calios wrote Mar 7, 2008 at 4:02 AM

Im afraid v 1.5 did not fix it - my users.config again vanished:

<?xml version="1.0"?>
<ArrayOfXmlUser xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />

File was killed - again - for no obvious reason - ok i was debugging this time - but still ... .

velio wrote Mar 7, 2008 at 7:02 AM

I haven't reproduced the issue like you discribe it above.
Please, send me more details and code of the page where that happens.
Thanks in advance.


Projekt2501 wrote Mar 20, 2008 at 7:22 PM

I do have the same issue again with 1.5 as Calios has. One thing I noticed that it seems to kill the user.config when using impersonation. Using no impersonation does help, but the issue persists. I am trying to find the combination that breaks it. More details on that later.

velio wrote Mar 20, 2008 at 8:54 PM

Thanks a lot. I'm really looking forward.


Projekt2501 wrote Mar 20, 2008 at 10:07 PM

Hi, I attached an updated version of some source files. Basically I added [MethodImpl(MethodImplOptions.Synchronized)] to all of the attributes an methods of Persistable.cs and XmlUserStore.cs. This seems to fix the issue for me. Maybe it helps Calios, too.

Best Regards
Timo Griese

wrote Mar 20, 2008 at 10:07 PM

Projekt2501 wrote Mar 21, 2008 at 2:36 AM

While thinking about it, the same issue possibly applies to the Role / Profile providers, too. Might be worth a look.
Best Regards

velio wrote Mar 21, 2008 at 7:54 AM

Thanks a lot.
In the original source I have applyed [MethodImpl(MethodImplOptions.Synchronized)] just to the static factory method GetStore(fileName).
But now when you say I fixes the problem with membership file I will apply it to all methods.
And it alloways a good idea to synchronize the store classes and persistable.
I will do same fixes to to the release files later today.

Best Regards

wrote Mar 21, 2008 at 7:57 AM

wrote Mar 21, 2008 at 8:43 AM

velio wrote Mar 21, 2008 at 8:41 PM

I have implemented synchronized stores and set them in use in the new release 1.7


wrote Mar 21, 2008 at 8:41 PM

Projekt2501 wrote Mar 22, 2008 at 10:50 AM

Hi, as soon as I add the syncronized store classes to my project it keeps crashing right away. Strangely enough it seems to work if I do not add the syncronized stores to the project and seems to compile normally.

For now I reverted to my fixed 1.5. Would be great if you had a clue about this.

Best Regards

velio wrote Mar 22, 2008 at 7:36 PM

What is the Visual Stodio used by you and wich version .NET framework.
I have no problems at all to compile it.
Would you send me some details of the error you got.


Projekt2501 wrote Apr 1, 2008 at 10:56 AM


I use Visual Studio 2008 Standard. There is no problem to compile, but to execute. Strange that it works fine when the .syncronized files are not added to the solution, but when they are added the test-server crashes on startup. This is so strange :/ I will have to investigate some further and send you some details when I know more.
I saw you fixed the fileName issue. Is it possible to specify a path outside of App_Data ? Trying to do so leads to a crash for me.

Best Regards

deusBlue wrote Apr 24, 2008 at 1:21 AM

Unfortunately this problem just started happening for me on a new project on the latest release.

SyntaxError wrote Sep 3, 2008 at 3:44 PM

I'm using v2.0 and have the same problem. Everything was working correctly during development on my local machine with VS2005. The problem started to appear after I published the web application on a test server with IIS. Can you please help ?

Thanks in advance.

wrote Nov 12, 2008 at 2:11 PM

cheung7 wrote Feb 13, 2009 at 4:38 PM

hi i have the same problem, my user.config is cleared too. It apears when you login.
Im afraid too i use v 1.7 :

<?xml version="1.0"?>
<ArrayOfXmlUser xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />


It is strange, the code seems so complex.to debug...

velio wrote Feb 15, 2009 at 12:54 PM

** Closed by velio 11/12/2008 6:11 AM

velio wrote Feb 15, 2009 at 12:54 PM

Seems the problem persists and I look at the code again to solve it.

wrote Feb 15, 2009 at 12:55 PM

wrote Feb 16, 2009 at 7:31 AM

cheung7 wrote Feb 16, 2009 at 8:09 AM

Hello I want solve this problem, and i want to know how can i create a executable file to test your Library DLL

Thank you!

wrote Feb 16, 2009 at 9:51 AM

Resolved with changeset 31497.

cheung7 wrote Feb 16, 2009 at 11:08 AM

Hello, how can i to be sure ? What is the probleme with previous version ?? thanks you

cheung7 wrote Feb 16, 2009 at 11:10 AM

!! i only have to test your project .... and at first login , all users in your XML file was deleted !!!

cheung7 wrote Feb 16, 2009 at 11:25 AM

i use your version 31497 , and it was again bug, still no change... in your xml file, there are 2 user thate we can read, admin and member.

I login by admin / admin, after that, i read xml file but, all users was delete and the resut of xmlfile is :

<?xml version="1.0"?>
<ArrayOfXmlUser xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />


velio wrote Feb 16, 2009 at 12:42 PM

Which code you use when you get it from the source.
You should get the code from /Releases/Version-2.2 or better get the built assemblies from the Release 2.2 files.

velio wrote Feb 16, 2009 at 12:49 PM

Forgot you answer some of your questions :)
I'm sure because I reproduced the issue and then when fix it I tested number of time, but issue didn't appear any more.
Then I roll back the code changes and issue appears. After that I put the code changes again and issue gone, again tested number of times.

The cause was one lock more then I needed in Persistable. The method OnFileChanged is now changed to:
void OnFileChanged(string key, object value, CacheItemRemovedReason reason) {
        // invalidate value
        if (key == _fileName) _value = default(T);
Before that was surrounded with a lock.

Check if you have referencing the new build of the assembly you done when you get the latest code or it is some old copy of assembly in the bin folder of your webiste


cheung7 wrote Feb 16, 2009 at 2:53 PM

it is very strange, i cant reproduce the problem, it is random problem....
i launch 6 page aspx (iexplorer) asynchrone it write xml file by calling "validateuser(username,password)" and after call membership.getuser.

all page was independent, i cant find any trouble... i use your previous version but i suspect the trouble delete will appears!

Robosport wrote Jan 2, 2010 at 10:14 AM

I started using your terrific XML Providers (version 2.5 August 18, 2009 build) library about a month ago on a new project (with Visual Studio 2008, ASP.net 3.5) and it has worked well.

Today I made a change in my project in that I call Membership.GetUser during the loading of every page. As soon as I made that change I have a very similar problem to the last one reported in the comment by cheung7 (wrote Feb 16 2009 at 9:53 AM on this page). All the users in the Users.xml file are deleted (seemingly at random) and I have the xsi:nil="true" at the end of the last line in the XML file. I cannot create steps to reproduce (other than the description above) because sometimes it takes two page loads and sometimes it takes five or six. Eventually it always deletes the users though. Sounds awfully familiar to the bug discussed in this thread.

Did the fix (removing some of the locks?) from this thread stay in the latest version (2.5)?

I created a work-around by storing the user name in a session variable and accessing the session variable on every page load instead of Membership.GetUser to get the name or confirm if the user is logged in. But I'm worried about what might happen if my site scales up in usage enough to call Membership.GetUser frequently enough to run into this user deletion problem again.

Thank you in advance.

wrote Feb 14, 2013 at 12:09 AM

wrote May 16, 2013 at 6:27 AM