Hi
Is there a way that I can call a method in an EXE (managed code,
VB.NET) from a .NET DLL by passing a reference to the instance of the
EXE Multiple instances of EXE might be running and loaded in memory
and I need the DLL to invoke a method within the running instance by
passing a reference (such as the application title, window handler
etc).
In case you are wondering why the DLL is calling the EXE method and not the other way around, it is because this DLL is like a wrapper class and the method that invokes the method in the EXE is actually called from an Access VBA module.
TIA

Call EXE method from DLL
Sujithf
Hi,
There are many different ways you can accomplish this, and exactly how you go about it depends on your particular needs.
Do you need to be able to interact with a running application, or are you just looking to reuse some logic written in your VB.NET app from your access application If you are just looking to reuse application logic, then you can just add a reference to the exe to your wrapper dll (as if the exe was a dll), and you should have access to all the publicly visible types in the exe just like you would with a dll reference (in which case the exe will act just like a dll an won't actually spawn a new instance.)
If you need to interact with a running executable, then there are several other options available.
-Scott Wisniewski
RaulHD
It sounds to me like you have a model where you have 1 long lived instance of your application that needs to do work, and several other short-lived instances that will send it commands to execute and then close down.
Is this correct
Not quite.The users always launch the ClickOnce application from a URL to insure they are using the current version.
Sometimes, the URL contains additional paramaters so that they are taken directly to an area of the application.
When they open the app a second time and they already have an instance we want it to re-use the first instance but pass the paramaters from the 2nd.
I've looked at StartUpNextInstance and don't think that'll work. I think remoting might not be the way to go either.
Grumpy McNasty
My situation is this.
The user opens an instance of the application WITHOUT startup parameters. They then can open the application WITH startup parameters while the first instance is running.
I want to check if there's an instance running (already got that), and if there is, pass it the startup parameters.
Any suggestions
tmiller3
In the New() method od the application I strip the parameters from the querysting and write them to a file. Then when the StartupNextInstance is run I read the paramaters from the file and delete it.
Not pretty, but it'll work well for my situation.
beto81
How can I get remoting to work without the use of IIS or any webserver. The samples that I see have
http://localhost:<port number> to specify where the remoting objects are.
EyalRF
I would reccomend that you use .NET remoting.
You can access a sample app here:
http://www.microsoft.com/downloads/details.aspx familyid=87951CB9-5AEB-4F46-9BF0-2B3E3664BE77&displaylang=en
-Scott
mrboldt
Hi Scott,
Thanks for your reply.
I have to interact with a running executable and there might be multiple instances of the executable at any time. How can I reference a particular executable instance and call the method
I have the referencing thing, setup right now but the specs have changed which now involves calling the method from a running instance of an executable.
TIA
Michael Klucher - MSFT
Remoting also supports the use of TCP channels in addition to HTTP channels.
If you look at the 101 VB.NET samples, here:
http://www.microsoft.com/downloads/details.aspx familyid=87951CB9-5AEB-4F46-9BF0-2B3E3664BE77&displaylang=en
The "VB.NET - Advanced - Remoting - How-To TCP Remoting" sample shows how to use .NET remoting with TCP.
-Scott
ZardoS42
It sounds to me like you have a model where you have 1 long lived instance of your application that needs to do work, and several other short-lived instances that will send it commands to execute and then close down.
Is this correct
There are several other approaches besides remoting you can use to accomplish this. One method is to use MSMQ (Microsoft Message Queue). This has the advantage of already having support in the .NET Framework via the System.Messaging namespace. It does, however, have the disadvantage of requiring you to either have a shared message queue server available or to install MSMQ on all of your client machines, which may complicate your deployment. You can check out the MSDN documentation for the System.Messaging namespace here: http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemmessaging.asp.
If the deployment requirements of MSMQ will not work for you, then you can try using named pipes. These have the advantage of not requiring complex deployment. However, they have the disadvantage of not having direct .NET support, requiring you to use interop to call into the Win32 API. You can find information about the Named Pipes API here:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/ipc/base/createnamedpipe.asp
-Scott Wisniewski
Jarda Jirava
I'm looking at using the StartupNextInstance handler, but it doesn't look to promising for a click once application.
Luislcm
Symbolicly
In either case you should be able to use either MSMQ or named pipes.
-Scott