Solved

Can you determine a procedure's address from its name?

Posted on 2004-09-27
4
189 Views
Last Modified: 2010-04-23
I am interested in using a method's name (ie MyFunc) to find its address. I know you can use CallByName to actually call the function, but I just want to get its address. I have a delegate and I want to assign it the AddressOf "MyFunc".
0
Comment
Question by:BASESLydia
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 125 total points
ID: 12159664
u can use the GetAssemblyByName method

Imports System
Imports System.Reflection
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic

Public Class AssemblyName_GetAssemblyName
   
   Public Shared Sub Main()
     

      ' Get the type of 'System.Object'.
      Dim myType As Type = GetType(System.Object)
     
      ' Get the path of 'System.dll'.
      Dim system As String = Regex.Replace(myType.Assembly.CodeBase, "mscorlib.dll", "System.dll")
      system = Regex.Replace(system, "file:///", "")
     
      ' Get the assembly information and display to the console.
      Dim myAssemblyName As AssemblyName = AssemblyName.GetAssemblyName(system)
      Console.WriteLine(ControlChars.Cr + "Displaying the assembly information of 'System.dll'" + ControlChars.Cr)
      Console.WriteLine(myAssemblyName.ToString())
   End Sub 'Main
End Class 'AssemblyName_GetAssemblyName

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12170767
What's wrong with AddressOf?

Bob
0
 
LVL 1

Author Comment

by:BASESLydia
ID: 12170815
Unless I am using it wrong, AddressOf requires the function name be typed at runtime, you cannot use a string as a parameter. I would like to load the string name from a database and get the address from it at a runtime.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12170838
Aaah, yes, that one again.  Good luck!

Bob
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question