February 2007 CTP Installation Issue

Topics: Data Access Application Block, General discussion
Mar 8, 2007 at 7:41 PM
I installed the February 2007 CTP for the App Blocks. However, I am receiving an error message when attempting to access the blocks. The error is pretty common:

"An error occurred creating the configuration section handler for dataConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

Any ideas as to why this is happening?
Mar 8, 2007 at 8:55 PM
Hi Jason -

Thanks for reporting this. Could you provide more details on exactly what you were doing when you got this error? Was it during installation, using the tool, running code, ...?

thanks
Tom
Mar 9, 2007 at 10:15 AM
Edited Mar 9, 2007 at 10:28 AM
Hi Tom ,
I am also facing the same problem.I am trying to use VAB in my winforms application.
(After successfully installing the EntLib3.0(FEB2007 CTP).
Am also having entlib 2.0 Jan2006 in my system.)..

So I added the integration references
from
"D:\EntLib3Src\App Blocks\Src\Validation\Integration\WinForms\bin\Debug\\Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WinForms.dll "

I have added 3/4 textboxes in a WinForms appln & trying to validate.(the busines.obj.files exists in a separate file CategoriesBO.cs file.

"D:\WindowsApplications\MathOperationWorkflowDemo\EntLibCachingDemo\app.config" is my app.config file path.

I have configured the VAB through EntLibConfig tool by going hru the follow.steps:

0)New application

1)added a new VAB->new type->added a validation provider(thru Type selector)-->ruleset-->property then added the properties(categoryid, name, shippeddate etc..)
&& associated the NotNullValidator, String Length Validator, etc for the properties.

After doing this,i ran the winforms appln.
I got the follow error.

---------------------------

---------------------------
An error occurred creating the configuration section handler for dataConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (D:\WindowsApplications\MathOperationWorkflowDemo\EntLibCachingDemo\bin\Debug\EntLibCachingDemo.vshost.exe.config line 6)
---------------------------
OK
---------------------------

Can you plz give any pointers to solve this issue...






the catgeoriesbusinesobjects.cs file

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WinForms;

namespace EntLibCachingDemo.BusinessObjects
{
public class CategoriesBO
{

private int _catgoryid;
private string _catgoryname;
private string _catgorydescri;
private object _picture;
private string _emailID;
private DateTime _shipStartDate;
private DateTime _shipDeliveredDate;

public string CatgeoryName
{
get { return _catgoryname; }
set { _catgoryname = value; }
}

public string CatgeoryDescr
{
get { return _catgorydescri; }
set { _catgorydescri = value; }
}

public string EmailID
{
get { return _catgorydescri; }
set { _catgorydescri = value; }
}

public int CatgeoryID
{
get { return _catgoryid; }
set { _catgoryid = value; }
}
public DateTime ShipStartDate
{
get { return _shipStartDate; }
set { _shipStartDate = value; }
}
public DateTime ShipDeliveredDate
{
get { return _shipDeliveredDate; }
set { _shipDeliveredDate = value; }
}

public System.Object Picture
{
get { return _picture; }
set { _picture = value; }
}
}
******************************************

WinForms file.form1.cs file
***************************************
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;

using Microsoft.Practices.EnterpriseLibrary.Validation.Integration;
using Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WinForms;


try
{

EntLibCachingDemo.BusinessObjects.CategoriesBO objCategory = new EntLibCachingDemo.BusinessObjects.CategoriesBO();


objCategory.CatgeoryID =Convert.ToInt32(txtxcatid.Text);
objCategory.CatgeoryName = txtcategoryname.Text;
objCategory.CatgeoryDescr = txtcatgeorydescr.Text;
objCategory.EmailID = txtemailidcategory.Text;
objCategory.ShipDeliveredDate =Convert.ToDateTime(txtdelivereddate.Text);
objCategory.ShipStartDate =Convert.ToDateTime(txtShippeddate.Text);


ValidationResults vresults = Validation.Validate(objCategory);
string message = string.Empty;

if (!vresults.IsValid)
{
foreach (ValidationResult results in vresults)
{
message += results;
// MessageBox.Show(results.Key + "\t\t" + results.Message);
}
}
if(message.Equals(string.Empty))
{
message ="input is Valid";
}
}
catch (Exception EXPDD)
{
MessageBox.Show(EXPDD.Message);
//ExceptionPolicy.HandleException(EXPDD,ExceptionPolicyConsts.LoggingNNotify);
}

*************************************************
The app.config's configSections contains...

<configSections>
<section name="validation" type="Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.ValidationSettings, Microsoft.Practices.EnterpriseLibrary.Validation, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
**************************************************************************
Mar 9, 2007 at 3:24 PM
Could you provide more details on exactly what you were doing when you got this error?
Sure! I downloaded the CTP and ran the installer. During the installer I made sure I compiled the code into the assemblies. I then copied all of the assemblies to the bin folder on a new web (not a web project, but a new web) that I've been working on. In the App_Code folder, I attempted to create a very basic function that utilizes the data assembly. Here is my sample VB code:

 
        Public Shared Function Test() As String
            'Create Database and DataReader
            Dim db As Database = DatabaseFactory.CreateDatabase("SecondSqlServer")
 
            Dim sqlCommand As String = "SELECT ProductName FROM Product WHERE (ProductID = 10)"
            Dim dbCommand As DbCommand = db.GetSqlStringCommand(sqlCommand)
 
            Return CStr(db.ExecuteScalar(dbCommand))
        End Function

I ran the configuration tool to create my web.config sections. However, if I try to load the web.config again in the tool, I receive the same messages. Here is a sampling from my web.config:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="dataConfiguration" 
            type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.9.9.2, 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" 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" allowDefinition="Everywhere" />
                    <section name="profileService" 
                        type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" allowDefinition="MachineToApplication" />
                    <section name="authenticationService" 
                        type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" allowDefinition="MachineToApplication" />
                </sectionGroup>
            </sectionGroup>
        </sectionGroup>
    </configSections>
    <dataConfiguration defaultDatabase="FirstSqlServer" />
    <connectionStrings>
        <add name="FirstSqlServer" connectionString="-ConnectionString-" providerName="System.Data.SqlClient" />
        <add name="SecondSqlServer" connectionString="-ConnectionString-" providerName="System.Data.SqlClient" />
    </connectionStrings>
 
    ...

Any suggestions would be appreciated! Thanks again Tom!
Mar 9, 2007 at 5:45 PM
Thanks for the extra info. Here is my theory:

Enterprise Library 3.0 ships with compiled, strong-named assemblies. It also includes source that compiles to non-strong-named assemblies. You're free to use either version, however the configuration for each version will be different as it will need to have either PublicKeyToken=31bf3856ad364e35 or PublicKeyToken=null to match your assemblies.

If you are using the standalone configuration tool, you can simply use the version compiled against the appropriate set of assemblies. However if you're using the Visual Studio-integrated tool, things are more complex as you only have one copy of Visual Studio installed.

By default, the Visual Studio editor will point to the strong-named assemblies, so you'll get errors if you edit config files for apps that use the non-strong-named version. Luckily you can change this on a per-solution basis by selecting the Solution root node, finding the EnterpriseLibraryConfigurationSet property in the properties window, and choosing EntLib3Src as the active set. Once you do this, the VS-integrated tool should load the non-strong-named assemblies for that solution. The documentation explains how you can edit the registry to add additional configuration sets or change the default.

Let me know if this helps.
Tom