Console App Display DLL logging info


B

Bill

Hello

I've got a C# console app, that calls a startup function in a C# dll that I
have created. In my DLL, as I'm processing data, I want to display some
logging information, but I want to pass it back to the console app, and have
it write the text to the console as it comes from the DLL, but I'm not sure
how I should do this....

Any suggestions, example


Thanks
 
Ad

Advertisements

B

Bill

The DLL, isn't going to actually do the printing to a console window,
instead it should pass text strings back to the calling app, and then the
calling app would print the string to the console window.
 
M

Mr. Arnold

Bill said:
Hello

I've got a C# console app, that calls a startup function in a C# dll that I
have created. In my DLL, as I'm processing data, I want to display some
logging information, but I want to pass it back to the console app, and have
it write the text to the console as it comes from the DLL, but I'm not sure
how I should do this....

Any suggestions, example


Thanks

You're easiest option would be to make a public object with get/set for
string value and pass the object between the console app and the dll.
You would instantiate the object in the console app and send it (by ref)
to the dll.

You come out of the dll back to the console app and print what's in the
object's string property.
 
B

Bill

I just setup a delegate in my DLL, then in my calling console app, I create
an instance of the delgete, and pass that into the constructor of the class
in the DLL, and assign it to a this.del where del is of delegate type.

In my console application I've got a function that prints out the strings.

Not sure if it is the best way to go, but it works
 
M

Mr. Arnold

Bill said:
I just setup a delegate in my DLL, then in my calling console app, I create
an instance of the delgete, and pass that into the constructor of the class
in the DLL, and assign it to a this.del where del is of delegate type.

In my console application I've got a function that prints out the strings.

Not sure if it is the best way to go, but it works

What -- you think it's about something being better? All I provided was
a simple solution no more or no less.


I don't need you in my face about it.
 
M

Mr. Arnold

Bill said:
I just setup a delegate in my DLL, then in my calling console app, I create
an instance of the delgete, and pass that into the constructor of the class
in the DLL, and assign it to a this.del where del is of delegate type.

In my console application I've got a function that prints out the strings.

Not sure if it is the best way to go, but it works


Oh, my post was not directed it at you. I can't see the other person. I
don't know why I can't see his posts nor do I care, and that's using two
readers.
 
Ad

Advertisements

T

Tom Shelton

It happens that Bill formulated :
Hello

I've got a C# console app, that calls a startup function in a C# dll that I
have created. In my DLL, as I'm processing data, I want to display some
logging information, but I want to pass it back to the console app, and have
it write the text to the console as it comes from the DLL, but I'm not sure
how I should do this....

Any suggestions, example


Thanks

I would look into Log4Net if I were you. It lets the application
control where log messages end up via the config file. You can also
have them go to multiple places and set different levels. It's an
excelent logging library, IMHO.
 
M

Mr. Arnold

Tom said:
It happens that Bill formulated :

I would look into Log4Net if I were you. It lets the application
control where log messages end up via the config file. You can also
have them go to multiple places and set different levels. It's an
excelent logging library, IMHO.

Enterprise Library has a nice logging application.
 
Ad

Advertisements

A

Arne Vajhøj

It happens that Bill formulated :

I would look into Log4Net if I were you. It lets the application control
where log messages end up via the config file. You can also have them go
to multiple places and set different levels. It's an excelent logging
library, IMHO.

It certainly is.

There are alternatives (Logging Application Block, NLog etc.), but it is
the original.

But for the specific question about how to get the logging from the
DLL to the EXE for logging it may not be the right answer.

Arne
 

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