Microsoft KB Archive/815700

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

Article ID: 815700

Article Last Modified on 9/2/2003

-

APPLIES TO


 * Microsoft Commerce Server 2002 Standard Edition

-





For a Microsoft Visual Basic .NET version of this article, see 816081.



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.



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 &quot;Publish failed&quot; to appear in the Business Desk application status throw new Exception(&quot;Publish failed&quot;); } 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:   Add the following references to the code: using Microsoft.CommerceServer.Runtime; using Microsoft.CommerceServer.Runtime.Profiles;   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[&quot;Biz Data Service&quot;][&quot;s_BizDataStoreConnectionString&quot;].ToString; providerConnectionString = (string)CommerceApplicationModule.Resources[&quot;Biz Data Service&quot;][&quot;s_CommerceProviderConnectionString&quot;].ToString; profilesConnectionString = (string)CommerceApplicationModule.Resources[&quot;Biz Data Service&quot;][&quot;s_ProfileServiceConnectionString&quot;].ToString; profContext = new ProfileContext(profilesConnectionString, providerConnectionString, bdaoConnectionString, CommerceContext.Current.DebugContext); CommerceProfileModule.ProfileContext = profContext; } 

Keywords: kbhowto KB815700

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.