in

ASP.NET Weblogs

Joe Wrobel

Web Profile Builder for Web Application Projects

Files can be downloaded from the Web Profile Builder project page.

If you use Web Application Projects, you have probably run into the issue of not being
able to access the Profile at design time.

Thankfully, some nice people created an Add-In for Visual Studio 2005 that will generate
a wrapper class as a workaround.  That project can be found here.  I wanted to contribute
to the Web Profile Generator project, but my emails went unanswered.  I decided to start
a new project.

This project picks up where that one left off and is based on their source code.  I started
out rebuilding that project as it stood to add support for Visual Studio 2008.  I got it to
work, but I wanted to do more. 

I decided to go ahead and address the issues listed on the original project site.

Here is a summary of the changes made.

  • First of all, this is no longer an Add-In.  Instead, it is a Build Task.
  • Works for Visual Studio 2005 and 2008.
  • Added ability to set the file name.
  • Added ability to set the directory the file gets created in.
  • Added ability to set the class name.
  • Added ability to set the name space.
  • Added an extra method as requested here.

Usage:

  1. Run the installer.
  2. Add this Import statement to your project file.  (see special notes below)
    <Import Project="$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets" />
  3. Done.

The profile will get generated every time you build the project.

Special Notes:

After you modify the project file by adding the import statement, you will get this security
warning when the project loads.  Choose the "Load project normally" option and press OK.
image 

Extended Usage:

If you want to customize the web profile, you can add the following sections to your web.config.

This section needs to be at the top of the file just under the opening configuration tag.
<configSections>
   
<sectionGroup name="robo.webProfile">
       
<section name="webProfileSettings"
         
type="WebProfileBuilder.WebProfileConfigurationSection, WebProfileBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01d50f1f82943b0c"
         
allowLocation="true"
         
allowDefinition="Everywhere"/>
   
</sectionGroup>
</configSections>

This section can be anywhere under the configuration section.
<robo.webProfile>
   
<webProfileSettings className="MyWebProfile"
                       
nameSpace="CustomNameSpace" 
                       
directory="CodeFiles"
                       
fileName="MyWebProfile" />
</robo.webProfile>

The directory name is not a virtual directory, but is in reference to the root of the Web Application.
The fileName is just the name of the file and should not include an extension.
The className and nameSpace are as you would expect.
None of these settings are required.  You don't even need to define this section at all.

If you would like to use Web Profile Builder, it can be downloaded here.
Also available is the complete source code and examples in VB and C#.

Thanks
-Joe

Comments

 

Joe said:

Thanks man!

Works like a charm!

February 22, 2008 8:42 AM
 

Chris said:

Why does this require .NET 3.5 to install under studio 2005?

February 27, 2008 12:08 PM
 

Kevin Isom said:

So, I'm working on a Web Application Project in Visual Studio 2008 and I realize I don't have a strongly

February 27, 2008 3:05 PM
 

robolize said:

Chris,

Good question.  I didn’t intend for .NET 3.5 to be required.

I built this using Visual Studio 2008.  I must have inadvertently made a reference to the 3.5 framework.  I will post an update to fix this in the next few days.

Thanks
-Joe

February 27, 2008 4:10 PM
 

robolize said:

I just updated the installer and source files.  WebProfileBuilder now only requires .NET 2.0

Thanks
-Joe

February 27, 2008 8:53 PM
 

GrZeCh said:

Hello!

Thanks for this project. But how can I update profiles other users than current (for example after registration set some default values)?

Thanks in advance

February 28, 2008 8:42 AM
 

robolize said:

GrZeCh,

Sorry, I don't understand your question.

February 28, 2008 2:07 PM
 

GrZeCh said:

Sorry .. I'm always bad at describing my problems :)

Lets say I'm administrator of some page and I want to change on field in my users profile (City for example). How can I do this from codebehind?

WebProfile.Current.GetProfile("User").City = "New city";

something like this should work?

February 28, 2008 2:24 PM
 

GrZeCh said:

ok .. I found solution for my problem.

           var user = new WebProfile().GetProfile("User");

           user.City = "New city";

           user.Save();

thanks again for this profile builder

February 28, 2008 3:15 PM
 

Kalle said:

when using source control, it's quite annoying to have to keep WebProfile.cs checked out at all times or to check it out every time before compile. Is there a workaround for this?

February 29, 2008 3:52 PM
 

robolize said:

Kalle,

I bet that it annoying.  I use a source control model that doesn’t require files to be checked out so this is something I didn’t think of.  I am planning to make an update that will address this issue.  Thanks for your feedback.

-Joe

March 1, 2008 10:03 AM
 

stevienova.com » Blog Archive » Visual Studio 2005/2008 Web Application Projects: Profile Class Auto Generation Workaround said:

Pingback from  stevienova.com  &raquo; Blog Archive   &raquo; Visual Studio 2005/2008 Web Application Projects: Profile Class Auto Generation Workaround

March 1, 2008 9:39 PM
 

Martin said:

I'm surprised Microsoft didn't fix this in VS2008. Anyway, thanks for coding this up. I've got it working in my web app but I have one  big problem....

This appears to break debugging functionality. Whenever I hit a breakpoint and try to continue I get the error:

"Edits were made to the code which cannot be applied while debugging"

I assume this was because the WebProfile file is getting autogenerated everytime. Do you have a workaround?

Thanks!!

March 6, 2008 2:55 PM
 

robolize said:

Martin,
Another good point.  I will address this in the next update.  Basically, I will identify if changes were made to the profile section in the web.config and only regenerate the profile class if there were changes.  I’m crazy busy with my real job right now, but I plan to have this update out in the next few weeks.  
Thanks for your feedback and patients.

-Joe

March 7, 2008 12:35 PM
 

Ben said:

FYI - I update the source on the copy I download to only attempt to overwrite the source file when the source file is writable.

private void SaveWebProfile(string code)

       {

           // Write the code to disk

           string fullName = Path.Combine(ProfileDirectory, ProfileFileName);

           bool isReadOnly;

           isReadOnly = new FileInfo(fullName).IsReadOnly;

           if (!isReadOnly)

           {

               using (StreamWriter sw = File.CreateText(fullName))

               {

                   sw.Write(code);

               }

           }

       }

March 7, 2008 2:43 PM
 

robolize said:

Ah, very nice.  I’ll incorporate this into the next release.

Thanks Ben.

March 7, 2008 3:18 PM
 

effpath said:

Really great! I'm developing my first projects in asp.net and I lost some hours before discovering that web applications don't have access to strong typed profile's properties. I was resigning myself to writing a boring wrapper for the ProfileBase when I found your work... Thank you!

March 10, 2008 8:23 PM
 

Dude said:

Thanks.

March 23, 2008 4:31 AM
 

auge said:

Cool Tool,

First it didnt't work for me until I found out that this was because I had set the namespace in the <configuration>-Element of my web.config File.

e.g. <configuration  xmlns="schemas.microsoft.com/.../v2.0">

Now it works great, thx

March 23, 2008 1:43 PM
 

Steele said:

Thanks for filling in an important hole, this was making me crazy trying to understand the difference after converting from a WebSite Project.

Why does this REQUIRE a RootNamespace

Frequently in VB I leave it blank.

Perhaps, this is bad form, but there are many valid reasons to do so in VB.Net.

March 28, 2008 5:38 AM
 

Jason said:

I'm fairly new to the .NET framework, and I'm having a hard time with step 2 in your install instructions.

Under my project, there is a project file called "My Project", but it is not an XML-formatted file.  It has a GUI menu with options that include "references", etc. and I don't understand where to put the <import project /> line to include into the project.  

Using this will help me greatly in dealing with my user profiles on the back-end and I am anxious to getting it working, but I am stuck.

April 3, 2008 6:36 PM
 

Web Profile Builder for Web Application Projects - Joe Wrobel « vincenthome’s Software Development said:

Pingback from  Web Profile Builder for Web Application Projects - Joe Wrobel &laquo; vincenthome&#8217;s Software Development

April 5, 2008 10:52 PM
 

Arino said:

Unfortunately did not work in VS2005 although I followed all the instructions...

April 6, 2008 10:39 AM
 

Gary Davis said:

I installed the setup file, inserted the statement into the csproj file, loaded the project and this error displayed:

Warning 1 The "BuildWebProfile" task failed unexpectedly.

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

  at WebProfileBuilder.Builder.LoadProfileFromWebConfig(String path)

  at WebProfileBuilder.Builder.GenerateWebProfile(BuildWebProfile buildWebProfile)

  at WebProfileBuilder.BuildWebProfile.Execute()

  at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) theStore24

Most of my references are now marked with the yellow yield icon. Attempting build of the solution then adds these warnings:

Warning 2 The referenced component 'AjaxPro.2' could not be found.

Warning 3 The referenced component 'CMPCDotNet' could not be found.

Warning 4 The referenced component 'ICSharpCode.SharpZipLib' could not be found.

  :

  :

Removing the statement from the csproj file fixes everytlhing.

This is using the 1.1.0.0 release with VS2008 on Win Server 2003 SP2.

Any ideas on this?

April 11, 2008 10:30 AM
 

marco said:

i have the same problem !

April 15, 2008 6:44 AM
 

Joe Wrobel said:

Files can be downloaded from the Web Profile Builder project page. If you are unfamiliar with Web Profile

April 17, 2008 12:16 AM
 

Scenes From A Developer Memory said:

Σήμερα, μετά από πολύ καιρό, προσπάθησα να βάλω χρησιμοποιήσω τον SqlProfileProvider στο Visual Studio

April 23, 2008 11:49 AM
 

Stacy said:

"This property cannot be set for anonymous users"

I get this error when accesing a property during signup in the CreateUserWizard1_CreatedUser method. My code is:

// Create an empty Profile for the newly created user

MyWebProfile p = new MyWebProfile();

p.GetProfile(CreateUserWizard1.UserName, true);

p.FirstName = "Bob";

webProfileSettings tag in config correctly generates the MyWebProfile  class with all my properties.

In my previous website project, I used this code that works fine:

ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);

p.FirstName = "Bob";

Can someone please help me with this convert to WAP?

I thought GetProfile created a new user profile like ProfileCommon.Create, but I get the error above.

April 26, 2008 2:39 AM
 

Stacy said:

I switched to ver 1.2 and the problem went away.

I used the new static method to create a new profile:

MyWebProfile p = MyWebProfile.GetProfile(CreateUserWizard1.UserName, true);

April 28, 2008 12:42 PM
 

pshaffer said:

Liked the tool very much.  However, there is a bug in v1.2.

When you optimized the WebProfile.Current property, you made it into a singleton.  This means that the first user profile accessed via this property is now used by every request until the workspace is recycled in IIS.  I've entered a bug issue on it.

Great work on the whole thing.  We all appreciate it very much.

May 1, 2008 5:16 PM
 

emanlee said:

WebProfileBuilderforWebApplicationProjects FilescanbedownloadedfromtheWebProfileBu...

May 12, 2008 1:15 AM
 

simon said:

I get the following error when i try to build

Error 1 The "BuildWebProfile" task failed unexpectedly.

System.ArgumentNullException: String reference not set to an instance of a String.

Parameter name: s

  at System.Text.Encoding.GetBytes(String s)

  at WebProfileBuilder.Builder.IsProfileSame()

  at WebProfileBuilder.Builder.GenerateWebProfile(BuildWebProfile buildWebProfile)

  at WebProfileBuilder.BuildWebProfile.Execute()

  at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) Web

Cheers,

Simon

May 15, 2008 12:20 PM
 

Valentin said:

Hi,

I got the same error

Thanks,

Val

May 16, 2008 2:17 PM
 

Web Profile Builder for Web Application Projects - Joe Wrobel « Sami’s Weblog said:

Pingback from  Web Profile Builder for Web Application Projects - Joe Wrobel &laquo; Sami&#8217;s Weblog

May 19, 2008 9:20 AM
 

Kurt said:

This rocks!  Thanks a ton!

May 27, 2008 5:38 PM
 

Tony said:

Simon,

You error is generally casued by the profile section not being declared with in the web.config.

I get the following error when i try to build

Error 1 The "BuildWebProfile" task failed unexpectedly.

System.ArgumentNullException: String reference not set to an instance of a String.

Parameter name: s

 at System.Text.Encoding.GetBytes(String s)

 at WebProfileBuilder.Builder.IsProfileSame()

 at WebProfileBuilder.Builder.GenerateWebProfile(BuildWebProfile buildWebProfile)

 at WebProfileBuilder.BuildWebProfile.Execute()

 at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) Web

Cheers,

Simon

May 28, 2008 10:09 AM
 

Vanja said:

Hey,

Great tool! Took me some time to finally get it working with my system but its runs really well now.

Only qualm I have with this is that it sometimes fails silently - build will succeed but the profile won't be regenerated. This happened to me when I had a "serializeas" tag in one of my profile parameters (instead of "serializeAs").

Thanks again for the great tool!

Vanja.

Ps. It would be incredibly useful if you could add support for nested type specifiers though. For some reason the code generator does not like something like "List`1[ KeyValuePair`2[Int, Int] ]"

July 8, 2008 10:35 PM
 

CodersBarn.com said:

ASP.NET PayPal Subscriptions IPN

July 11, 2008 12:27 AM
 

barnchick said:

I'm getting this error when I try to build my project:

Error 101 The "BuildWebProfile" task failed unexpectedly.

System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for robo.webProfile/webProfileSettings: Could not load file or assembly 'WebProfileBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01d50f1f82943b0c' or one of its dependencies. The system cannot find the file specified. (C:\Documents and Settings\angel\My Documents\Visual Studio 2008\Projects\MembershipPortal\MembershipPortal\web.config line 13) ---> System.IO.FileNotFoundException: Could not load file or assembly 'WebProfileBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01d50f1f82943b0c' or one of its dependencies. The system cannot find the file specified.

File name: 'WebProfileBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01d50f1f82943b0c'

  at System.Configuration.TypeUtil.GetTypeWithReflectionPermission(IInternalConfigHost host, String typeString, Boolean throwOnError)

  at System.Configuration.MgmtConfigurationRecord.CreateSectionFactory(FactoryRecord factoryRecord)

  at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)

WRN: Assembly binding logging is turned OFF.

To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.

Note: There is some performance penalty associated with assembly bind failure logging.

To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

  --- End of inner exception stack trace ---

  at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)

  at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)

  at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)

  at System.Configuration.Configuration.GetSection(String sectionName)

  at WebProfileBuilder.Builder.Initialize(String directory)

  at WebProfileBuilder.Builder.GenerateWebProfile(BuildWebProfile buildWebProfile)

  at WebProfileBuilder.BuildWebProfile.Execute()

  at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) MembershipPortal

July 17, 2008 2:58 PM
 

helpin out said:

I figured out the problem of when you get the rror 101 The "BuildWebProfile" task failed unexpectedly error.

You need to have this line in your web.config:

<profile configSource="ProfileSection.config"/>

And you need to have the ProfileSection.config file in your project.  You can find it in the sample application.

August 6, 2008 12:22 PM
 

wookie said:

I only just stumbled upon this problem now as I have traditionally stayed away from the Profile object in asp.net 2.0 because it is a bit "twitchy". Very nice little tool and did the job as expected first time.

August 8, 2008 2:06 PM
 

Sean Mackey said:

The Extended Usage steps above strictly use version 1.0.0.0 in the web.config markup. I only have the latest 1.3.0.0 version so the WebProfileBuilder assembly was not found in the GAC.

You should add a note to update the web.config markup to the correct version.

This is the solution to the issue barnchick posted July 17, 2008 2:58 PM.

August 11, 2008 1:58 PM
 

ReenaCutie said:

I installed vs2005, got the following error

The "Message" task could not be loaded from the assembly Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Could not load file or assembly 'Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available.

Can anybody help?

August 12, 2008 2:37 AM
 

Andy said:

I was receiving the "BuildWebProfile" task failed unexpectedly as well. The one thing I found that worked me was to make sure that in your web.config, you have the correct version referenced in your configsection. The documentation on this page is out of date. It recommends using:

<section name="webProfileSettings"

   type="WebProfileBuilder.WebProfileConfigurationSection, WebProfileBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01d50f1f82943b0c"

         allowLocation="true"

         allowDefinition="Everywhere"/>

That "Version=1.0.0.0" is the problem. Change that to "Version=1.3.0.0". Doing this solved the problem for me.

August 27, 2008 9:54 AM
 

Matt said:

I am unable to save the profile information.  It says it saves but it never shows up in the DB.

Membership.CreateUser(this.txtUserName.Text, this.txtPassword.Text, this.txtEmail.Text);

               setMessage("User added", false);

               //Profile prof = .Create(this.txtUserName.Text);

               MyWebProfile p = MyWebProfile.GetProfile(this.txtUserName.Text,true);

               p.ClientID = ddlClients.SelectedValue;

               p.Save();

September 2, 2008 2:54 PM
 

Matt said:

Everything appears to be correct.  The database connection is correct and the class is being generated properly.  There are no compile time errors and no run time errors.  The record is just not being written.

Could this be related to Ajax?

September 2, 2008 3:42 PM
 

Matt said:

I removed all Ajax code so that is not causing the problem.

September 2, 2008 3:48 PM
 

Orion said:

Thx, works fine.

September 4, 2008 7:39 AM
 

Krisztian said:

Hi Matt!

Did you solve your problem? I have the same.

Thanks, Krisztian

September 9, 2008 10:51 AM
 

Around and About .NET World said:

Impossibile accedere all'oggetto Profile da una Web Application

September 30, 2008 5:12 PM
 

Steve said:

I was using the old addin for VS2005 - thank god you've done something for VS2008 as I use the Membership API a lot and in particular user profiles. Nice one matey.

October 5, 2008 11:54 AM
 

Sreeni said:

Added the Import tag to project file. i am using to build a FBA user management  with some custom properties. any help of how to use?

October 10, 2008 1:21 PM
 

Around and About .NET World said:

Attraverso l&#39;oggetto Profile di ASP .NET è possibile gestire con estrema facilità una serie di informazioni

October 20, 2008 11:19 AM
 

C said:

I don't have a csproj file for my web app, presumably because it's from HTTP rather than filesystem.

October 30, 2008 8:30 AM
 

Ruben said:

Awesome!  Had it up and running in a custom directory and namespace in 5 minutes.  Thanks!

December 4, 2008 10:51 AM
 

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

December 11, 2008 10:49 PM
 

apostle said:

getting this message. everything builds fine.

Could not find schema information for the element 'robo.webProfile'.

any ideas?

December 23, 2008 12:31 AM
 

Luiz Antonio - Brasil said:

How do I save, I do not think that the class ProfileCommon as I save this method since error happens on the line and marked as I solve this error

I'm using VS2005 Pro Edition and WebProfileBuilder 1.3.0.0

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using CustomNameSpace;

using System.Web.Profile;

namespace MeuWebProfile

{

   public partial class Novo : System.Web.UI.Page

   {

       protected void Page_Load(object sender, EventArgs e)

       {

       }

       protected void CreateUserWizard1_ContinueButtonClick(object sender, EventArgs e)

       {

           //Pesquisa/Recupera dados dos IDs de Controles do CreateUserWizard

           CheckBox chk = (CheckBox)CreateUserWizard1.FindControl("chkCrianca");

           TextBox txtTel = (TextBox)CreateUserWizard1.FindControl("txtTel");

           TextBox txtEnd = (TextBox)CreateUserWizard1.FindControl("txtEnd");

           //Cria o Profile baseado na Class MyWebProfile do WebProfileBuilder

           MyWebProfile prof = MyWebProfile.Create(CreateUserWizard1.UserName);//The error appears in this line

           //Repassa os dados inseridos nos controles

           //para as propriedades(campos) dos perfis

           //do profile criado

           prof.Crianca = chk.Checked;

           prof.Endereco = txtEnd.Text;

           prof.Telefone = txtTel.Text;

           //chama o método Save para salvar

           //os perfis de meu usuário na Base

           //AspNetDb ou do ProfileProvider criada

           prof.Save();

       }

       public static MyWebProfile Profile

       {

           //get { return new MyWebProfile(HttpContext.Current.Profile); }

           get { return MyWebProfile.Current; }

       }

   }

}

December 29, 2008 2:12 PM
 

grrrrrrr said:

How do you get this to work with the default profile or do you HAVE to create a custom profile class and then define every property in the class? I followed all the instructions and am still getting "[Property] is not a member of 'Profile'" errors every time I access my profile. It would really suck if I have to go and make a whole new class that defines all of my properties (again - they are in the web.config file). Please advise.

Thanks!

January 2, 2009 11:33 AM
 

LockTar said:

@grrrrr

Make sure that your build is succeeded. So don't use the properties yet when you create them in you web.config. First build your project. Then go to your solution explorer and refresh it. Set the function for hidden files on. You see now a new class in your project. right mouse click and include him into your project. Now build again and your properties are available.

One other problem that i found: when you are using Team foundation server and you add a propertie in your web.config. make sure that your profle class and web.config are checkt out. otherwise the propertie won't be build.

Now I have a problem. I'm working @home now. so i made a VPN connection to my work. get al the files from team foundation and try to build. I now get the error "the webprofiletask can not be loaded from assembly. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available.". anybody a suggestion???

January 12, 2009 3:07 AM
 

Mehdi said:

Hi,

Thanks , I using your solution it . but I have a problem.

I put profile update on sign up page and will update profile every time user loggined.

The problem is profile information just after 2 times update, can be used on other page( after first login , all profile information was empty and when I re-try and login again profiles retun correct value) what is wrong?

Thanks

January 17, 2009 1:25 AM
 

Blog de José Manuel Alarcón Aguín en Geeks.ms (alternativo a www.JASoft.org) said:

Como seguramente sabrás, con la aparición de Visual Studio 2005 el modelo de troyectos Web cambió completamente

January 18, 2009 3:26 PM
 

Mark Jones said:

Hey there

Excellent work! Got it installed and working no problems. However I now have a bit of an issue trying to build.

We are using team build and we have not been able to get past this error message:

C:\Program Files\MSBuild\WebProfileBuilder\WebProfileBuilder.targets(7,3): error MSB4018: The "BuildWebProfile" task failed unexpectedly.

System.UnauthorizedAccessException: Access to the path 'F:\builddir\web_dev\Nightly_Build\Sources\main\synseal_co_uk\WebProfileBuilder.user' is denied.

  at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

  at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)

  at System.IO.FileStream..ctor(String path, FileMode mode)

  at WebProfileBuilder.Builder.IsProfileSame()

  at WebProfileBuilder.Builder.GenerateWebProfile(BuildWebProfile buildWebProfile)

  at WebProfileBuilder.BuildWebProfile.Execute()

  at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)

The solution builds fine locally (so long as I have webProfileBuilder.user checked out) but as soon as I set up a team build I get this error every time.

I am unfortunately a little new to all this and any advice would be appreciated. As far as I can see the TSService account has correct access to the file path, and the path is not long and has no spaces etc.  Do I need to get the build to somehow check out the webprofilebuilder.user file?

January 22, 2009 11:40 AM
 

Luiz Antonio - Brazil (Country) said:

Hello researching and testing the blog via WebProfileGenerator1.3 by Visual Studio 2005 and below could save the custom profile

protected void CreateUserWizard1_ContinueButtonClick(object sender, EventArgs e)

       {

           //Pesquisa/Recupera dados dos IDs de Controles do CreateUserWizard

           CheckBox chk = (CheckBox)CreateUserWizard1.FindControl("chkCrianca");

           TextBox txtTel = (TextBox)CreateUserWizard1.FindControl("txtTel");

           TextBox txtEnd = (TextBox)CreateUserWizard1.FindControl("txtEnd");

           //Cria o Profile baseado na Class MyWebProfile do WebProfileGenerator3.1

           string username;

           username = CreateUserWizard1.UserName;

           //Maneira Errada com o WebProfileGenerator

           //WebProfile prof = WebProfile.Create(username);

           //Maneira Correta com o WebProfile Generator

           WebProfile prof = new WebProfile().GetProfile(username);

           //Repassa os dados inseridos nos controles

           //para as propriedades(campos) dos perfis

           //do profile criado

           prof.Crianca = chk.Checked;

           prof.Endereco = txtEnd.Text;

           prof.Telefone = txtTel.Text;

           //chama o método Save para salvar

           //os perfis de meu usuário na Base

           //AspNetDb ou do ProfileProvider criada

           prof.Save();

       }

       private WebProfile Profile

       {

           get { return new WebProfile(Context.Profile); }

       }

but as I understand it by WebProfileGenerator can only be used in VisualStudio2005 and not in VisualStudio2008, how it would be the same code or using the above action with the webprofilebuilder 1.3.0.0 that at least in reading is recognized in Visual Studio but the rescue the profiles do not yet have not found the method. getprofile as in the example above using the WebProfileGenerator above, as I could finally reap the same result but the above code with the WebProfileBuilder 1.3.0.0 what I have to add or modify the code to be accepted the rescue

I look at now and I thank

Translated from Portuguese into English by Google

January 23, 2009 4:42 PM
 

Mark Jones said:

For anyone else having trouble with Team Build try this:

<Target Name="BeforeCompile">

   <Exec WorkingDirectory="$(SolutionRoot)" Command="$(TF) checkout  /noprompt $(BuildProjectFolderPath)/../../<project name>//WebProfileBuilder.user"/>

</Target>

<Target Name="AfterCompile">

   <Exec WorkingDirectory="$(SolutionRoot)" Command="$(TF) undo /noprompt  $(BuildProjectFolderPath)/../../<project name>/WebProfileBuilder.user"/>

</Target>

Add this to the TFSBuild.proj file in Source Control Explorer. Make sure you replace <project name> with the correct path to your project.

January 27, 2009 2:48 AM
 

ASP.NET Website vs Web Application project | TechBubbles said:

Pingback from  ASP.NET Website vs Web Application project | TechBubbles

February 13, 2009 8:58 PM
 

Katherine Labbe said:

Hi,

I'm new in Web Application and I don't seems to get it right.  I have this build error :

"BuildWebProfile" task failed unexpectedly.

System.ArgumentNullException: String reference not set to an instance of a String.

Parameter name: s

  at System.Text.Encoding.GetBytes(String s)

  at WebProfileBuilder.Builder.IsProfileSame()

  at WebProfileBuilder.Builder.GenerateWebProfile(BuildWebProfile buildWebProfile)

  at WebProfileBuilder.BuildWebProfile.Execute()

  at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) WebPO

Thanks !

March 24, 2009 11:30 AM
 

Alexander Yermakov. My life. » Blog Archive » Web Application ???????????? ?? ?????????????????????????? ?????????????? ???????????????????????? ?? ASP.NET said:

Pingback from  Alexander Yermakov. My life.  &raquo; Blog Archive   &raquo; Web Application ???????????? ?? ?????????????????????????? ?????????????? ???????????????????????? ?? ASP.NET

April 1, 2009 11:38 AM
 

Jason said:

For those of you having trouble with Mark's team build directions, you will need to add:

<TF>&quot;$(TeamBuildRefPath)\..\tf.exe&quot;</TF>

to your PropertyGroup so that it can evaluate $(TF) properly.

April 16, 2009 11:30 AM
 

Jason said:

Another thing for people using Team Build.

I found that doing a local build became a problem when the WebProfileBuilder.user file was locked due to it being under source control. I would get an error saying that the BuildWebProfile task could not access the file.

I fixed this by adding

<Exec Command="attrib -r &quot;$(ProjectDir)\WebProfileBuilder.user&quot;"/> before the <BuildWebProfile> node in Program Files/MSBuild/WebProfileBuilder/WebProfileBuilder.targets.

I also added <Exec Command="attrib +r &quot;$(ProjectDir)\WebProfileBuilder.user&quot;"/> after the BuildWebProfile node to set the file to readonly again.

I found that before I fixed this my project could not resolve any references also. So if you have that problem this may help you.

April 16, 2009 12:10 PM
 

Nuno said:

Everything works fine when testing in VS.net 2005 web server but when I deploy it to IIS 5.1 the data doesn't get saved and no errors occur. I checked the event view and don't see anything there either.

Nuno

April 16, 2009 9:54 PM
 

Matt said:

You need to give an example of your explaination.

This is not good when all these people leave comments.

It is poor, sadly to say.

April 18, 2009 4:34 PM
 

Cord Thomas said:

This is very helpful.  I also had the IO.FileSystem error and it was the version number.  Great resource.

April 19, 2009 12:38 AM
 

nunop said:

I have this at the top of my page:

   private WebProfile Profile

       {

           get { return new WebProfile(Context.Profile); }

       }

and in the ItemCommand event of my gridview I have a switch statement with this:

          case "AddToCart":

                   {

                       ShoppingCartItem newItem = DataLayer.GetProducts(Convert.ToInt32(e.CommandArgument));

                       Profile.ShoppingCart.AddItem(newItem);

                       break;

                   }

The cart saved succesfully when debugging in VS.net 2005 Web Server but when deployed to IIS the items don't get saved.

April 21, 2009 1:58 PM
 

Sayitfast said:

This is great!  Worked like a charm... The examples on the download page were very helpful.

May 1, 2009 1:12 AM
 

James said:

Got a problem.  HttpContext.Current.Profile is not being set by Login.aspx (asp:Login) with a valid user.  Remains the anonymous initial setting with the UserName as a guid.

Got any ideas?

May 12, 2009 10:31 PM
 

The Rafael Van Dyke Blog said:

How To Get to the Profile Object in an ASP.NET Web Application

June 1, 2009 2:05 PM
 

W Khattak said:

Hi,

Quite useful if using default provider. Just wanted to know if it works with custom providers or not?

thanks,

June 17, 2009 5:41 AM
 

Alex P. said:

Anyone else having problems getting this going make sure that version is 1.3.0.0 in the config section, as opposed to 1.0.0.0 as in the example here.

June 17, 2009 2:16 PM
 

Richard said:

"1.3.0.0"

Fantastic!!

Thank you so much!

Everything works fine with PostgreSQL provider!!

July 13, 2009 5:26 PM
 

Stylesie said:

You Saved my bacon dude.

I cannot believe that Microsoft did not fix this bug with VS 2008.

Thanks for keeping the project alive.

July 17, 2009 11:23 AM
 

symacord said:

Wow! after many weeks of struggle, I finally found solution.

Thanks Joe.

July 22, 2009 9:27 AM
 

Type or NameSpace name ‘ ProfileCommon’ Could not found « dewaTeam said:

Pingback from  Type or NameSpace name &#8216; ProfileCommon&#8217; Could not found &laquo;  dewaTeam

July 23, 2009 9:38 PM
 

sonna said:

I have error:

Error 1 The "BuildWebProfile" task failed unexpectedly.

System.ArgumentNullException: String reference not set to an instance of a String.

Parameter name: s

  at System.Text.Encoding.GetBytes(String s)

  at WebProfileBuilder.Builder.IsProfileSame()

  at WebProfileBuilder.Builder.GenerateWebProfile(BuildWebProfile buildWebProfile)

  at WebProfileBuilder.BuildWebProfile.Execute()

  at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) DTech.BussinessLogic

August 4, 2009 10:06 PM
 

max said:

Hi, can I modify my project file (.csproj), if no .csproj being generated by asp.net web application??

thanx in advance

August 23, 2009 7:20 AM
 

techron said:

Thanks man. Pingback with my own instructions on my first try with this. Take a look max, I tried to explain that the csproj file may have its extension hidden. And just in case there was a misunderstanding, this is with a Web Application Project.

August 25, 2009 9:43 PM
 

livercool said:

Brillant stuff mate :)

September 8, 2009 1:08 PM
 

Mike said:

Good one. I had to use the config settings for it to work with ASP.Net mvc but it works great.

September 8, 2009 2:03 PM
 

Arley said:

Does this work with Visual WebGUI projects? I have tried it but not class is generated on the build.

September 11, 2009 8:26 PM
 

Keith said:

Awesome tool.  The only thing you might want to mention is that the WebProfile class file is generated into the root of the project by default, and that you will need to add the file into your project.  This may have been obvious, but I thought I would mention it.

September 21, 2009 12:36 PM
 

Jaco said:

Awesome tool. One problem. I have set up everything and it works well via vs2008 ide. But as soon as i publish to iis i get the folowing error.

The settings property 'ShoppingCart' was not found.

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.Configuration.SettingsPropertyNotFoundException: The settings property 'ShoppingCart' was not found.

Source Error:

Line 127:        

Line 128:        public virtual object GetPropertyValue(string propertyName) {

Line 129:            return this._profileBase.GetPropertyValue(propertyName);

Line 130:        }

Line 131:        

Source File: D:\Development\Work\IconManiacs\IconManiacs\IconManiacs\WebProfile.cs    Line: 129

It works fine via the IDE

October 14, 2009 7:05 AM
 

Camcorder Reviews said:

Really annoying that Microsoft did not fix this themselves, but thanks for an awesome tool, it cost me several extra hours unfortunately.

December 14, 2009 10:15 AM
 

.NET Type or NameSpace name ??? ProfileCommon??? Could not found | dewaMedia said:

Pingback from  .NET Type or NameSpace name ??? ProfileCommon??? Could not found | dewaMedia

December 24, 2009 11:17 PM
 

Stieven said:

Where to put the line mentioned in step2:

<Import Project="$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets" />

In what file? web.config?

Thx!!

December 30, 2009 10:56 AM
 

Raul Juarez said:

I was able to create a user, recover password by email, and login. I would like to integrate this with my application basically I would like to be able to retrive UserID and use into my other aspx pages, wouls some one point me to the right direccion.?

Thanks

January 11, 2010 1:59 PM
 

Dot Net World » Web Profile in Visual Studio Web Projects said:

Pingback from  Dot Net World &raquo; Web Profile in Visual Studio Web Projects

February 3, 2010 11:38 PM

Leave a Comment

(required)  
(optional)
(required)  
Add