473,325 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Assembly.GetTypes Exception

Assembly a =
Assembly.LoadFrom(@"c:\sandbox\iaf.net\serverinsta ll\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
Nov 27 '07 #1
1 3197
Dan Holmes wrote:
Assembly a =
Assembly.LoadFrom(@"c:\sandbox\iaf.net\serverinsta ll\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
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
Nov 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Carlos G Benevides | last post by:
I have a ASP.Net web application that has two assemblies that run under com+. Under Windows 2000 the two assemblies are added to com+ automatically when instantiated from the web site. For this...
8
by: serge calderara | last post by:
Dear all, I need to be sure that a loaded assembly is implementing a particular interface. How can I do that as long as my assembly is loaded and I have the assemlby object available in...
2
by: aerge calderara | last post by:
dear all, I am using the GetTypes method of an assembly object in order to check that it implement a particular needed interface for my application. ...
1
by: Abdessamad Belangour | last post by:
Hi all, An assembly is composed of a set of modules. An Assembly and a Module classes have a GetTypes() methods. Moreover, an Assembly class has a GetExportedTypes() method. 1. This means that if...
4
by: Jonathan Roewen | last post by:
Hi I've got loading assemblies dynamically done (wasn't too difficult). Now I want to lookup a static function in the loaded assembly, and if found, return it somehow, and call it from my app. So...
1
by: Zachary Hartnett | last post by:
I was trying to write a routine this morning that would open a given assembly, walk the inheritance tree of classes in the assembly, and provide a list of classes in the assembly that inherit from...
6
by: Steve | last post by:
I'm playing with late binding and trying a very simple test to load an assembly In my "Host" application I have this code: <code> string modulePath =...
4
by: Brian Richards | last post by:
Is it possible to run code in an assembly when it's loaded? In my case I have an assembly that requires that the users path be setup correctly or GetTypes() will throw an exception. Looking for a...
7
by: Paul Hadfield | last post by:
Hi, I'm running into one problem with trying to call "Type.GetCustomAttributes(...)" on my reflected code. Basically - I can't trap my own custom attribute - I can only catch / identify system...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.