DAAB problem

C

Chubbly Geezer

Now I'm coming from a VB6 background so I may be overlooking something here.

I have functionality that is contained with 2 VB 2005 dll's.

WARC_Subs_Reporting.dll which handles report functions and has a reference
to WARC_Standard_Functions which holds the day to day functionality and has
references to Microsoft.Practices.EnterpriseLibrary.Data.dll and
Microsoft.Practices.EnterpriseLibrary.Common.dll

I want WARC_Subs_Reporting.dll available to MS Access 2003 and so have
assigned Strong Names to all of the above. I have created an install
routine for WARC_Subs_Reporting.dll which then has the other 3 named dll's
as references. The install when run installs all 4 dll's to the correct
directory. I then add WARC_Subs_Reporting.dll to the GAC as it is the only
dll I require to access from COM.

I've now created a dummy VB 2005 project to test the installed dll. When I
step through, it calls a procedure within WARC_Subs_Reporting.dll, which
calls a procedure within WARC_Standard_Functions that creates a dataset by
using the procedures within the DAAB. However, it always falls over on the
following line of code within the DAAB:

return EnterpriseLibraryFactory.BuildUp<T>(name, configurationSource);

within the 'public T Create(string name)' procedure within the
'NameTypeFactoryBase' class.

Giving this error:

The type initializer for
'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory'
threw an exception.

Now, to be honest, I have no idea what this is and cannot find any useful
help on the matter. Any ideas.

Thanks

Chubbly
 
N

Nicholas Paldino [.NET/C# MVP]

Chubbly,

Have you tried to debug this? There should also be information in the
Message property of the exception. Also, be sure to check the
InnerException property. It looks like there is a static constructor for
the
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory
class which is throwing an exception.

Also, a comment on your installation. While you might only be exposing
classes from one assembly in the GAC, you should have all of the references
that the assembly has in the GAC as well. It doesn't make sense to have
just the one assembly in the GAC and the others be private, when you know
that it will require those references.

The idea here is to distrubute those assemblies as a logical unit, which
you are currently breaking up.

Adding them to the GAC won't make them visible to COM, it will just
enforce that logical unit.

Hope this helps.
 
C

Chubbly Geezer

Nicolas

thanks for the quick response.

I am unable to find any info on the inner exception, but copying this error
to the clipboard produces the following:

System.TypeInitializationException was unhandled
Message="The type initializer for
'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory'
threw an exception."
Source="Microsoft.Practices.EnterpriseLibrary.Common"
TypeName="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory"
StackTrace:
at
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](String
id, IConfigurationSource configurationSource)
at
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.Create(String
name)
at
Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase(String
name)
at SharedFunctions.clsConnection.CreateDataset(String strSQL, String
conn)
at WARC_Subs_Reporting.modRenewal.AgentsRenewalsCheck()
at WARC_Subs_Reporting.clsPublic.AgentsRenewal()
at WindowsApplication3.Form1.Button1_Click(Object sender, EventArgs
e) in C:\temp\2005\WindowsApplication3\WindowsApplication3\Form1.vb:line 8
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine)
at WindowsApplication3.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

with which I am totally lost. I can see where the error is happening but
not too sure how to resolve.

Chubbly
Nicholas Paldino said:
Chubbly,

Have you tried to debug this? There should also be information in the
Message property of the exception. Also, be sure to check the
InnerException property. It looks like there is a static constructor for
the
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory
class which is throwing an exception.

Also, a comment on your installation. While you might only be exposing
classes from one assembly in the GAC, you should have all of the
references that the assembly has in the GAC as well. It doesn't make
sense to have just the one assembly in the GAC and the others be private,
when you know that it will require those references.

The idea here is to distrubute those assemblies as a logical unit,
which you are currently breaking up.

Adding them to the GAC won't make them visible to COM, it will just
enforce that logical unit.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Chubbly Geezer said:
Now I'm coming from a VB6 background so I may be overlooking something
here.

I have functionality that is contained with 2 VB 2005 dll's.

WARC_Subs_Reporting.dll which handles report functions and has a
reference to WARC_Standard_Functions which holds the day to day
functionality and has references to
Microsoft.Practices.EnterpriseLibrary.Data.dll and
Microsoft.Practices.EnterpriseLibrary.Common.dll

I want WARC_Subs_Reporting.dll available to MS Access 2003 and so have
assigned Strong Names to all of the above. I have created an install
routine for WARC_Subs_Reporting.dll which then has the other 3 named
dll's as references. The install when run installs all 4 dll's to the
correct directory. I then add WARC_Subs_Reporting.dll to the GAC as it
is the only dll I require to access from COM.

I've now created a dummy VB 2005 project to test the installed dll. When
I step through, it calls a procedure within WARC_Subs_Reporting.dll,
which calls a procedure within WARC_Standard_Functions that creates a
dataset by using the procedures within the DAAB. However, it always
falls over on the following line of code within the DAAB:

return EnterpriseLibraryFactory.BuildUp<T>(name, configurationSource);

within the 'public T Create(string name)' procedure within the
'NameTypeFactoryBase' class.

Giving this error:

The type initializer for
'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory'
threw an exception.

Now, to be honest, I have no idea what this is and cannot find any useful
help on the matter. Any ideas.

Thanks

Chubbly
 
K

Kevin Yu [MSFT]

Hi Chubbly,

If you step into the code, on which line was the exception thrown?

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
C

Chubbly Geezer

It seems the inner exception is

System.IO.FileNotFoundException



Chubbly Geezer said:
Nicolas

thanks for the quick response.

I am unable to find any info on the inner exception, but copying this
error to the clipboard produces the following:

System.TypeInitializationException was unhandled
Message="The type initializer for
'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory'
threw an exception."
Source="Microsoft.Practices.EnterpriseLibrary.Common"

TypeName="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory"
StackTrace:
at
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](String
id, IConfigurationSource configurationSource)
at
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.Create(String
name)
at
Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase(String
name)
at SharedFunctions.clsConnection.CreateDataset(String strSQL, String
conn)
at WARC_Subs_Reporting.modRenewal.AgentsRenewalsCheck()
at WARC_Subs_Reporting.clsPublic.AgentsRenewal()
at WindowsApplication3.Form1.Button1_Click(Object sender, EventArgs
e) in C:\temp\2005\WindowsApplication3\WindowsApplication3\Form1.vb:line 8
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine)
at WindowsApplication3.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

with which I am totally lost. I can see where the error is happening but
not too sure how to resolve.

Chubbly
Nicholas Paldino said:
Chubbly,

Have you tried to debug this? There should also be information in the
Message property of the exception. Also, be sure to check the
InnerException property. It looks like there is a static constructor for
the
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory
class which is throwing an exception.

Also, a comment on your installation. While you might only be
exposing classes from one assembly in the GAC, you should have all of the
references that the assembly has in the GAC as well. It doesn't make
sense to have just the one assembly in the GAC and the others be private,
when you know that it will require those references.

The idea here is to distrubute those assemblies as a logical unit,
which you are currently breaking up.

Adding them to the GAC won't make them visible to COM, it will just
enforce that logical unit.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Chubbly Geezer said:
Now I'm coming from a VB6 background so I may be overlooking something
here.

I have functionality that is contained with 2 VB 2005 dll's.

WARC_Subs_Reporting.dll which handles report functions and has a
reference to WARC_Standard_Functions which holds the day to day
functionality and has references to
Microsoft.Practices.EnterpriseLibrary.Data.dll and
Microsoft.Practices.EnterpriseLibrary.Common.dll

I want WARC_Subs_Reporting.dll available to MS Access 2003 and so have
assigned Strong Names to all of the above. I have created an install
routine for WARC_Subs_Reporting.dll which then has the other 3 named
dll's as references. The install when run installs all 4 dll's to the
correct directory. I then add WARC_Subs_Reporting.dll to the GAC as it
is the only dll I require to access from COM.

I've now created a dummy VB 2005 project to test the installed dll.
When I step through, it calls a procedure within
WARC_Subs_Reporting.dll, which calls a procedure within
WARC_Standard_Functions that creates a dataset by using the procedures
within the DAAB. However, it always falls over on the following line of
code within the DAAB:

return EnterpriseLibraryFactory.BuildUp<T>(name, configurationSource);

within the 'public T Create(string name)' procedure within the
'NameTypeFactoryBase' class.

Giving this error:

The type initializer for
'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory'
threw an exception.

Now, to be honest, I have no idea what this is and cannot find any
useful help on the matter. Any ideas.

Thanks

Chubbly
 
C

Chubbly Geezer

Hi Kevin

It always falls over on the following line of code within
Microsoft.Practices.EnterpriseLibrary.Common.dll:

return EnterpriseLibraryFactory.BuildUp<T>(name, configurationSource);

within the 'public T Create(string name)' procedure within the
'NameTypeFactoryBase' class.

Giving this error:

The type initializer for
'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory'
threw an exception.

The inner exception appears to be 'System.IO.FileNotFoundException'

Any help would be appreciated.

Chubbly
 
C

Chubbly Geezer

I appear to have tracked down what I think is the error.

"The requested database Subscriptions2_Test is not defined in configuration."

This is being thrown from within the 'DatabaseFactory.cs' class and the 'CreateDatabase' method.

Subscriptions2_Test is the name of the default connection within my app.config in my WARC_Standard_Functions.dll

Do I maybe need to create an app.config file for the DatabaseFactory ..?
 
K

Kevin Yu [MSFT]

Hi Chubby,

Since the inner exception is a FileNotFoundException, could you please if
you're missing something? Are the assemblies you're referencing all exists
and registered successfully?

I agree with Nicholas that the assemblies referenced by assembly in GAC
should all be in GAC.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
C

Chubbly Geezer

I don't appear to be missing anything. I have reinstalled the Enterprise
Library in full.

My WARC_Subs_Reporting.dll references WARC_Shared_Functions.dll which in
turn references 2 enterprise library dll's. My setup project for
WARC_Subs_Reporting.dll shows the other 3 dll's as dependencies. Upon
install, all 4 dll's are copied to the correct directory as expected.

When I then run my test project which references WARC_Subs_Reporting.dll, I
can step through until I receive the error. This happens whether I add the
dll's to the GAC or not.
 
C

Chubbly Geezer

When I create a database I use the following procedure:

Public Class clsConnection

Function CreateDataset(ByVal strSQL As String, ByVal conn As String) As DataSet

Dim db As Database = DatabaseFactory.CreateDatabase(conn)

Dim sqlcommand As String = strSQL

Dim dbcommand As System.Data.Common.DbCommand = db.GetSqlStringCommand(sqlcommand)

Dim ds As DataSet = db.ExecuteDataSet(dbcommand)

Return ds

End Function

as you can see I am supplying an argument ('conn' in this case Subscriptions2_Test) for the 'DatabaseFactory.CreateDatabase'. It seems to me that the problem is here somewhere. The demo app supllied with Ent Lib does not use this argument.

I have an app.config file included as part of my dll which looks like this:

<configuration>

<configSections>

<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" />

</configSections>

<connectionStrings>

<add name="WarcLog_Test" connectionString="server=WEBDEV;database=WARCLog;Integrated Security=true"

providerName="System.Data.SqlClient" />

<add name="Subscriptions2_Test" connectionString="server=WEBDEV;database=Subscriptions2;Integrated Security=true"

providerName="System.Data.SqlClient" />

<add name="WarcLog" connectionString="server=WARC;database=WARCLog;Integrated Security=true"

providerName="System.Data.SqlClient" />

<add name="Subscriptions" connectionString="server=ACC_SQL2K;database=Subscriptions;Integrated Security=true"

providerName="System.Data.SqlClient" />

</connectionStrings>

<dataConfiguration defaultDatabase="Subscriptions2_Test"/>

</configuration>

It appears that this database connection string is not being found when I run the installed app. I'm sure there must be a simple solution here.
 
K

Kevin Yu [MSFT]

Hi Chubbly,

Based on my analyze, the configurationSource in your buidUp method might be
incorrect. Has the configuration file been put to a directory that the
enterprise library can see? Please use F11 to step into the method and
check the value for configurationSource.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
C

Chubbly Geezer

I have now removed this DB argument and the app errors when trying to find the default database.

I have a config file in both my DLL's and now also in the Enterprise Library Data DLL, but it still cannot find the entries within it and so I suspect cannot see the config file at all.


When I create a database I use the following procedure:

Public Class clsConnection

Function CreateDataset(ByVal strSQL As String, ByVal conn As String) As DataSet

Dim db As Database = DatabaseFactory.CreateDatabase(conn)

Dim sqlcommand As String = strSQL

Dim dbcommand As System.Data.Common.DbCommand = db.GetSqlStringCommand(sqlcommand)

Dim ds As DataSet = db.ExecuteDataSet(dbcommand)

Return ds

End Function

as you can see I am supplying an argument ('conn' in this case Subscriptions2_Test) for the 'DatabaseFactory.CreateDatabase'. It seems to me that the problem is here somewhere. The demo app supllied with Ent Lib does not use this argument.

I have an app.config file included as part of my dll which looks like this:

<configuration>

<configSections>

<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" />

</configSections>

<connectionStrings>

<add name="WarcLog_Test" connectionString="server=WEBDEV;database=WARCLog;Integrated Security=true"

providerName="System.Data.SqlClient" />

<add name="Subscriptions2_Test" connectionString="server=WEBDEV;database=Subscriptions2;Integrated Security=true"

providerName="System.Data.SqlClient" />

<add name="WarcLog" connectionString="server=WARC;database=WARCLog;Integrated Security=true"

providerName="System.Data.SqlClient" />

<add name="Subscriptions" connectionString="server=ACC_SQL2K;database=Subscriptions;Integrated Security=true"

providerName="System.Data.SqlClient" />

</connectionStrings>

<dataConfiguration defaultDatabase="Subscriptions2_Test"/>

</configuration>

It appears that this database connection string is not being found when I run the installed app. I'm sure there must be a simple solution here.
 
C

Chubbly Geezer

My test app is called WindowsApplication3

When I run, it steps through my DLL's and into the EntLib DLL's with the
configurationsource showing as :

C:\temp\2005\WindowsApplication3\WindowsApplication3\bin\Debug\WindowsApplication3.vshost.exe.config

which does not exist.
 
C

Chubbly Geezer

OK, I've wasted too much time so I'm going to give up trying to get this to work.

I've replaced
Dim db As Database = DatabaseFactory.CreateDatabase(conn)

with

Dim db As SqlDatabase = New SqlDatabase(conn)

and all seems to work fine at the moment.



I eventually found this on someone's blog. Is it me, but I can't find any actual documentation for the Enterprise Library. I wish I'd left my original code in place, this all seems like a bit too much hassle.
 
K

Kevin Yu [MSFT]

Hi Chubby,

This seems to be the problem. The enterprise library will get the database
connection string from an app.config file. Since you mentioned that you
have supplied the app.config file, please check if
WindowsApplication3.vshost.exe.config or WindowsApplication3.exe.config is
in the Debug folder.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
C

Chubbly Geezer

Thanks very much for your help Kevin, but I've wasted too much time already.
I need to move on.

Chubbly
 
K

Kevin Yu [MSFT]

Hi Chubbly,

Sorry that I didn't provide much useful information. Good luck!

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
N

Nelson Garcia

I had the same trouble and after spend several hours i got the solution:
you must add a reference to the Microsoft.Practices.ObjectBuilder.dll
assembly.

that's all!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top