So, I've recently finished Beta 1 of the local install of Easy Assets .NET and I started passing it to some of the beta testers (thanks to those companies that graciously accepted to test it). So far a few people have been into my code and I've received many compliments on how clean and nice the database and code is. I'm glad that my refactoring seems to have paid big dividends.
Suddenly, mysteriously, I got two reports from beta testers that the application wasn't working as per my install instructions and was giving a mysterious registry error in the enterprise library. How could this be?! The Enterprise Library has worked fine for me in development for months. I assembled the following information to start:
- Problem occurs when deploying to Windows Server 2003
- Registry error fires inside the database application block when logging tries to fire
- Installing the enterprise library package from microsoft on the server does not fix the problem
- Visual Studio is not installed on the server.
This was all very odd so I threw open my command window and tried to execute the InstallServices batch file (installservices.bat). It threw an error that visual studio was not installed. I boggled, why would you need visual studio to install the enterprise library services? Come to find out it was just looking for a utility provided by the .NET Framework. I leapt into action (with some help from Brenden Tompkins) and I modified the InstallServices.bat file to go right to the framework directory and grab the needed utility.
In addition, installing the enterprise library does not compile it without having visual studio installed. The way I fixed this was to install the Enterprise Library then copy the /bin directory from another machine that I had successfully compiled the Enterprise Library on. Then I replaced the installservices.bat file with my modified one and VOILA! Errors gone and Easy Assets .NET works properly.
Without further ado, here is the installer script to use to get services running without visual studio, my modifications are highlighted:
@echo off
@REM ---------------------------------------------------------------------------------
@REM InstallServices.bat file
@REM
@REM This batch file installs/uninstalls various services for the Enterprise Library
@REM application blocks.
@REM
@REM Optional arguments for this batch file:
@REM 1 - /u to unstall. Otherwise it is installed.
@REM ----------------------------------------------------------------------------------
echo.
echo ==========================================================================
echo InstallServices.bat
echo Installs/uninstalls services for the Enterprise Library
echo ==========================================================================
echo.
set Frameworkdir=%SystemRoot%\Microsoft.NET\Framework\v1.1.4322\
set binDir="..\bin"
set pause=true
@REM ---------------------------------------------------------------
@REM User can override default directory containing the
@REM the Enterprise Library assemblies by supplying
@REM a parameter to batch file (e.g. InstallServices C:\bin).
@REM ---------------------------------------------------------------
if "%1"=="/?" goto HELP
if "%1"=="" goto RUN
@REM ----------------------------------------------------
@REM If the first parameter is /q, do not pause
@REM at the end of execution.
@REM ----------------------------------------------------
if /i "%1"=="/q" (
set pause=false
SHIFT
)
@REM ----------------------------------------------------
@REM If the first parameter is /u, uninstall.
@REM ----------------------------------------------------
if /i "%1"=="/u" goto RUN
goto HELP
:RUN
@REM ------------------------------------------------
@REM Shorten the command prompt for making the output
@REM easier to read.
@REM ------------------------------------------------
set savedPrompt=%prompt%
set prompt=*$g
@ECHO ----------------------------------------
@ECHO InstallServices.bat Started
@ECHO ----------------------------------------
@ECHO.
@REM -------------------------------------------------------
@REM Change to the directory where the assemblies reside
@REM -------------------------------------------------------
pushd %binDir%
@ECHO.
@ECHO -----------------------------------------------------------------
@ECHO Installing Services for the Common Application Block
@ECHO -----------------------------------------------------------------
@ECHO.
if Exist Microsoft.Practices.EnterpriseLibrary.Common.dll %Frameworkdir%installutil %1 Microsoft.Practices.EnterpriseLibrary.Common.dll
@if errorlevel 1 goto :error
@ECHO.
@ECHO -----------------------------------------------------------------
@ECHO Installing Services for the Caching Application Block
@ECHO -----------------------------------------------------------------
@ECHO.
if Exist Microsoft.Practices.EnterpriseLibrary.Caching.dll %Frameworkdir%installutil %1 Microsoft.Practices.EnterpriseLibrary.Caching.dll
@if errorlevel 1 goto :error
@ECHO.
@ECHO -----------------------------------------------------------------
@ECHO Installing Services for the ConfigurationApplication Block
@ECHO -----------------------------------------------------------------
@ECHO.
if Exist Microsoft.Practices.EnterpriseLibrary.Configuration.dll %Frameworkdir%installutil %1 Microsoft.Practices.EnterpriseLibrary.Configuration.dll
@if errorlevel 1 goto :error
@ECHO.
@ECHO -----------------------------------------------------------------
@ECHO Installing Services for the Cryptography Application Block
@ECHO -----------------------------------------------------------------
@ECHO.
if Exist Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll %Frameworkdir%installutil %1 Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll
@if errorlevel 1 goto :error
@ECHO.
@ECHO -----------------------------------------------------------------
@ECHO Installing Services for the Data Access Application Block
@ECHO -----------------------------------------------------------------
@ECHO.
if Exist Microsoft.Practices.EnterpriseLibrary.Data.dll %Frameworkdir%installutil %1 Microsoft.Practices.EnterpriseLibrary.Data.dll
@if errorlevel 1 goto :error
@ECHO.
@ECHO -----------------------------------------------------------------------
@ECHO Installing Services for the Exception Handling Application Block
@ECHO -----------------------------------------------------------------------
@ECHO.
if Exist Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll %Frameworkdir%installutil %1 Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
@if errorlevel 1 goto :error
@ECHO.
@ECHO ---------------------------------------------------------------------------------
@ECHO Installing Services for the Logging and Instrumentation Application Block
@ECHO ---------------------------------------------------------------------------------
@ECHO.
if Exist Microsoft.Practices.EnterpriseLibrary.Logging.dll %Frameworkdir%installutil %1 Microsoft.Practices.EnterpriseLibrary.Logging.dll
@if errorlevel 1 goto :error
@ECHO.
@ECHO -----------------------------------------------------------------
@ECHO Installing Services for the Security Application Block
@ECHO -----------------------------------------------------------------
@ECHO.
if Exist Microsoft.Practices.EnterpriseLibrary.Security.dll %Frameworkdir%installutil %1 Microsoft.Practices.EnterpriseLibrary.Security.dll
@if errorlevel 1 goto :error
@ECHO.
@ECHO ----------------------------------------
@ECHO InstallServices.bat Completed
@ECHO ----------------------------------------
@ECHO.
@REM ----------------------------------------
@REM Restore the command prompt and exit
@REM ----------------------------------------
@goto :exit
@REM -------------------------------------------
@REM Handle errors
@REM
@REM Use the following after any call to exit
@REM and return an error code when errors occur
@REM
@REM if errorlevel 1 goto :error
@REM -------------------------------------------
:error
@ECHO An error occured in InstallServices.bat - %errorLevel%
if %pause%==true PAUSE
@exit errorLevel
:HELP
echo Usage: InstallServices.bat [/q] [/u]
echo.
echo Examples:
echo.
echo "InstallServices" - installs services for Enterprise Library assemblies
echo "InstallServices /u" - uninstalls services for Enterprise Library assemblies
echo "InstallServices /q" - installs services, no pause when error occurs (quiet mode)
echo.
@REM ----------------------------------------
@REM The exit label
@REM ----------------------------------------
:exit
popd
set pause=
set binDir=
set prompt=%savedPrompt%
set savedPrompt=
echo on
I would wager that you don't need to install the enterprise library installer at all and could just xcopy the .dll's in with your project and point this script at your project's /bin directory.
Posted
Mon, Mar 21 2005 4:16 PM
by
Eric Wise