Cannot create a reference to library dll's

Topics: Data Access Application Block, Enterprise Library Core, General discussion, Logging Application Block
Apr 18, 2007 at 11:17 PM
This is driving me nuts.

I want to use the data and logging application blocks. So, I used the configuration tool to setup my web.config file. That worked a charm. When it came time to reference dll's from the GAC, it would allow me but doing nothing. There'd be no reference in the list of references for the site. Then, I had the bright idea of adding the assemblies manually to my web.config. When I tried to save the file I was given a 'the process cannot access the file because it is being used by another process...'. Turns out that the process using the file is VS studio!! Visual studio can't edit the web.config file because visual studio is using the file. Nice.

So... I removed the library from GAC, rebooted a dozen or so times just to be sure and tried to reference the dll's after dropping them into my bin. No joy.

OK. I closed visual studio, deleted all the config information and then reloaded my project. Now I could add references to the assemblies I needed and was able to use the objects in my code. Of course, this does me no good cause I HAVE NO CONFIGURATION INFORMATION! :-)

This is ridiculous. I want to have bugs and problems like the rest of you with your runtime errors and bad syntax. Please help me get out of the starting gate.

Thanks.

(oh... btw, I've been using the application blocks for years)
Apr 18, 2007 at 11:29 PM
I'm not sure what's going on here, but in general you should not add references to GAC copies of assemblies - you should add them from a "regular" folder. If the assemblies are GAC'ed and your reference is to the same strong-named assemblies, the GAC will be used at runtime regardless to which copy you originally pointed your app at.

Tom
Apr 19, 2007 at 12:02 AM
Thanks for replying Tom,

I've had a chance to cool down (read some heartwarming stuff on the Canucks ;-) ).

I've removed the libraries from the GAC, so I should be able to dump the libraries into my Bin and then reference them from the web app. However, if I do that it adds the assemblies to the file listing on the solution explorer, but VS does not add the assemblies to the list of references for the site. So, the files are there, but the site is unaware of it.

I tried something else. I have a few business classes included in the web site project. These are in their own projects. I referenced logging into one of them and it worked exactly as expected.

I think the problem has something to do with the settings in my web.config. After configuring web.config with the configuration tool, web.config can no longer be edited while VS is open. I've attached a cleaned up version of the relevant portions of my web.config for you to peruse.

Thanks again.

<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup">
<section name="converters" type="Microsoft.Web.Configuration.ConvertersSection" />
</sectionGroup>
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add databaseInstanceName="yyy" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory" formatter="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Database Trace Listener" />
<add toAddress="tmurphy@yyy.com" fromAddress="logging@yyy.com"
subjectLineStarter="" subjectLineEnder="" smtpServer="yyy.yyy.ca"
smtpPort="25" formatter="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Email TraceListener" />
<add source="Enterprise Library Logging" formatter="Text Formatter"
log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Formatted EventLog TraceListener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="Application Exceptions">
<listeners>
<add name="Database Trace Listener" />
<add name="Email TraceListener" />
</listeners>
</add>
<add switchValue="All" name="UI Events">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
<add switchValue="All" name="General">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>