Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Load the log4net assembly into the GAC

84 views
Skip to first unread message

andrewwages

unread,
Sep 28, 2009, 12:30:40 PM9/28/09
to
I was having the same type of issue with a lib I wrote. I just had to add the assembly to the GAC (Global Assembly Cache). Then I was able to load my assembly.

Hope this helps!

Emil ?str? wrote:

Loading NHibernate.dll (and log4net) in PowerShell
16-Apr-09

Hi!

I'm trying to load a .Net DLL (NHibernate.dll, but that is probably not
relevant) which in turns references log4net. Log4net seems to give problems:

---------------------------------
System.Management.Automation.MethodInvocationException: Exception calling
".ctor" with "0" argument(s): "The type initializer for 'NHibernat
e.Cfg.Configuration' threw an exception." --->
System.TypeInitializationException: The type initializer for
'NHibernate.Cfg.Configuration' t
hrew an exception. ---> System.IO.FileNotFoundException: Could not load file
or assembly 'log4net, Version=1.2.10.0, Culture=neutral, Public
KeyToken=1b44e1d426115821' or one of its dependencies. The system cannot
find the file specified.
File name: 'log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=1b44e1d426115821'
at NHibernate.Cfg.Configuration..cctor()
--- End of inner exception stack trace ---
at
System.Runtime.CompilerServices.RuntimeHelpers._RunClassConstructor(IntPtr
type)
at
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle type)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at
System.Management.Automation.DotNetAdapter.AuxiliarConstructorInvoke(ConstructorInfo constructor, Object[] arguments, MethodInformatio
n methodInformation, Object[] originalArguments)
--- End of inner exception stack trace ---
at
System.Management.Automation.DotNetAdapter.AuxiliarConstructorInvoke(ConstructorInfo constructor, Object[] arguments, MethodInformatio
n methodInformation, Object[] originalArguments)
at
System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(ConstructorInfo[] constructors, Object[] arguments)
at
Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(ConstructorInfo[] constructors, Object[] args)
At line:1 char:39
+ C:\tfs\Lernia\Int??ktsverktyget\test.ps1 <<<<
---------------------------------

So it seems that log4net references something that cannot be found. The
question is what that might be...

Here's my script:

[reflection.assembly]::loadfile('C:\TFS\Lernia\Int??ktsverktyget\Libs\log4net.dll')
[reflection.assembly]::loadfile('C:\TFS\Lernia\Int??ktsverktyget\Libs\NHibernate.dll')
$config = new-object NHibernate.Cfg.Configuration

It's the last line of the script that throws the exception. It's probably
thrown the first time that a log message is created.

Any ideas on what might be problem or how I can debug this are most welcome!

Thanks in advance

Emil

EggHeadCafe - Software Developer Portal of Choice
WPF DataGrid Custom Paging and Sorting
http://www.eggheadcafe.com/tutorials/aspnet/8a2ea78b-f1e3-45b4-93ef-32b2d802ae17/wpf-datagrid-custom-pagin.aspx

0 new messages