GetType on a Referenced Assemble without hardcoding assembly loadfrom values
-
Hello, I have a problem : I have a class Library (FooClasses) which has a refence to a second set of classes (Foo2Classes) In Foo2Classes is a class (Foo3) I have the following code Imports System.Reflection Imports Foo2Classes Public Class FooClass Protected Sub SomeSub() Dim T as Type T = Type.GetType("Foo2Classes.Foo3") I have also tried T = Type.GetType("FooClasses.Foo2Classes.Foo3") End Sub End Class The T cant be found by reflection so I am assuming I must load the Foo2Classes assembly first. If this is the case how can I load the assembly without using a hardcoded path in a loadfrom. What I want to be able to do is to use the fact that it has been referenced in my FooClasses. Can you get the path from the assembly reference , rather than hardcoding it OR putting in a partially qualified pathname ie "/subdir/Foo2Classes.dll" Thanks Martin
life is a bowl of cherries go on take a byte
-
Hello, I have a problem : I have a class Library (FooClasses) which has a refence to a second set of classes (Foo2Classes) In Foo2Classes is a class (Foo3) I have the following code Imports System.Reflection Imports Foo2Classes Public Class FooClass Protected Sub SomeSub() Dim T as Type T = Type.GetType("Foo2Classes.Foo3") I have also tried T = Type.GetType("FooClasses.Foo2Classes.Foo3") End Sub End Class The T cant be found by reflection so I am assuming I must load the Foo2Classes assembly first. If this is the case how can I load the assembly without using a hardcoded path in a loadfrom. What I want to be able to do is to use the fact that it has been referenced in my FooClasses. Can you get the path from the assembly reference , rather than hardcoding it OR putting in a partially qualified pathname ie "/subdir/Foo2Classes.dll" Thanks Martin
life is a bowl of cherries go on take a byte
MartyK2007 wrote:
If this is the case how can I load the assembly without using a hardcoded path in a loadfrom.
Use the
Path
class to build the fully qualified path to the assembly.Dim fullPath As String = Path.Combine(Application.StartupPath, "myAssembly.dll")
MartyK2007 wrote:
Can you get the path from the assembly reference
The reference only exists to keep the compiler happy. They don't exist at runtime.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
MartyK2007 wrote:
If this is the case how can I load the assembly without using a hardcoded path in a loadfrom.
Use the
Path
class to build the fully qualified path to the assembly.Dim fullPath As String = Path.Combine(Application.StartupPath, "myAssembly.dll")
MartyK2007 wrote:
Can you get the path from the assembly reference
The reference only exists to keep the compiler happy. They don't exist at runtime.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008Hello, yes your assuming the assembly is in the startup path - is that a valid assumpton? I may have a solution though I think I can get the fully qualified name of the assembly from the current executing assemblies refernce collection. This value doest have a path in it at all. from there I can issue am assembly load using the fully qualified Name and it seems to get it. I am testing to see if this happens in all cases thanks Martin
life is a bowl of cherries go on take a byte
-
Hello, yes your assuming the assembly is in the startup path - is that a valid assumpton? I may have a solution though I think I can get the fully qualified name of the assembly from the current executing assemblies refernce collection. This value doest have a path in it at all. from there I can issue am assembly load using the fully qualified Name and it seems to get it. I am testing to see if this happens in all cases thanks Martin
life is a bowl of cherries go on take a byte
MartyK2007 wrote:
yes your assuming the assembly is in the startup path - is that a valid assumpton?
No, it's not, and it wasn't meant to be an assumption. I gave you an example of building a path from a well-known starting point.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
MartyK2007 wrote:
yes your assuming the assembly is in the startup path - is that a valid assumpton?
No, it's not, and it wasn't meant to be an assumption. I gave you an example of building a path from a well-known starting point.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008ok no offense meant. The issue with that is that your dll's have to be below your app.startup which in my case may not be relevent I think the fully qualified name though has legs - still testing thanks for your help Martin
life is a bowl of cherries go on take a byte
-
ok no offense meant. The issue with that is that your dll's have to be below your app.startup which in my case may not be relevent I think the fully qualified name though has legs - still testing thanks for your help Martin
life is a bowl of cherries go on take a byte
There's more than one place to put .DLL's. GetFolderPath[^] and the Environment.SpecialFolder Enumeration[^]
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008