Microsoft KB Archive/310901

= HOW TO: Use a Project Hook to Recycle IIS So VFP COM DLL Can Be Rebuilt =

Article ID: 310901

Article Last Modified on 6/29/2004

-

APPLIES TO

 Microsoft Visual FoxPro 6.0 Professional Edition Microsoft Visual FoxPro 7.0 Professional Edition Microsoft Internet Information Server 4.0, when used with:  Microsoft Windows NT 4.0

 Microsoft Windows 2000 Standard Edition  Microsoft Internet Information Services 5.0, when used with:  Microsoft Windows NT 4.0</li></ul>

 Microsoft Windows 2000 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q310901

<div class="notice_section">

IN THIS TASK
SUMMARY
 * Use a Project Hook to Recycle IIS So That VFP COM DLL Can Be Rebuilt

REFERENCES

<div class="summary_section">

SUMMARY
This step-by-step article demonstrates how to release a Visual FoxPro (VFP) COM DLL that is in use by Microsoft Internet Information Server (IIS) so that it may be rebuilt.

By default, IIS does not immediately free dynamic-link libraries (DLLs) after it is finished with them. This provides the benefit of increased performance because the libraries are not read from disk with each request. The libraries are eventually freed, but if you are in the process of developing a VFP DLL for use with IIS, you will probably not want to wait to overwrite it. To avoid this problem, it is possible to cycle IIS from VFP (thereby freeing your COM DLL) when you rebuild your VFP project.

Visual FoxPro 6.0 and 7.0 include the ability to execute code from the Project Manager by using a project hook. Specifically, you can use the BeforeBuild event to execute code that will cycle the IIS service on the local (development) computer, thereby freeing any used DLLs and allowing them to be overwritten.

back to the top

Use a Project Hook to Recycle IIS So That VFP COM DLL Can Be Rebuilt
<ol> Open Visual FoxPro 6.0 or 7.0.</li> On the File menu, click New, and then click Class.</li> Fill in the New Class dialog as follows:

Class name: IISDLL_HOOK

Based on: ProjectHook

Store in: \IISDLL_HOOK.VCX (where Path is a directory path of your choosing on your local computer)

</li> In the Class Designer, double-click the class to open the code window, and then select BeforeBuild from the procedure drop-down box.</li>  Paste the following code in the code window below the &quot;PARAMETERS...&quot; statement.

NOTE: This code relies on IIS being installed on the same computer as Visual FoxPro. The code will not work with Microsoft Personal Web Server. If you are using Windows 2000 or later, make sure that the Windows\System32 directory is in the system path. To check this, run IISRESET from a command prompt; if it runs successfully, the following project hook code will work as well. LPARAMETERS cOutputName, nBuildAction, lRebuildAll, lShowErrors, lBuildNewGuids
 * AUTHOR:   Trevor Hancock (trevorh@Microsoft.com)
 * CREATED:  Thursday, Oct. 18, 2001
 * ABSTRACT: This code will cycle IIS on the LOCAL machine running
 * Windows NT, Windows 2000, XP or .NET Server,
 * thereby freeing any used VFP COM DLLs allowing
 * them to be rebuilt. This code does NOT work with
 * Microsoft Personal Web Server.
 * 1) DEFINE MB_YESNO                4   && Yes and No buttons
 * 2) DEFINE MB_ICONQUESTION   32   && Warning query
 * 3) DEFINE IDYES                      6   && Yes button pressed
 * 1) DEFINE MB_ICONQUESTION   32   && Warning query
 * 2) DEFINE IDYES                      6   && Yes button pressed

LOCAL lnCycleAnswer AS INTEGER lnCycleAnswer = MESSAGEBOX(  &quot;Would you like cycle IIS before building?&quot;, ;    MB_YESNO + MB_ICONQUESTION, &quot;Cycle Web Server?&quot;) IF lnCycleAnswer # IDYES RETURN .F. ENDIF
 * !* Ask developer if Web server should be cycled.
 * !* Exit: they answered &quot;No&quot;.

WAIT WINDOW &quot;Resetting IIS to free used DLL(s)...&quot; NOWAIT NOCLEAR

IF (&quot;5.01&quot; $ OS) OR (&quot;5.00&quot; $ OS) &&W2K or WXP/.NET RUN IISRESET ELSE RUN NET STOP IISADMIN /Y RUN NET START W3SVC ENDIF

WAIT CLEAR WAIT WINDOW &quot;Reset complete. Building...&quot; NOWAIT </li> Save the class and then close the Class Designer.</li></ol>

When you attach this project hook to a project, each time the project is built you will be prompted to cycle the IIS server on the local computer. If you choose to do so, any VFP COM DLLs will be freed, allowing them to be rebuilt.

back to the top

<div class="references_section">