Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to Create Code for Profile Refresh in Visual C# .NET


View products that this article applies to.

Summary

When you create a new Commerce Server Microsoft ASP.NET Web application in Microsoft Visual C# .NET by using Microsoft Visual Studio .NET, the code that is generated does not contain all the code that is required for profile refresh to function correctly. Also, the documentation does not contain the information that you must have to write this code.

↑ Back to the top


More information

In the source code of the RefreshApp.aspx (RefreshApp.aspx.cs) file, the code that is generated causes a profile refresh to fail. The following is the default code:
private void ProfileRefresh()
{
		// Implement Profile Service Refresh here
		// Please see the Profile Service documentation for more information on
		// implementing a refresh of the Profile Service

		// This will cause "Publish failed" to appear in the Business Desk application status
		throw new Exception("Publish failed");
}
If you use the default profile system, you can replace the default code with the following code to provide valid profile refresh functionality. To do this, follow these steps:
  1. Add the following references to the code:
    	using Microsoft.CommerceServer.Runtime;
    	using Microsoft.CommerceServer.Runtime.Profiles;
  2. Replace the existing code with the following sample code:
    private void ProfileRefresh()
    {
    	ProfileContext profContext = CommerceContext.Current.ProfileSystem;
    	string bdaoConnectionString;
    	string providerConnectionString;
    	string profilesConnectionString;
    	bdaoConnectionString = (string)CommerceApplicationModule.Resources["Biz Data Service"]["s_BizDataStoreConnectionString"].ToString();
    	providerConnectionString = (string)CommerceApplicationModule.Resources["Biz Data Service"]["s_CommerceProviderConnectionString"].ToString();
    	profilesConnectionString = (string)CommerceApplicationModule.Resources["Biz Data Service"]["s_ProfileServiceConnectionString"].ToString();
    	profContext = new ProfileContext(profilesConnectionString, providerConnectionString, bdaoConnectionString, CommerceContext.Current.DebugContext);
    	CommerceProfileModule.ProfileContext = profContext;
    }

↑ Back to the top


Keywords: KB815700, kbhowto

↑ Back to the top

Article Info
Article ID : 815700
Revision : 3
Created on : 9/2/2003
Published on : 9/2/2003
Exists online : False
Views : 345