Dialog in DLL

D

Dennis

I'm just experimenting with VB.Net, so please forgive me if this
question has been asked before...

I would like to put a modal dialog in a DLL (totally separate VS
Project), and then have my application load the DLL and pop-up the
dialog.

Can anyone point me to an article that explains how to do this?

TIA,
 
L

Lloyd Sheen

Dennis said:
I'm just experimenting with VB.Net, so please forgive me if this
question has been asked before...

I would like to put a modal dialog in a DLL (totally separate VS
Project), and then have my application load the DLL and pop-up the
dialog.

Can anyone point me to an article that explains how to do this?

TIA,

What you need to do is add a reference to the DLL in your .exe project.
Then (you have to make the class that is the dialog - winform public) you
can just create the object and use ShowDialog

Hope this helps
LS
 
M

Mr. Arnold

Dennis said:
I'm just experimenting with VB.Net, so please forgive me if this
question has been asked before...

I would like to put a modal dialog in a DLL (totally separate VS
Project), and then have my application load the DLL and pop-up the
dialog.

Can anyone point me to an article that explains how to do this?

You cannot put a screen of any type in a Dynamic Link Library. The
screen will never show and the DLL will hang at that point.
 
J

Jack Jackson

You cannot put a screen of any type in a Dynamic Link Library. The
screen will never show and the DLL will hang at that point.

That is not true for .NET DLLs.
 
C

Cor Ligthert[MVP]

Dennis,

It depends what kind of dialog, however you can start with trying

dim myDialog as new System.Windows.Forms.Form
myDialog.ShowDialog

as your DLL has no reference to System.Windows.Forms you have to set that
first.

Be aware that this for sure does not work in things like a windows service

Cor
 
M

Michel Posseth [MCP]

Dennis ,,,

Just ad a windows form class to the library , note that for a modal dialog
to behave as expected by the user you should add the object pointer of the
calling form
( just add Me in the overloaded show method )

HTH

Michel
 
M

Michel Posseth [MCP]

true for VB6

:)




Mr. Arnold said:
You cannot put a screen of any type in a Dynamic Link Library. The screen
will never show and the DLL will hang at that point.
 
M

Mr. Arnold

Jack Jackson said:
That is not true for .NET DLLs.

Yes, my reference is from COM and COM+ DLLs, back in the day. But on the
other hand, there would be no way I would do something of the sort with a
..NET solution either. That is popping Windows forms from a DLL. It's
ridiculous.
 
M

Mr. Arnold

Stephany Young said:
What a load of rubbish.

What are you some kind of a nut?

All you had to say was that it was not correct and not the BS that you
posted. You suck.
 
D

Dennis

What you need to do is add a reference to the DLL in your .exe project.
Then (you have to make the class that is the dialog - winform public) you
can just create the object and use ShowDialog

Hope this helps

Thanks Lloyd (and others). That was simple enough to get working.

This method apparently binds (probably not the right terminology) the
dll to the exe at compile time. Is there a way to do this binding at
runtime in VB.Net?

In other words, what I would like to do is provide the ability for
add-ons to be used with my application. Maybe my application would have
a dialog where a user would enter the name/path to a dll, the name of
the entrypoint (that launches a dialog) in the dll, etc. Then my
application would take this info and add an item to the menu which would
call the dll's entrypoint and pop-up the dll's dialog when clicked.

I'm just experimenting to see if this can be done. I'm a retired
programmer with some time to kill. ;-)
 
S

Stephany Young

System.Reflection is your friend for this.


Dennis said:
Thanks Lloyd (and others). That was simple enough to get working.

This method apparently binds (probably not the right terminology) the
dll to the exe at compile time. Is there a way to do this binding at
runtime in VB.Net?

In other words, what I would like to do is provide the ability for
add-ons to be used with my application. Maybe my application would have
a dialog where a user would enter the name/path to a dll, the name of
the entrypoint (that launches a dialog) in the dll, etc. Then my
application would take this info and add an item to the menu which would
call the dll's entrypoint and pop-up the dll's dialog when clicked.

I'm just experimenting to see if this can be done. I'm a retired
programmer with some time to kill. ;-)
 
D

Dennis

System.Reflection is your friend for this.

Stephany,

I got it working thanks to your hint ... using LoadFrom, GetType,
MethodInfo, CreateInstance, and Invoke.

Thanks again!
 
S

Stephany Young

They be the ones!


Dennis said:
Stephany,

I got it working thanks to your hint ... using LoadFrom, GetType,
MethodInfo, CreateInstance, and Invoke.

Thanks again!

--

Dennis

***
 
H

Herfried K. Wagner [MVP]

Mr. Arnold said:
Yes, my reference is from COM and COM+ DLLs, back in the day. But on the
other hand, there would be no way I would do something of the sort with a
.NET solution either. That is popping Windows forms from a DLL. It's
ridiculous.

Why? What if you have some forms which are used by different forms, such as
a login dialog, an item selection dialog, a custom print preview dialog,
....? I think it makes perfect sense to place them in a library. However,
then I would not use late-bound access.
 
H

Herfried K. Wagner [MVP]

Michel Posseth said:
Just ad a windows form class to the library , note that for a modal
dialog to behave as expected by the user you should add the object pointer
of the calling form
( just add Me in the overloaded show method )

Not really. In most scenarios it won't work as expected any more when
passing the reference to the calling form to 'ShowDialog'.
 
M

Michel Posseth [MCP]

Huh ???

Could you give an example when not ?
cause , i have a lot of projects where we have common dialogs that are
compiled in one dll , that are used in several projects
i found that if i use the callees object pointer everything works as how i
would expect it and i have full control

I am curious where i would encounter such a problem
 
D

Dennis

Stephany,

I got it working thanks to your hint ... using LoadFrom, GetType,
MethodInfo, CreateInstance, and Invoke.

Thanks again!

Just to take this discussion a little further ... what would be the best
way to post a message back to the calling exe? For example, after the
dll did some work, what if it wanted to tell the calling exe to refresh
its window?
 

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