views:

88

answers:

2

Hi everyone,

I have a web application which uses membership and profiles. I successfully used the WebProfileBuilder extension, so my profile class is correctly generated, and is working nicely.

However, after a new request of my client, I need now to move that profile management part into another assembly (so I'd be able to get profile information in a windows service running on the same machine).

What I made is created the new assembly, moved my generated profile file, and tried to use it from the other assembly, but without any success. I always get a SettingsPropertyNotFoundException. My thought is that the profile system doesn't know where to find its connection information, so I tried to add the connectionstring and provider in the app.config of this assembly, but this doesn't seem to work.

What am I missing ? Is it possible to do ?

Thanks in advance!

A: 

I've got a nasty suspicion that your APP.Config file won't be picked by the web application; did you keep the settings in your Web.Config file ?

I've only found app.config to work on such an assemply when using NUnit or similar.

Russ C
I removed what was between `<profile>...</profile>` from my web.config, and the problem is still there.
Shimrod
Oh sorry, I mean to say you should try and keep the stuff in web.config and *not* move it to the app.config.I had exactly the same problem trying to consume some WCF services. The designer insisted on putting the bindings in app.config, but then threw the exception when I tried to load the page. I had to move the settings into Web.Config then it all started working.
Russ C
This was my initial try, and it doesn't work either :-(Now... Given that my windows service is using the new assembly, where should I place the app.config ? In the assembly or in the windows service ?
Shimrod
Just made another try, disabling the profileBuilder, removing the generated files from the web app, so I'm sure it only uses the profile part of the new assembly. I also removed the config section in the *web.config*, and got the same error. Will made other tries, and keep you updated...
Shimrod
Ok I'm kind of lost now... I retried the same setting as just before, but with the profile settings present in the *web.config*... And the website part works now! Now I still have to understand why it doesn't work with the new assembly...
Shimrod
A: 

Ok I found what's wrong... Thanks to this blog post:

http://fredrik.nsquared2.com/viewpost.aspx?postid=244&amp;showfeedback=true

The only thing I needed to do is add applicationName="/" in my provider configuration, in the app.config. (which is the application name, can be found inside the aspnet_Applications table in the DB.

<configuration>

  <connectionStrings>
    <add
        name="MyConnectionString"
        connectionString="Data Source=...;Initial Catalog=...;User ID=...;Password=..."
        providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <profile
      enabled="true"
      defaultProvider="Sql2008ProfileProvider">
      <properties>
        <add name="UserLevel" type="integer"/>
        <add name="value1" type="string" />
        <add name="value2" type="string"  />
        <add name="value3" type="string" />
        <add name="value4" type="string"/>
      </properties>

      <providers>
        <clear/>
        <add
            name="Sql2008ProfileProvider"
            type="System.Web.Profile.SqlProfileProvider"
            connectionStringName="MyConnectionString"
            applicationName="/"
            />
      </providers>

    </profile>
  </system.web>

</configuration>
Shimrod