Microsoft KB Archive/293293

= PRB: Cannot Update Source Code Control Status From ProjectHook.Init =

Article ID: 293293

Article Last Modified on 4/24/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q293293



SYMPTOMS
When you try to update files that are under Source Code Control (that is, Visual SourceSafe) from the ProjectHook's Init event, the Source Code Control methods that are associated with the File objects fail.



CAUSE
The Visual FoxPro (VFP) documentation states, &quot;Note that the project object and its properties and methods are not available in the ProjectHook object Init event.&quot; Because the project object logs on to the Source Code Control database, any attempt to operate on the files at this time fails.



RESOLUTION
Use a different method to operate on the files, For example, set a flag so that the first operation on any file causes the latest version of all the files to be brought down to the working folder.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Create a Project Hook class in the class designer.  Add the following code to the Init event: This.oProject = _VFP.ActiveProject WAIT WINDOW NOWAIT &quot;Project Hook Enabled&quot; This.GetLatestAll   Create a class method called GetLatestAll, and add the following code to it: LOCAL oFile, m.i

FOR m.i = 1 TO This.oProject.Files.Count oFile = This.oProject.Files[m.i]  ? oFile.Name ? oFile.SCCStatus IF NOT oFile.SCCStatus = 0   && SCCFILE_NOTCONTROLLED ? oFile.GetLatestVersion ENDif ENDfor && each file   Add the following code to the class's Destroy event: This.oProject = NULL  Save the class, and add it to a project that is under Source Control.</li> Open the project, and note that although each file and its SCCStatus are listed, each call to GetLatestVersion fails.</li></ol>

<div class="references_section">