4

I'd be grateful if anyone could point me towards the right direction for the following problem.

Given: Sharepoint 2010 project. FBA Authentication with custom user profile (class called UserProfile, inherited from ProfileBase). Custom user profile class is located in the Test.Utils library.

Required: Run a custom timer job once a day to get the list of user emails (require to fetch and compare data from UserProfile) to send notifications.

I've managed to get timer job running and fetching membership data, however I'm failing to fetch user profile details for a given user.

My owstimer.exe.config looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
    <connectionStrings>
        <remove name="Test-FBA" />
        <add connectionString="Data source=(local)\Sharepoint;Integrated Security=True;Initial Catalog=Test_dev;" name="Test-FBA" />
    </connectionStrings>
<system.web>
    <compilation>
        <assemblies>
            <add assembly="Test.UserUtils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5f674de4cd3d93d8" />  
        </assemblies>
    </compilation>
    <httpModules>
        <add name="Profile" type="System.Web.Profile.ProfileModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <add name="ProfileBase" type="System.Web.Profile.ProfileBase, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </httpModules>
    <membership defaultProvider="FBAMembershipProvider">
        <providers>
            <clear/>
            <add name="FBAMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
    applicationName="/" connectionStringName="Test-FBA" enablePasswordReset="true" 
    enablePasswordRetrieval="true" passwordFormat="Clear" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
    maxInvalidPasswordAttempts="3" minRequiredNonalphanumericCharacters="0" />
       </providers>
    </membership>
    <roleManager cacheRolesInCookie="false" defaultProvider="FBARoleProvider" enabled="true">
        <providers>
            <clear/>
            <add name="FBARoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
    applicationName="/" connectionStringName="Test-FBA" />
        </providers>
    </roleManager>
    <profile enabled="true" defaultProvider="SqlProfileProvider" inherits="Test.UserUtils.UserProfile, Test.UserUtils">
        <providers>
            <clear/>
            <add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/" connectionStringName="Test-FBA" />
        </providers>
        <properties>
        </properties>
    </profile>
    <authentication mode="Forms">
        <forms loginUrl="~/_layouts/FBA/Login.aspx" />
    </authentication>
  </system.web>
</configuration>

When I try to access UserProfile from timerjob class, i.e.

UserProfile profile = UserProfile.GetProfile(memberuser.UserName);

I get this error: Could not load file or assembly 'Test.Utils' or one of its dependencies. The system cannot find the file specified.

What I've tried: - This assembly is in the GAC. - I've stopped the SP timer, deployed the solution, restarted the timer to attach to the OWSTimer process - I've rebooted the IIS

Do I miss something else?

Thanks in advance!

Galiya

-- Update 13/09

First comments made me change the structure a bit. Now I have Test.UserUtils which don't reference to any custom DLLs except System and Sharepoint- related ones.

I have updated my OWSTimer.config.exe above to reflect my latest (still not working) version.

ULS Viewer provides me with the following error:

Exception stack trace:   
at System.Web.Profile.ProfileBase.InitializeStatic()    
at System.Web.Profile.ProfileBase.Create(String username, Boolean isAuthenticated)    
at Test.UserUtils.UserProfile.GetProfile(String username)    
at Test.Web.AlertManagement.TimerJob.SubscriberAlertsTimerJob.GetListRegisteredUsers(SPSite site, String connectionString)    
at Test.Web.AlertManagement.TimerJob.SubscriberAlertsTimerJob.GetListOfConfirmedSubscribers(String alertSectorsAsString, SPSite site, String connectionString)    
at Test.Web.AlertManagement.TimerJob.SubscriberAlertsTimerJob.Execute(Guid contentDbId)    
at Microsoft.SharePoint.Administration.SPTimerJobInvokeInternal.Invoke(SPJobDefinition jd, Guid targetInstanceId, Boolean isTimerService, Int32& result)

The code still fails at the call to UserProfile:

using System.Web.Profile;

namespace Test.UserUtils
{
    public class UserProfile: ProfileBase
    {
        public static UserProfile GetProfile(string username)
        {
            **return Create(username, true) as UserProfile;** <- fails here
        }
    }
}
2
  • Does Test.Utils have any references to other DLLs/Namespaces that you also need to include or install to the GAC? Sep 12, 2011 at 19:19
  • @John Yes, I had some references to other DLLs. Thanks for reminding about that. I've created a separate Test.UserUtils now which doesn't have any references except System and Sharepoint related. There is one which I had to add was System.Web, which I have a feeling creates some problems. See update.
    – Galiya
    Sep 13, 2011 at 10:26

1 Answer 1

2

When ever i see could not load assembly, the first thing i suggest trying is fuslogvw.exe to see what asseblies are tried loaded from where

Check out a guide here.

You could also try to debug the issue with Process Explorer.

1
  • Thanks for your message. I've debugged using Process Explorer and found out that previously I was using the dll, which has some dependencies. However, after my changes (see updated section) Process Explorer doesn't seem to suggest anything specific.
    – Galiya
    Sep 13, 2011 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.