By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,649 Members | 1,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,649 IT Pros & Developers. It's quick & easy.

sending messages from a dll to the main app

P: n/a
Hi,

I have an application that contains a class library as another project.
The application basically executes DTS packages on a remote SQL Server.

This works great.

However I want to add some code that will allow the class executing the
current DTS package to send back messages to the main form of the application.

I have tried using throw new system.exception ("message") this only works
when an exception has occured.

The DTS code I use was taken from the net and has on progress, on error, on
start, on finish events that do a console.writeline.
Instead I would like the message not to go to the console but sent out to a
form label in the application.

I don't want to have to necessarily call an exception as this will cause me
to drop out of the code which is in fact working perfectly fine.

thank you,

Chris

Nov 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
Hi,

I have an application that contains a class library as another project.
The application basically executes DTS packages on a remote SQL Server.

This works great.

However I want to add some code that will allow the class executing the
current DTS package to send back messages to the main form of the
application.

I have tried using throw new system.exception ("message") this only works
when an exception has occured.

The DTS code I use was taken from the net and has on progress, on error,
on
start, on finish events that do a console.writeline.
Instead I would like the message not to go to the console but sent out to
a
form label in the application.


First, you'll probably get more help with this by asking in one of the SQL
Server newsgroups, perhaps microsoft.public.sqlserver.programming or .dts.

You'll have to go look at the API used to execute the remote DTS package to
see if it has any way to pass events back. If it does, then perhaps you
could pick up those events in the .NET class which calls that API. That
class could raise an event when it receives one from the DTS package. The
form could listen for that event and update its label.

John Saunders
Nov 22 '05 #2

P: n/a
Hi Chris,

Exceptions must never be (mis)used to control normal program behaviour -
they are only ever meant to be used for the management of unexpected errors.
The good news is that there is a feature in .NET for solving exactly your
type of problem - delegates/events.

If I understand you right, the following is true of your app - the GUI uses
DTSCode which then uses/calls RemoteSQLServer (excuse my naming).

What you might want to do is create a public event in DTSCode, and when
constructing DTSCode objects from the GUI, 'tell' the DTSCode event that the
GUI 'is interested' to know when the public event in the DTSCode occurs.
Events also allow the passing of information, so your command line messages
can be sent from the DTSCode to the GUI, which in turn can display the
messages on the GUI screen.

If on the other hand you don't have direct access to DTSCode sources, you
could write your own DTSCode wrapper class that wraps the DTSCode
functionality, but which also declares/generates the event when/where
required. In this case your GUI will declare an interest in the public event
of the DTS code wrapper.

Have a look at the following link(s) for examples of this
http://msdn.microsoft.com/library/de...tsTutorial.asp
http://www.codeproject.com/csharp/delegates-part1.asp

HTH,
Patrick
"Chris" wrote:
Hi,

I have an application that contains a class library as another project.
The application basically executes DTS packages on a remote SQL Server.

This works great.

However I want to add some code that will allow the class executing the
current DTS package to send back messages to the main form of the application.

I have tried using throw new system.exception ("message") this only works
when an exception has occured.

The DTS code I use was taken from the net and has on progress, on error, on
start, on finish events that do a console.writeline.
Instead I would like the message not to go to the console but sent out to a
form label in the application.

I don't want to have to necessarily call an exception as this will cause me
to drop out of the code which is in fact working perfectly fine.

thank you,

Chris

Nov 22 '05 #3

P: n/a
Hi Chris,

Exceptions must never be (mis)used to control normal program behaviour -
they are only ever meant to be used for the management of unexpected errors.
The good news is that there is a feature in .NET for solving exactly your
type of problem - delegates/events.

If I understand you right, the following is true of your app - the GUI uses
DTSCode which then uses/calls RemoteSQLServer (excuse my naming).

What you might want to do is create a public event in DTSCode, and when
constructing DTSCode objects from the GUI, 'tell' the DTSCode event that the
GUI 'is interested' to know when the public event in the DTSCode occurs.
Events also allow the passing of information, so your command line messages
can be sent from the DTSCode to the GUI, which in turn can display the
messages on the GUI screen.

If on the other hand you don't have direct access to DTSCode sources, you
could write your own DTSCode wrapper class that wraps the DTSCode
functionality, but which also declares/generates the event when/where
required. In this case your GUI will declare an interest in the public event
of the DTS code wrapper.

Have a look at the following link(s) for examples of this
http://msdn.microsoft.com/library/de...tsTutorial.asp
http://www.codeproject.com/csharp/delegates-part1.asp

HTH,
Patrick
"Chris" wrote:
Hi,

I have an application that contains a class library as another project.
The application basically executes DTS packages on a remote SQL Server.

This works great.

However I want to add some code that will allow the class executing the
current DTS package to send back messages to the main form of the application.

I have tried using throw new system.exception ("message") this only works
when an exception has occured.

The DTS code I use was taken from the net and has on progress, on error, on
start, on finish events that do a console.writeline.
Instead I would like the message not to go to the console but sent out to a
form label in the application.

I don't want to have to necessarily call an exception as this will cause me
to drop out of the code which is in fact working perfectly fine.

thank you,

Chris

Nov 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.