I'll look at it further tomorrow, but the "more true" scenario is this:
We have an app (C) that gets the interface from a separate assembly (A).
We have a plug in (B) that also gets the interface from A.
The app loads a class from the plug in. This class exposes a "GetForm"
method. The Form returned from this inherits Form plus implements IPlugIn.
It can be used as a Form, as we're able to display it just fine, however it
just doesn't like that interface. I can get the interface by name, so the
class definitely implements it, but it won't cast. It's like it sees it as
a separate interface, just with coincidentally the same interface name.
-Chris
> The oversimplified code works fine, assembly B can be loaded through
> reflection (Assembly.LoadFile for example) and then class PlugIn can
[quoted text clipped - 65 lines]
>>
>>-Chris
Peter Duniho - 26 Sep 2007 03:33 GMT
> I'll look at it further tomorrow, but the "more true" scenario is this:
>
[quoted text clipped - 7 lines]
> class definitely implements it, but it won't cast. It's like it sees it as
> a separate interface, just with coincidentally the same interface name.
I really have no practical experience with this sort of thing. However,
the last time something like this came up in this newsgroup, it turned
out to be an issue where the class being used for the cast was just as
you describe: it had the same name, but was from a completely different
assembly.
You should double-check to make sure that the interface that all code is
using is the same interface. That is, all of the code referencing the
interface uses the same assembly, compiled from a single source. The
problem _sounds_ like you may have an issue where you're getting the
interface from multiple places.
Pete
sloan - 26 Sep 2007 07:49 GMT
I concur.
I've seen that issue as well, where it was the same name, but actually
different classes.
Can you get some extra info about it , using something like ... GetType()
and the full AssemblyName or something like that
(its late and I'm going from memory)
>> I'll look at it further tomorrow, but the "more true" scenario is this:
>>
[quoted text clipped - 22 lines]
>
> Pete
<ctacke/> - 26 Sep 2007 17:14 GMT
Yep, that was it. The project was modified by another developer to put the
plug-in in a separate folder, so it then copied the interface-holding
assembly there too, causing the two projects to be using separate assemblies
for the physical reference.
Adding the interface assembly to the GAC solved the problem.

Signature
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
>I concur.
>
[quoted text clipped - 31 lines]
>>
>> Pete
sloan - 26 Sep 2007 18:17 GMT
GAC'ing the A.dll seems like overkill.
Can't you just put the compiled version of A.dll somewhere that both
projects can reference?
Either way, you got it figure out.
> Yep, that was it. The project was modified by another developer to put
> the plug-in in a separate folder, so it then copied the interface-holding
[quoted text clipped - 39 lines]
>>>
>>> Pete