simple logging in a C# COM DLL

  • Thread starter Thread starter wurzelCidermaker
  • Start date Start date
W

wurzelCidermaker

I have created a very simple C# class library (DLL).

I have ticked the "Register for COM interop" option in the project
properties dialog.

I have made the [assembly: ComVisible(true)] in the AssemblyInfo.cs file.

I can call a public method in this library from VBScript.

So far so good, now I'd like to have some very *simple* loggging capability.

For other applications I've gone down the [log4net] route and rolled by own
loggers etc...etc.

For this tiny DLL, I'd like to have for example the option to just drop a
[myDll.dll.config] file into the same directory as the DLL and add a trace
listener that outputs to a file or optionally roll my own trace listener
(i.e. udp).

I've successfully done things with trace listeners, but cannot get the DLL
to pick up the custom trace listener config file.

I've tried various names for the config file, but no joy.

Any suggestions?

Is it because I'm calling it from a VBScript file and not a .NET application?
 
I have created a very simple C# class library (DLL).

I have ticked the "Register for COM interop" option in the project
properties dialog.

I have made the [assembly: ComVisible(true)] in the AssemblyInfo.cs file.

I can call a public method in this library from VBScript.

So far so good, now I'd like to have some very *simple* loggging capability.

For other applications I've gone down the [log4net] route and rolled by own
loggers etc...etc.

For this tiny DLL, I'd like to have for example the option to just drop a
[myDll.dll.config] file into the same directory as the DLL and add a trace
listener that outputs to a file or optionally roll my own trace listener
(i.e. udp).

I've successfully done things with trace listeners, but cannot get the DLL
to pick up the custom trace listener config file.

I've tried various names for the config file, but no joy.

Any suggestions?

Is it because I'm calling it from a VBScript file and not a .NET application?

Hi,

By default a DLL has no config file. What you can do is read the
config in your code , make the file to reside in the same folder of
the dll, then you can read it using something like
System.IO.Path.GetDirectoryName( Assembly.GetRunningAssembly().Location)
+ "\\log.config";
 
So are you saying that a DLL cannot read a [myDll.dll.config] automatcially
and add a trace listener contained in that config file?

Ignacio Machin ( .NET/ C# MVP ) said:
I have created a very simple C# class library (DLL).

I have ticked the "Register for COM interop" option in the project
properties dialog.

I have made the [assembly: ComVisible(true)] in the AssemblyInfo.cs file.

I can call a public method in this library from VBScript.

So far so good, now I'd like to have some very *simple* loggging capability.

For other applications I've gone down the [log4net] route and rolled by own
loggers etc...etc.

For this tiny DLL, I'd like to have for example the option to just drop a
[myDll.dll.config] file into the same directory as the DLL and add a trace
listener that outputs to a file or optionally roll my own trace listener
(i.e. udp).

I've successfully done things with trace listeners, but cannot get the DLL
to pick up the custom trace listener config file.

I've tried various names for the config file, but no joy.

Any suggestions?

Is it because I'm calling it from a VBScript file and not a .NET application?

Hi,

By default a DLL has no config file. What you can do is read the
config in your code , make the file to reside in the same folder of
the dll, then you can read it using something like
System.IO.Path.GetDirectoryName( Assembly.GetRunningAssembly().Location)
+ "\\log.config";
 
Back
Top