cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
eseilram
Level 5

.Net4 Application Pool IIS7

We face a real big problem:

We upgraded our solution to .Net4
But how can I set an application pool to this version and link my application to this pool?

I'm able to run an custom action that sets my pool to .Net 4, but there's always an app pool "ASP.NET v4.0 " created and my application is linked to this pool.

After which should this CA be executed?
I'm using InstallShield 2009 Premier

I'm using
I need urgent help!

Thanks in advance
Labels (1)
0 Kudos
(2) Replies
mdbritt
Level 3

You did not say what type of IS project you are using. If you can use InstallScript in your project, here is some code that works for IIS6 and IIS7 for setting up app pools. This routine is called passing in the name of the Virtual Directory to create. It does other things as well that you can ignore if they are not important to you.

///////////////////////////////////////////////////////////////////////////////
// //
// Function: CreateVirDir //
// //
// Purpose: This function creates an IIS Virtual Directory //
// //
///////////////////////////////////////////////////////////////////////////////

function CreateVirDir(IISSite, SiteDir)
BOOL SiteExisted;
object objIIS_Root, objVirtDir, objAppPool, objIIS_WS, objSchedule;
STRING svAppPool, strMsg, svT, svHold, svCmd, svProg, svParms[500], svOut;
STRING szField1, svF1, svF2;
NUMBER svPoolStatus, nLineNum;

begin

svAppPool = "M5WebServices";

if @IFX_PRODUCT_NAME = "M5 Pages, Components and Help" then
svAppPool = "M5AppServices";
endif;

if (svIISVer = "6") then
if (SYSINFO.WINNT.bWinServer2003 = TRUE) then
set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/AppPools", "");
if (IsObject(objIIS_Root)) then
try
set objAppPool = objIIS_Root.GetObject("IISApplicationPool", svAppPool);
svPoolStatus = TRUE;
catch
set objAppPool = objIIS_Root.Create("IISApplicationPool", svAppPool);
svPoolStatus = FALSE;
objAppPool.SetInfo();
endcatch;

if (IsObject(objAppPool)) then
// In minutes
objAppPool.PeriodicRestartTime = 1740;
if svAppPool = "M5WebServices" then
// In number of events
// objAppPool.PeriodicRestartRequests = 4000;
// In bytes
// objAppPool.PeriodicRestartMemory = 512000;
// In bytes
// objAppPool.PeriodicRestartPrivateMemory = 196608;
endif;
objAppPool.SetInfo();
endif;
set objAppPool = NOTHING;
set objIIS_Root = NOTHING;
endif;
endif;

set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");
if (IsObject(objIIS_Root)) then
try
set objVirtDir = objIIS_Root.GetObject("IISWebVirtualDir", IISSite);
SiteExisted = TRUE;
catch
set objVirtDir = objIIS_Root.Create("IISWebVirtualDir", IISSite);
SiteExisted = FALSE;
endcatch;
if (IsObject(objVirtDir)) then
// Do not recreate the CrystalExports site in case the output
// for reports has been manually changed (file sharing in use
// multiple web servers.
if (IISSite = "CE_BIN" && SiteExisted) then
svLine = "Business Objects Exports Bin directory already exists. It will not be recreated.";
nResult = WriteLine(nvLogFileHandle, svLine);
elseif (IISSite = "Uploads" && SiteExisted) then
svLine = "Uploads directory already exists. It will not be recreated.";
nResult = WriteLine(nvLogFileHandle, svLine);
else
try
objVirtDir.Path = SiteDir;
objVirtDir.AccessRead = TRUE;
objVirtDir.AccessScript = TRUE;
if (SYSINFO.WINNT.bWinServer2003 = TRUE) then
objVirtDir.AspMaxRequestEntityAllowed = 10485760; //10 MB
objVirtDir.AspBufferingLimit = 5242880; //5 MB
endif;
objVirtDir.AccessWrite = FALSE;
objVirtDir.AspEnableParentPaths = TRUE;
objVirtDir.EnableDirBrowsing = FALSE;
objVirtDir.AspScriptLanguage = "JScript";
objVirtDir.AppFriendlyName = IISSite;
objVirtDir.AppIsolated = 2;
objVirtDir.AspAllowSessionState = FALSE;
if (SYSINFO.WINNT.bWinServer2003 = TRUE) then
objVirtDir.AppPoolID = svAppPool;
endif;
objVirtDir.SetInfo();
objVirtDir.AppCreate(TRUE);
objVirtDir.SetInfo();
catch
svLine = "Unable to create Virtual Directory " + IISSite + ". You will have to create it manually.";
nResult = WriteLine(nvLogFileHandle, svLine);
endcatch;
endif;
endif;
endif;
else
// IIS 7 setup
// Check for the correct application pool first
svCmd = "cmd";
svProg = " /C " + WINDIR ^ "system32" ^ "inetsrv" ^ "appcmd.exe";
svOut = szAppPath ^ "m5iis.txt";
svT = ' list apppool /name:"' + svAppPool + '" >>' + svOut;
svParms = svProg + svT;
svLine = "Checking for " + svAppPool + " application pool";
nResult = WriteLine(nvLogFileHandle, svLine);
nResult = LaunchAppAndWait(svCmd, svParms, WAIT | LAAW_OPTION_HIDDEN);
if (FileGrep (svOut, svAppPool, szField1,
nLineNum, RESTART) != 0) then
svLine = "Need to create application pool " + svAppPool;
nResult = WriteLine(nvLogFileHandle, svLine);
svF1 = ' add apppool /name:"' + svAppPool + '" /managedRunTimeVersion:"v2.0" /managedPipelineMode:"Classic" ';
// svF2 = '/autoStart:"true" /recycling.periodicRestart.requests:"4000" /recycling.periodicRestart.time:"24:00:00" /recycling.periodicRestart.memory:"512000" /recycling.periodicRestart.privateMemory:"196608"';
svF2 = '/autoStart:"true"';
svT = svF1 + svF2;
svHold = svF1 + svF2;
svParms = svProg + svT;
svLine = "Creating " + svAppPool + " application pool";
nResult = WriteLine(nvLogFileHandle, svLine);
nResult = LaunchAppAndWait(svCmd, svParms, WAIT | LAAW_OPTION_HIDDEN);
svT = ' list apppool /name:"' + svAppPool + '" >>' + svOut;
svParms = svProg + svT;
nResult = LaunchAppAndWait(svCmd, svParms, WAIT | LAAW_OPTION_HIDDEN);
if (FileGrep (svOut, svAppPool, szField1,
nLineNum, RESTART) != 0) then
svLine = "Unable to create application pool " + svAppPool;
nResult = WriteLine(nvLogFileHandle, svLine);
svLine = " command used was " + svHold;
nResult = WriteLine(nvLogFileHandle, svLine);
bProblem = TRUE;
endif;
endif;
nResult = DeleteFile(svOut);
// Now add the IIS application
svCmd = "cmd";
svProg = " /C " + WINDIR ^ "system32" ^ "inetsrv" ^ "appcmd.exe";
svOut = szAppPath ^ "m5iis.txt";
svT = ' list app http://localhost/' + IISSite + '" >>' + svOut;
svParms = svProg + svT;
svLine = "Checking for " + IISSite + " IIS application";
nResult = WriteLine(nvLogFileHandle, svLine);
nResult = LaunchAppAndWait(svCmd, svParms, WAIT | LAAW_OPTION_HIDDEN);
if (FileGrep (svOut, IISSite, szField1,
nLineNum, RESTART) = 0) then
if (IISSite = "CE_BIN") then
svLine = "Business Objects Exports Bin directory already exists. It will not be recreated.";
nResult = WriteLine(nvLogFileHandle, svLine);
return 0;
elseif (IISSite = "Uploads") then
svLine = "Uploads directory already exists. It will not be recreated.";
nResult = WriteLine(nvLogFileHandle, svLine);
return 0;
endif;
endif;
svT = ' add app /site.name:"Default Web Site" /path:/' + IISSite + ' /physicalPath:' + SiteDir + ' /applicationPool:' + svAppPool;
svParms = svProg + svT;
svLine = "Creating IIS Application " + IISSite + " using paramters of " + svT;
nResult = WriteLine(nvLogFileHandle, svLine);
nResult = LaunchAppAndWait(svCmd, svParms, WAIT | LAAW_OPTION_HIDDEN);
nResult = DeleteFile(svOut);
endif;

return 0;
end;
0 Kudos
boggle
Level 3

Hi mdbritt

Sorry to reopen an old thread, but I'm having issues with IIS 7 support.
No problem creating app pools and virtual directories etc with Installshield 2011, but I need some way of adding other properties e.g. ssl port bindings, requiressl etc, and I figure the IIS7 part of your script above should help me out.

My question is: what did you have to do in terms of your custom action to get this to work? When did you schedule the action in your execute sequence? Did you have to run it deferred in system context? Have you run this script in Win2K8 before? did you have any problems getting the output of appcmd list to write to the text file?

Thanks in advance for any help you can provide!
0 Kudos