PC Review


Reply
Thread Tools Rate Thread

Assembly.GetTypes Exception

 
 
Dan Holmes
Guest
Posts: n/a
 
      27th Nov 2007
Assembly a =
Assembly.LoadFrom(@"c:\sandbox\iaf.net\serverinstall\IVS.WMS.Category.Server.dll");
Type []t = a.GetTypes();

The GetTypes fails with this message:

"System.TypeLoadException: Could not load type
'IVS.WMS.Product.ICategoryService' from assembly
'IVS.WMS.Category.Common, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null'."

What i don't get is that the interface it says it can't load isn't used
in the code being loaded. To make it more confusing
IVS.WMS.Category.Common has an interface of that name.

Ideas?

dan
 
Reply With Quote
 
 
 
 
Lasse Vågsæther Karlsen
Guest
Posts: n/a
 
      30th Nov 2007
Dan Holmes wrote:
> Assembly a =
> Assembly.LoadFrom(@"c:\sandbox\iaf.net\serverinstall\IVS.WMS.Category.Server.dll");
>
> Type []t = a.GetTypes();
>
> The GetTypes fails with this message:
>
> "System.TypeLoadException: Could not load type
> 'IVS.WMS.Product.ICategoryService' from assembly
> 'IVS.WMS.Category.Common, Version=1.0.0.0, Culture=neutral,
> PublicKeyToken=null'."
>
> What i don't get is that the interface it says it can't load isn't used
> in the code being loaded. To make it more confusing
> IVS.WMS.Category.Common has an interface of that name.
>
> Ideas?
>
> dan


Are you sure your dll containing the interface you claim is being used
is the same as the one being referenced?

I've seen this problem in the following scenario:

1. application references and uses code from dll A version 1
2. application also references and uses code from dll B
3. dll B references dll A version 2, but no code that would use that dll
is actually being called, so should not be a problem
4. application is only shipped with dll A version 1 (but shouldn't be a
problem)

unless... you start itering with reflection and GetTypes()... then you
might end up trying to load a referenced assembly that isn't actually
present, which would otherwise not be a problem since no code from that
assembly is actually needed to run your application.

So to start with, I would check the references and see which versions
they add. Also note that I think VS2005 lists the version of the dll
found in the property window for a reference, instead of the version the
project actually references. Ie. if the project added the reference to
version 1.0.0.0 of the dll, and you later replace the dll with version
1.0.0.1, the project will reference 1.0.0.0, but the property window
might show 1.0.0.1. I'm not entirely sure about this but I've always
found that removing and readding the references fixes these problems.

--
Lasse Vågsæther Karlsen
private.php?do=newpm&u=
http://presentationmode.blogspot.com/
 
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
Using reflection and assembly.getTypes() FBU Microsoft Dot NET Compact Framework 2 7th Aug 2004 11:37 PM
URGENT : GetTypes in assembly?? aerge calderara Microsoft Dot NET 2 9th Jan 2004 02:03 PM
The difference between GetTypes() and GetExportedTypes() methods of the Assembly class. Abdessamad Belangour Microsoft C# .NET 1 1st Dec 2003 09:07 PM
Problem with dinamically loaded assembly, (getTypes, createInstance... not working) Stephane Belzile Microsoft Dot NET 0 23rd Sep 2003 08:12 PM
Re: AxImporter, Assembly.LoadFrom(), Assembly.GetTypes() Nicholas Paldino [.NET/C# MVP] Microsoft C# .NET 3 10th Jul 2003 02:48 PM


Features
 

Advertising
 

Newsgroups
 


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