How determine location of Microsoft.Basic.dll?

  • Thread starter Thread starter Alexander Baranovsky
  • Start date Start date
A

Alexander Baranovsky

Hello friends,

How I can determine full path of Microsoft.Basic.dll?

Thanks,

Alexander
 
Alexander Baranovsky said:
How I can determine full path of Microsoft.Basic.dll?

\\\
Imports System.IO
Imports System.Reflection
..
..
..
For Each asm As [Assembly] In AppDomain.CurrentDomain.GetAssemblies()
If Path.GetFileName(asm.Location) = "microsoft.visualbasic.dll" Then
MsgBox(asm.Location)
Exit For
End If
Next asm
///
 
Thank you, but this code will return

"microsoft.visualbasic.dll"

not expected something like

"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Microsoft.VisualBasic.dll"

Alexander

Herfried K. Wagner said:
Alexander Baranovsky said:
How I can determine full path of Microsoft.Basic.dll?

\\\
Imports System.IO
Imports System.Reflection
.
.
.
For Each asm As [Assembly] In AppDomain.CurrentDomain.GetAssemblies()
If Path.GetFileName(asm.Location) = "microsoft.visualbasic.dll" Then
MsgBox(asm.Location)
Exit For
End If
Next asm
///
 
Alexander,
In addition to the other comments:


Short answer: Its in the GAC.


Long answer: Use code similar to:

Dim type As type = GetType(Microsoft.VisualBasic.Collection)
Debug.WriteLine(type.Assembly.Location)

However be aware its in the GAC & you really shouldn't rely on the disk
location as the GAC can keep multiple versions of the same assembly.

NOTE: Microsoft.VisualBasic.Collection is a type that I know is currently
(.NET 1.0 & 1.1) in the Microsoft.VisualBasic.dll, the above only works for
types that you know are in the specific assembly...

--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


| Hello friends,
|
| How I can determine full path of Microsoft.Basic.dll?
|
| Thanks,
|
| Alexander
|
|
|
 
Thank you.
Dim type As type = GetType(Microsoft.VisualBasic.Collection)
Debug.WriteLine(type.Assembly.Location)

Alas, this solution does not work for me because I want to dynamically load
the Microsoft.VisualBasic.dll assembly by means of Assembly.LoadFrom method
at run-time. (I'm creating a VB.NET interpreter in C# and I would not like
to use a static reference on Microsoft.VisualBasic.dll in the application).

Alexander

"Jay B. Harlow [MVP - Outlook]" <[email protected]>
ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
Alexander,
In addition to the other comments:


Short answer: Its in the GAC.


Long answer: Use code similar to:

Dim type As type = GetType(Microsoft.VisualBasic.Collection)
Debug.WriteLine(type.Assembly.Location)

However be aware its in the GAC & you really shouldn't rely on the disk
location as the GAC can keep multiple versions of the same assembly.

NOTE: Microsoft.VisualBasic.Collection is a type that I know is currently
(.NET 1.0 & 1.1) in the Microsoft.VisualBasic.dll, the above only works for
types that you know are in the specific assembly...

--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


| Hello friends,
|
| How I can determine full path of Microsoft.Basic.dll?
|
| Thanks,
|
| Alexander
|
|
|
 
Alexander,
As I stated, Microsoft.VisualBasic.dll is in the GAC, you don't need to know
where it is on the disk!

To dynamically load it simply use Assembly.Load or
Assembly.LoadWithPartialName:

http://msdn.microsoft.com/library/d...lrfSystemReflectionAssemblyClassLoadTopic.asp

http://msdn.microsoft.com/library/d...tionAssemblyClassLoadWithPartialNameTopic.asp

Something like:

// C# sample
System.Reflection.Assembly vb =
System.Reflection.Assembly.Load("Microsoft.VisualBasic, Version=7.0.5000.0,
Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a");


--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


| Thank you.
|
| > Dim type As type = GetType(Microsoft.VisualBasic.Collection)
| > Debug.WriteLine(type.Assembly.Location)
|
| Alas, this solution does not work for me because I want to dynamically
load
| the Microsoft.VisualBasic.dll assembly by means of Assembly.LoadFrom
method
| at run-time. (I'm creating a VB.NET interpreter in C# and I would not like
| to use a static reference on Microsoft.VisualBasic.dll in the
application).
|
| Alexander
|
| "Jay B. Harlow [MVP - Outlook]" <[email protected]>
| ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
| | > Alexander,
| > In addition to the other comments:
| >
| >
| > Short answer: Its in the GAC.
| >
| >
| > Long answer: Use code similar to:
| >
| > Dim type As type = GetType(Microsoft.VisualBasic.Collection)
| > Debug.WriteLine(type.Assembly.Location)
| >
| > However be aware its in the GAC & you really shouldn't rely on the disk
| > location as the GAC can keep multiple versions of the same assembly.
| >
| > NOTE: Microsoft.VisualBasic.Collection is a type that I know is
currently
| > (.NET 1.0 & 1.1) in the Microsoft.VisualBasic.dll, the above only works
| for
| > types that you know are in the specific assembly...
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > T.S. Bradley - http://www.tsbradley.net
| >
| >
| > | > | Hello friends,
| > |
| > | How I can determine full path of Microsoft.Basic.dll?
| > |
| > | Thanks,
| > |
| > | Alexander
| > |
| > |
| > |
| >
| >
|
|
 
If you really want to use Assembly.LoadFrom, given that the
Microsoft.VisualBasic.dll is in the .NET Framework folder, you can get the
folders of .NET Frameworks using the registry entry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework

But I would use Jay's approach, using Assembly.Load and the full qualified
assembly name.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
// C# sample
System.Reflection.Assembly vb =
System.Reflection.Assembly.Load("Microsoft.VisualBasic, Version=7.0.5000.0,
Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a");

I'm in a similar situation, where I want to be able to load an assembly
given just the file name of the .dll file. LoadPartialWithName() currently
works for what I need, but it is marked obsolete. Is there an alternative
that will work with just a file name.

Note: The CodeDomProvider has this functionality, because when I call
CompileAssemblyFromSource, I've only given it file names of references, not
fully qualified names, (through the CompilerParameters.ReferencedAssemblies
member) and yet it still resolves the references sufficiently. I want to be
able to do the same thing.

Brian.
 
Brian,
Not sure how it does it.

I suspect that the CodeDomProvider is based on LoadWithPartialName, or more
then likely they are both based on some, possibly internal, API.

Then again what is Reflector using to display assemblies in its "Assembly
Cache" dialog? Is it looking directly into \Windows\Assembly? or is there
some obscure Framework object that provides a list of the Assemblies in the
GAC?

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


|> // C# sample
| > System.Reflection.Assembly vb =
| > System.Reflection.Assembly.Load("Microsoft.VisualBasic,
Version=7.0.5000.0,
| > Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a");
|
| I'm in a similar situation, where I want to be able to load an assembly
| given just the file name of the .dll file. LoadPartialWithName() currently
| works for what I need, but it is marked obsolete. Is there an alternative
| that will work with just a file name.
|
| Note: The CodeDomProvider has this functionality, because when I call
| CompileAssemblyFromSource, I've only given it file names of references,
not
| fully qualified names, (through the
CompilerParameters.ReferencedAssemblies
| member) and yet it still resolves the references sufficiently. I want to
be
| able to do the same thing.
|
| Brian.
|
|
 
Back
Top