PC Review


Reply
Thread Tools Rate Thread

Can't get Assembly.LoadFrom to work

 
 
Brad Wood
Guest
Posts: n/a
 
      28th Dec 2004
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...
 
Reply With Quote
 
 
 
 
Daniel Moth
Guest
Posts: n/a
 
      28th Dec 2004
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
--
http://www.danielmoth.com/Blog/


"Brad Wood" <bradley_.wood_@ndsu_.edu> wrote in message
news:(E-Mail Removed)...
>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...



 
Reply With Quote
 
Brad Wood
Guest
Posts: n/a
 
      28th Dec 2004
Daniel Moth wrote:
> 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...
 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      28th Dec 2004
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/...rch+this+group

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Brad Wood" <bradley_.wood_@ndsu_.edu> wrote in message
news:%(E-Mail Removed)...
> Daniel Moth wrote:
>> 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...



 
Reply With Quote
 
Brad Wood
Guest
Posts: n/a
 
      28th Dec 2004
Daniel Moth wrote:
> 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/...rch+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?
 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      29th Dec 2004
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
--
http://www.danielmoth.com/Blog/


"Brad Wood" <bradley_.wood_@ndsu_.edu> wrote in message
news:(E-Mail Removed)...
> Daniel Moth wrote:
>> 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/...rch+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?



 
Reply With Quote
 
Brad Wood
Guest
Posts: n/a
 
      29th Dec 2004
Daniel Moth wrote:
> GetType(SqlServerCe.SqlCeCommand).Assembly.GetName().Version.ToString()


Very good.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unload an Assembly loaded via Assembly.LoadFrom() GD Microsoft Dot NET Compact Framework 4 10th Aug 2006 05:12 AM
Assembly.LoadFrom loading a .net 2.0 assembly from a 1.1 app Jeremy Chapman Microsoft Dot NET Framework 1 28th Jun 2006 12:19 AM
Diif Assembly.Load and Assembly.LoadFrom =?Utf-8?B?R3VqanU=?= Microsoft VB .NET 1 22nd Jul 2005 10:54 AM
Restricting access to Assembly.LoadFrom call within an assembly based on strong names Nicholas Paldino [.NET/C# MVP] Microsoft C# .NET 3 9th Dec 2003 09:32 PM
Re: AxImporter, Assembly.LoadFrom(), Assembly.GetTypes() Nicholas Paldino [.NET/C# MVP] Microsoft C# .NET 3 10th Jul 2003 03:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:54 PM.