Enterprise Library Data Access Application Block

Enterprise Library Data Access Application Block

AET_AJa
Contributor Contributor
1,874 Views
1 Reply
Message 1 of 2

Enterprise Library Data Access Application Block

AET_AJa
Contributor
Contributor

Hi,

I am trying to get data access to an SQL Server from a .NET class library running under AutoCAD 2011. I'm using Microsofts Enterprise Library Data Access Application Block (DAAB). The data acces is in a separate assembly, that have worked perfectly well for similar add-in scenarios under Word, Excel and Visio. In these scenarios, I just had to make sure that a xxx.dll.config file existed in the folder where the Add-In assembly was deployed. The config file contains:

 

<configuration>
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>
  </configSections>
  <dataConfiguration defaultDatabase="AET18"/>
  <connectionStrings>
    <add name="AET18" connectionString="Database=AET;Server=AET18;Integrated Security=SSPI" providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>

 

When initializing I get the error message: Activation error occurred while trying to get instance of type Database, key ""

 

I have seen this error message before, namely when i failed to place a xx.dll.config file in the directory where the add-in resided. So it seems that the enterprise library can't find the config file and thus can't read the connection strings.

 

I have tried placing the xx.dll.config file in acad.exe's directory, and I have also tried incorporating the xml in acad.exe.config under a <appSettings> ...  </appSettings> tag, but no luck. If I don't place it in these tags AutoCAD refuses to run, saying something about "permission to run" etc.

 

I know this is maybe more a question to a Enterprise Library discussion group, but I can't seem to find anything as to how the DAAB reads the connection strings, and I was hoping that someone else had tried this. 

0 Likes
1,875 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor

I think you should place the configuration settings for the Data Access Applocation Block in AutoCAD's acad.exe.config files.

 

However, you do not place them in <appSettings /> unless you also modify the Data Access Application Block to have it load configuration from <appSettings />.

 

I'd simply copy the the configuration content into acad.exe.config, e.g, copying this

 

<configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>
  </configSections>
  <dataConfiguration defaultDatabase="AET18"/>
  <connectionStrings>
    <add name="AET18" connectionString="Database=AET;Server=AET18;Integrated Security=SSPI" providerName="System.Data.SqlClient"/>
  </connectionStrings>

 

into acad.exe.config, directly underneath <configuration> tag.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes