Hi Jim,
Greatly thanks for the excellent details you provided. However, back to my
original question about how to setup the ASP.NET development environment for
using shared assemblies. Please correct me if I am wrong, it seems to me
that we need to add a post-build event to restart the IIS, or "touch" the
web.config for every changes made to the shared assembly projects ( in order
to reload the AppDomain).
I believe developers would appreciate if Microsoft can provide some
guidelines for developing ASP.NET applications with shared assemblies
scenarios. Actually the only reason we need to have shared assemblies is we
are using queued components from EnterpriseService namespace.
ILN
"Jim Cheshire [MSFT]" <jamesche@online.microsoft.com> wrote in message
news:Z$5ggTQuDHA.1412@cpmsftngxa06.phx.gbl...[color=blue]
> ILN,
>
> That article is not entirely accurate. As long as you don't make a change
> that causes the assembly hash value to change, you can update a new[/color]
version[color=blue]
> of the assembly in the GAC and the ASP.NET application will automatically
> use the new version without changing anything. (It should be noted that
> you do still have to reload the app domain.)
>
> What changes the hash value? If you change the assembly name, the major[/color]
or[color=blue]
> minor version, the public key token, or the culture, the hash value will
> change. As long as you don't modify any one of these, you would use the
> following procedure to update the assembly in the GAC.
>
> 1. Run sn to create a new verification entry for the new version. Do[/color]
that[color=blue]
> as
> follows:
>
> sn -Vr <assembly>
>
> 2. Run Gacutil to reinstall the assembly as follows:
>
> gacutil /nologo /if <assembly>
>
> Once you do that, simply open the web.config, add a new blank line, and
> save the web.config. That will force a reload of the app domain and your
> application will use the new assembly.
>
> If you have changed the hash value by changing one of the above, the
> easiest way to force your application to use the new version in cases[/color]
where[color=blue]
> you can't redirect the assembly binding in a configuration file is to use[/color]
a[color=blue]
> publisher policy assembly. Most people will say that you should use a
> publisher policy file, but that's not entirely accurate. The publisher
> policy file is used to create the publisher policy assembly, and it's
> actually the publisher policy assembly that redirects the binding.
>
> Here is an example of doing this. In this example, my assembly is called
> jcGAC.dll and I am changing the version number from 1.0.0.0 to 2.0.0.0.
>
> 1. Change code in version 1.0.0.0 of the assembly.
>
> 2. Change version number in assemblyinfo.cs to reflect new version.
>
> 3. Rebuild assembly.
>
> 4. Create publisher policy file in any text editor. You will need to
> replace "<public_key>" with the public key for your version 1.0 assembly.
>
> <configuration>
> <runtime>
> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
> <dependentAssembly>
> <assemblyIdentity name="jcGAC"
> publicKeyToken="<public_key>"
> culture="neutral" />
> <bindingRedirect oldVersion="1.0.0.0"
> newVersion="2.0.0.0"/>
> </dependentAssembly>
> </assemblyBinding>
> </runtime>
> </configuration>
>
> 5. Use al to create the publisher policy assembly. The publisher policy
> assembly MUST have the following file format:
> policy.major_ver.minor_ver.assembly.dll
>
> The major and minor version shown here would be the major and minor
> versions for your original version, not the updated new version. Below is
> an example of the command entered to create the publisher policy assembly
> for my assembly jcGAC.dll using the keyfile jcgac.snk. Note that the
> publisher policy file in created in step 4 was saved as pub.config.
>
> al /link:pub.config /out:policy.1.0.jcGAC.dll /keyfile:jcgac.snk
>
>
> 6. Install publisher policy assembly into the GAC.
>
> gacutil /i policy.2.0.jcGAC.dll
>
> 7. Install version 2.0.0.0 of your assembly into the GAC.
>
> gacutil /i jcGAC.dll
>
> 8. Restart the app domains by either saving a change to the[/color]
machine.config[color=blue]
> or by resetting IIS.
>
> 9. Run the ASP.NET app.
>
> After taking these steps, any ASP.NET application that originally
> referenced version 1.0.0.0 will now bind to version 2.0.0.0.
>
>
> Assembly binding is a fairly complex subject, but I hope that this helps
> explain a bit.
>
> Jim Cheshire, MCSE, MCSD [MSFT]
> Developer Support
> ASP.NET
>
jamesche@online.microsoft.com
>
> This post is provided as-is with no warranties and confers no rights.
>
> --------------------[color=green]
> >From: "Invalidlastname" <invalidlastname@toomanyvalidations.page>
> >References: <umWlzuBuDHA.540@tk2msftngp13.phx.gbl>[/color]
> <0CeiJ9HuDHA.1360@cpmsftngxa06.phx.gbl>
> <ut3xb$NuDHA.2408@tk2msftngp13.phx.gbl>[color=green]
> >Subject: Re: ASP.NET and shared assemblies
> >Date: Tue, 2 Dec 2003 11:09:34 -0500
> >Lines: 349
> >X-Priority: 3
> >X-MSMail-Priority: Normal
> >X-Newsreader: Microsoft Outlook Express 6.00.3790.0
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >Message-ID: <ecp6w6OuDHA.2060@TK2MSFTNGP10.phx.gbl>
> >Newsgroups: microsoft.public.dotnet.framework.aspnet
> >NNTP-Posting-Host: dc.cvent.com 65.117.187.221
> >Path:[/color]
>[/color]
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP10.[color=blue]
> phx.gbl[color=green]
> >Xref: cpmsftngxa06.phx.gbl[/color][/color]
microsoft.public.dotnet.framework.aspnet:194484[color=blue][color=green]
> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> >
> >BTW
> >from this article
> >
http://www.aspalliance.com/226
> >the asp.net will not look for the latest version from GAC, and this is[/color][/color]
what[color=blue][color=green]
> >I have experienced.
> >
> >ILN
> >
> >"Invalidlastname" <invalidlastname@toomanyvalidations.page> wrote in[/color]
> message[color=green]
> >news:ut3xb$NuDHA.2408@tk2msftngp13.phx.gbl...[color=darkred]
> >> Luke,
> >> The referenced projects, shared assemblies, are in the same solution as
> >> asp.net project. The references were added from Add Reference dialog[/color][/color][/color]
box[color=blue][color=green]
> >[color=darkred]
> >> Projects tab. The "copy local" was set to "false" for the references to[/color]
> >the[color=darkred]
> >> shared assemblies and to "true" for the references to private[/color][/color][/color]
assemblies.[color=blue][color=green][color=darkred]
> >>
> >> the followings are the project file fragment of the shared assembly
> >> (Xyz.Common)
> >> <VisualStudioProject>
> >> <CSHARP
> >> ProjectType = "Local"
> >> ProductVersion = "7.10.3077"
> >> SchemaVersion = "2.0"
> >> ProjectGuid = "{90AB26A7-505B-4E2F-9B80-0B910AFD215F}"
> >> SccProjectName = "SAK"
> >> SccLocalPath = "SAK"
> >> SccAuxPath = "SAK"
> >> SccProvider = "SAK"
> >> >
> >> <Build>
> >> <Settings
> >> ApplicationIcon = ""
> >> AssemblyKeyContainerName = ""
> >> AssemblyName = "Xyz.Common"
> >> AssemblyOriginatorKeyFile = ""
> >> DefaultClientScript = "JScript"
> >> DefaultHTMLPageLayout = "Grid"
> >> DefaultTargetSchema = "IE50"
> >> DelaySign = "false"
> >> OutputType = "Library"
> >> PreBuildEvent = '"C:\Program Files\Microsoft Visual[/color][/color]
> Studio[color=green][color=darkred]
> >> .NET 2003\SDK\v1.1\Bin\gacutil.exe" /nologo /uf "$(TargetPath)"'
> >> PostBuildEvent = '"C:\Program Files\Microsoft Visual[/color]
> >Studio[color=darkred]
> >> .NET 2003\SDK\v1.1\Bin\gacutil.exe" /nologo /if "$(TargetPath)"'
> >> RootNamespace = "Xyz.Common"
> >> RunPostBuildEvent = "OnBuildSuccess"
> >> StartupObject = ""
> >> >
> >> <Config
> >> Name = "Debug"
> >> AllowUnsafeBlocks = "false"
> >> BaseAddress = "285212672"
> >> CheckForOverflowUnderflow = "false"
> >> ConfigurationOverrideFile = ""
> >> DefineConstants = "DEBUG;TRACE"
> >> DocumentationFile = ""
> >> DebugSymbols = "true"
> >> FileAlignment = "4096"
> >> IncrementalBuild = "false"
> >> NoStdLib = "false"
> >> NoWarn = ""
> >> Optimize = "false"
> >> OutputPath = "bin\Debug\"
> >> RegisterForComInterop = "false"
> >> RemoveIntegerChecks = "false"
> >> TreatWarningsAsErrors = "false"
> >> WarningLevel = "4"
> >> />
> >> <Config
> >> Name = "Release"
> >> AllowUnsafeBlocks = "false"
> >> BaseAddress = "285212672"
> >> CheckForOverflowUnderflow = "false"
> >> ConfigurationOverrideFile = ""
> >> DefineConstants = "TRACE"
> >> DocumentationFile = ""
> >> DebugSymbols = "false"
> >> FileAlignment = "4096"
> >> IncrementalBuild = "false"
> >> NoStdLib = "false"
> >> NoWarn = ""
> >> Optimize = "true"
> >> OutputPath = "bin\Release\"
> >> RegisterForComInterop = "false"
> >> RemoveIntegerChecks = "false"
> >> TreatWarningsAsErrors = "false"
> >> WarningLevel = "4"
> >> />
> >> </Settings>
> >> <References>
> >> <Reference
> >> Name = "System"
> >> AssemblyName = "System"
> >> HintPath =
> >>[/color][/color][/color]
"..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework \v1.1.4322\System.dll"[color=blue][color=green][color=darkred]
> >> />
> >> <Reference
> >> Name = "System.Data"
> >> AssemblyName = "System.Data"
> >> HintPath =
> >>[/color][/color]
>
>"..\..\..\..\..\.\WINDOWS\Microsoft.NET\Framework \v1.1.4322\System.Data.dl
> l[color=green][color=darkred]
> >> "
> >> />
> >> <Reference
> >> Name = "System.XML"
> >> AssemblyName = "System.Xml"
> >> HintPath =
> >>[/color][/color]
>
>"..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framewor k\v1.1.4322\System.XML.dll
> "[color=green][color=darkred]
> >> />
> >> <Reference
> >> Name =[/color]
> >"Microsoft.ApplicationBlocks.ExceptionManagemen t"[color=darkred]
> >> Project = "{386CBF50-F4A9-4F05-98CB-B387D2D8F357}"
> >> Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
> >> Private = "False"
> >> />
> >> <Reference
> >> Name =
> >> "Microsoft.ApplicationBlocks.ExceptionManagement.I nterfaces"
> >> Project = "{5F25F8C2-DA02-46C6-A6CA-01E719EAD35D}"
> >> Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
> >> Private = "False"
> >> />
> >> <Reference
> >> Name = "Microsoft.ApplicationBlocks.Data"
> >> Project = "{30933672-466E-4F67-A111-ABF267539146}"
> >> Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
> >> Private = "False"
> >> />
> >> <Reference
> >> Name = "System.Web"
> >> AssemblyName = "System.Web"
> >> HintPath =
> >>[/color][/color]
>
>"..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framewor k\v1.1.4322\System.Web.dll
> "[color=green][color=darkred]
> >> />
> >> <Reference
> >> Name = "System.Security"
> >> AssemblyName = "System.Security"
> >> HintPath =
> >>[/color][/color]
>
>"..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framewor k\v1.1.4322\System.Securit
> y[color=green][color=darkred]
> >> .dll"
> >> />
> >> <Reference
> >> Name = "System.Web.Services"
> >> AssemblyName = "System.Web.Services"
> >> HintPath =
> >>[/color][/color]
>
>"..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framewor k\v1.1.4322\System.Web.Ser
> v[color=green][color=darkred]
> >> ices.dll"
> >> />
> >> </References>
> >> </Build>
> >>
> >> The followings are the project file fragment of the asp.net web[/color]
> >application[color=darkred]
> >>
> >> <VisualStudioProject>
> >> <CSHARP
> >> ProjectType = "Web"
> >> ProductVersion = "7.10.3077"
> >> SchemaVersion = "2.0"
> >> ProjectGuid = "{B92F596B-4F30-4FC2-9F84-5AD62B56C0DA}"
> >> SccProjectName = "SAK"
> >> SccLocalPath = "SAK"
> >> SccAuxPath = "SAK"
> >> SccProvider = "SAK"
> >> >
> >> <Build>
> >> <Settings
> >> ApplicationIcon = ""
> >> AssemblyKeyContainerName = ""
> >> AssemblyName = "Subscribers"
> >> AssemblyOriginatorKeyFile = ""
> >> DefaultClientScript = "JScript"
> >> DefaultHTMLPageLayout = "Flow"
> >> DefaultTargetSchema = "IE50"
> >> DelaySign = "false"
> >> OutputType = "Library"
> >> PreBuildEvent = ""
> >> PostBuildEvent = ""
> >> RootNamespace = "Xyz.Web.Subscribers"
> >> RunPostBuildEvent = "OnBuildSuccess"
> >> StartupObject = ""
> >> >
> >> <Config
> >> Name = "Debug"
> >> AllowUnsafeBlocks = "false"
> >> BaseAddress = "285212672"
> >> CheckForOverflowUnderflow = "false"
> >> ConfigurationOverrideFile = ""
> >> DefineConstants = "DEBUG;TRACE"
> >> DocumentationFile = ""
> >> DebugSymbols = "true"
> >> FileAlignment = "4096"
> >> IncrementalBuild = "false"
> >> NoStdLib = "false"
> >> NoWarn = ""
> >> Optimize = "false"
> >> OutputPath = "bin\"
> >> RegisterForComInterop = "false"
> >> RemoveIntegerChecks = "false"
> >> TreatWarningsAsErrors = "false"
> >> WarningLevel = "4"
> >> />
> >> <Config
> >> Name = "Release"
> >> AllowUnsafeBlocks = "false"
> >> BaseAddress = "285212672"
> >> CheckForOverflowUnderflow = "false"
> >> ConfigurationOverrideFile = ""
> >> DefineConstants = "TRACE"
> >> DocumentationFile = ""
> >> DebugSymbols = "false"
> >> FileAlignment = "4096"
> >> IncrementalBuild = "false"
> >> NoStdLib = "false"
> >> NoWarn = ""
> >> Optimize = "true"
> >> OutputPath = "bin\"
> >> RegisterForComInterop = "false"
> >> RemoveIntegerChecks = "false"
> >> TreatWarningsAsErrors = "false"
> >> WarningLevel = "4"
> >> />
> >> </Settings>
> >> <References>
> >> <Reference
> >> Name = "System"
> >> AssemblyName = "System"
> >> HintPath =
> >> "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1 .1.4322\System.dll"
> >> />
> >> <Reference
> >> Name = "System.Drawing"
> >> AssemblyName = "System.Drawing"
> >> HintPath =
> >>[/color][/color]
>
>"..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v 1.1.4322\System.Drawing.dl
> l[color=green][color=darkred]
> >> "
> >> />
> >> <Reference
> >> Name = "System.Data"
> >> AssemblyName = "System.Data"
> >> HintPath =
> >>[/color][/color]
> "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1 .1.4322\System.Data.dll"[color=green][color=darkred]
> >> />
> >> <Reference
> >> Name = "System.Web"
> >> AssemblyName = "System.Web"
> >> HintPath =
> >>[/color][/color][/color]
"..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1 .1.4322\System.Web.dll"[color=blue][color=green][color=darkred]
> >> />
> >> <Reference
> >> Name = "System.XML"
> >> AssemblyName = "System.Xml"
> >> HintPath =
> >>[/color][/color][/color]
"..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1 .1.4322\System.XML.dll"[color=blue][color=green][color=darkred]
> >> />
> >> <Reference
> >> Name = "Xyz.Common"
> >> Project = "{90AB26A7-505B-4E2F-9B80-0B910AFD215F}"
> >> Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
> >> Private = "False"
> >> />
> >> <Reference
> >> Name =[/color]
> >"Microsoft.ApplicationBlocks.ExceptionManagemen t"[color=darkred]
> >> Project = "{386CBF50-F4A9-4F05-98CB-B387D2D8F357}"
> >> Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
> >> Private = "False"
> >> />
> >> <Reference
> >> Name =
> >> "Microsoft.ApplicationBlocks.ExceptionManagement.I nterfaces"
> >> Project = "{5F25F8C2-DA02-46C6-A6CA-01E719EAD35D}"
> >> Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
> >> Private = "False"
> >> />
> >> <Reference
> >> Name = "System.Web.Services"
> >> AssemblyName = "System.Web.Services"
> >> HintPath =
> >>[/color][/color]
>
>"..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v 1.1.4322\System.Web.Servic
> e[color=green][color=darkred]
> >> s.dll"
> >> />
> >> <Reference
> >> Name = "Microsoft.ApplicationBlocks.Data"
> >> Project = "{30933672-466E-4F67-A111-ABF267539146}"
> >> Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
> >> Private = "False"
> >> />
> >> <Reference
> >> Name = "Xyz.DAL"
> >> Project = "{6559D88E-6265-4424-AC2D-8E4BC4462361}"
> >> Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
> >> />
> >> <Reference
> >> Name = "Xyz.Accounts"
> >> Project = "{FAE55257-8189-49CC-8421-AE34C85300BF}"
> >> Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
> >> />
> >> <Reference
> >> Name = "Xyz.Async"
> >> Project = "{E6D51F3B-F4A7-4A25-BAC1-6013EF66C4B4}"
> >> Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
> >> Private = "False"
> >> />
> >> </References>
> >> </Build>
> >>
> >>
> >>
> >> We used queued components for asynchronous processes. If the
> >>
> >> ILN
> >>
> >>
> >>
> >>
> >>
> >> "MSFT" <lukezhan@online.microsoft.com> wrote in message
> >> news:0CeiJ9HuDHA.1360@cpmsftngxa06.phx.gbl...
> >> > Hello,
> >> >
> >> > How did you add the reference to the web application? Based on my[/color][/color][/color]
test,[color=blue][color=green][color=darkred]
> >> the
> >> > web application will try to find the latest version of the referenced
> >> > assembly. (I added the reference by browsing to the classlibrary file[/color]
> >and[color=darkred]
> >> > set "copy local" to false.
> >> >
> >> > Luke
> >> > Microsoft Online Support
> >> >
> >> > Get Secure!
www.microsoft.com/security
> >> > (This posting is provided "AS IS", with no warranties, and confers no
> >> > rights.)
> >> >
> >>
> >>[/color]
> >
> >
> >[/color]
>[/color]