.Net calling Sub in other .Net Exe Application

How can I call a .Net application function (Sub)
(using the exe whether it is running or not)
from another .Net application?
tuchfeldAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daniel ReynoldsSoftware Applications Developer / IntegratorCommented:
You can't. You must compile those shared functions into a dll that you can then call from other applications and distribute the dll with any application that might call those functions.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
harmonoCommented:
I'm not sure if this is what you are looking for, but I hope this helps:

This runs another program I wrote in VB.NET. It only runs an .exe file.

 Try
            Dim strCommand As String
            strCommand =  ' a dos command line here that opens the file
            Shell(strCommand, AppWinStyle.NormalFocus, False)
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
the_oCommented:
Hi there
You can try the following code. If it solves your problem, be kind and reward with some points. :)
Private Sub CallOtherEXE()
        Dim strOtherPath As String = "c:\myOtherApp.exe"
        Dim newProcess As New Process()

        Dim startParams As New System.Diagnostics.ProcessStartInfo()
        startParams.FileName = strOtherPath
        startParams.WorkingDirectory = "c:"

        'You can either start the file using the StartInfo object or just the filename
        newProcess.Start(startParams)
        'newProcess.Start(strOtherPath)

        'Note that you can start any file like this and the associated application for that file
        'will be used to runn the file. This means that a .txt file will most likely be opened by
        'notepad if you have not set an alternative app to open such files

    End Sub

Open in new window

the_oCommented:
hahaha, my bad, It seems it is a bit late and I need to get some sleep.

Misread the function (sub) part. duh.
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
If you have the source code to both apps then it is possible...but there isn't anything "canned" that allows this.  You could either make the app a "single instance" app that runs the specific sub when it receives a particular command line argument, or you could setup a .Net Remoting scenario where they receive a specific command to run the sub...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.