AspNetPgSqlMembershipProvider configuration issue

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
TonyV
Posts: 74
Joined: Wed 25 May 2011 15:03

AspNetPgSqlMembershipProvider configuration issue

Post by TonyV » Fri 14 Oct 2011 20:52

I have an application that runs as a Windows service which needs to make calls to the DevArt ASPNET Membership provider. I've got an app.config file in the project with the following content:

Code: Select all


	
		
		
		
		
	
	
		
			
			
		
	

	
		
		
			
				
				
			
		
		
			
				
				
			
		
	

I took most of the file's contents from the app.config for another program I have that uses this same code and just tweaked it as necessary.

To test the code, we have a number of unit tests set up. I am debugging the code in the service through the unit test. To be clear, the app.config file is in the service project, not the test project. The module being tested has a property called CurrentUserName, which is included below:

Code: Select all

public string CurrentUserName {
        get { return iCurrentUserName; }
        set { 
            iCurrentUserName = value;

            if ( ! string.IsNullOrEmpty( iCurrentUserName ) && ! string.IsNullOrWhiteSpace( iCurrentUserName ) ) {
                MembershipUser user = Membership.GetUser( iCurrentUserName );

                if ( user == null ) {
                    Log( string.Format( "User \"{0}\" is not a registered user.  Cannot proceed with this user.", CurrentUserName ), EventTypeEnum.Error );

                    // Set the current user name to the empty string and the current domain ID to null
                    iCurrentUserName = string.Empty;
                    CurrentDomainId  = null;
                }

                if ( user.IsLockedOut ) {
                    string msg = string.Format( "User \"{0}\" is currently locked out.  Cannot proceed with this user.", CurrentUserName );
                    Log( msg, EventTypeEnum.Error );

                    iCurrentUserName = string.Empty;
                    CurrentDomainId  = null;
                }

                CurrentUser = CarSystemUser.Attach( user, true );
                UserProfile = CurrentUser.UserProfile;
                UserProfile.Save();
                CurrentDomainId = UserProfile.DomainId;
            }
        }
    }
When I single step through the code, a FileNotFound exception is thrown on the "MembershipUser user = Membership.GetUser( iCurrentUserName );" line.

I checked the properties on the Devart.Data.PostgreSql.Web.dll file and they are set to Copy if newer. Is something wrong with my app.config or is it some other problem?

Tony[/quote]

TonyV
Posts: 74
Joined: Wed 25 May 2011 15:03

Nevermind

Post by TonyV » Fri 14 Oct 2011 21:06

I just checked the TestResults folder. It turns out that when you run a test, the Test system creates a new folder under the TestResults folder for your solution and copies the files from the test project's bin\Debug folder (if you're running in debug mode) into the Out folder of the new test specific folder.

And it's not copying the DevArt dlls, even though they're in the test project's bin\Debug folder. I've checked the settings for the 3 Devart DLLS that are used & they're set to Copy Always.

If anybody knows how I can get VS 2010 to copy these DLLs, I'd love to hear it.

In any event, if I put a breakpoint earlly in my test & manually copy the DLLs into the Out folder, it all works fine.

Tony

TonyV
Posts: 74
Joined: Wed 25 May 2011 15:03

Found how to copy the Dlls to the test folder automattically

Post by TonyV » Mon 17 Oct 2011 19:37

If you want a unit test to copy the Devart Dlls to the TestResult folder, and it isn't doing it, you have to edit the Test project's references.

Go into Solution Explorer & expand the References line. You should see the references to the Devart DLLs listed there. If you don't, that's add them. Once they're there, right click on each in turn & choose Properties.

On the Properties page, make sure "Copy Local" is set to True.

Once you've done this for all of the Dlls, they will all get copied to the TestResuts folder automatically.

Tony

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 19 Oct 2011 12:43

TonyV wrote:When I single step through the code, a FileNotFound exception is thrown on the "MembershipUser user = Membership.GetUser( iCurrentUserName );" line.
Try specifying the full type name in your app.config file:

Code: Select all

            
[code]            <add name="AspNetPgSqlMembershipProvider"
                type="Devart.Data.PostgreSql.Web.Providers.PgSqlMembershipProvider, Devart.Data.PostgreSql.Web, Version=5.30.172.0, Culture=neutral, PublicKeyToken=09af7300eec23701"

TonyV
Posts: 74
Joined: Wed 25 May 2011 15:03

I was able to resolve this

Post by TonyV » Wed 19 Oct 2011 13:48

It turns out that the problem was nothing in the configuration file. It had to do with the MS Test environment not copying the Devart DLLs into the test folder. See my previous reply to this thread.

Everything is working fine now. All I had to do was set the "Copy Local" property to true on the Devart DLLs & everything works.

Tony

Post Reply