Can't get Assembly.LoadFrom to work

  • Thread starter Thread starter Brad Wood
  • Start date Start date
B

Brad Wood

I need to programatically determine the version of a .dll. Whenever I
call Assembly.LoadFrom I get an IOException. File.Exists tells me that
the path I pass to LoadFrom is correct.
In a previous post, someone who had this problem was able to fix it by
installing SP2 of the framework, but this didn't work for me...
 
I've had no problem with Assembly.LoadFrom and in fact also use it for the
version retrieval. The only time when it works differently is when the dll
is in the GAC, is that the case in your scenario?

Also try a simple repro scenario with some other dll to see if that works.
Does referencing/not referencing the dll from the exe make a difference?

Cheers
Daniel
 
Daniel said:
The only time when it works differently is when the dll
is in the GAC, is that the case in your scenario?
I'm sure one of the .dlls I'm trying to access is in the GAC, the other
I'm not sure of, but I imagine so (one of the Sql Server .dlls).

I've tried to figure out how to access information about assemblies in
the GAC to no avail...
 
Daniel said:
Without looking into why you are explicitly loading framework dlls...

...a quick search shows this has been discussed before. Look at the top
thread:
http://groups-beta.google.com/group...adFrom+gac&qt_g=1&searchnow=Search+this+group

So I need to know the version (part of the full strong name) in order to
load a GAC .dll in order to get it's version?

I want to programatically get the version of Sql Server CE and the
OpenNETCF framework. Is there any way to do this?
 
Are you referencing the assemblies in the question?

If you are, you could do something like this (for C# replace GetType with
typeOf):
GetType(SqlServerCe.SqlCeCommand).Assembly.GetName().Version.ToString()

Also note that the SDF should offer its version number via the EnvironmentEx
class in v1.3...

Cheers
Daniel
 
Back
Top