How to use interfaces properly...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Ok, I have been testing some things and now I have questions about it. I
created a dll assembly that contains just one interface (called
ITestInterface), which in turn just has one string property called TestName.
I built that project and then closed it. Then, I created a windows forms
project and added a reference to that assembly (it's named MyInterfaceTest).
Now, before I did anything else, I ran the project and a blank form came up.
That was as expected. Then I added the "Implements
MyInterfaceTest.ITestInterface" line and it added the property code for me.
I built the project again and it ran fine. Then I changed the "Copy Local"
property on the reference to "false". I ran the project again and it gave me
an error:

-----------------------
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in
Unknown Module.

Additional information: File or assembly name MyInterfaceTest, or one of its
dependencies, was not found.
-----------------------


Ok, so now I'm kind of confused. Does each application that implements an
interface have to have its own copy of the dll that contains the interface?
I'm asking this mainly because I'm working on building an app that uses a
plugin architecture, and I am having trouble figuring out how to set up
references that will work during development, but will also let the plugin
developer drop his executable and associated files into the main
application's plugins folder without breaking it. Can anyone explain how
this should be done? Thanks!
 
You do not need to have your own copy of the assembly. But wherever it is,
it should be reachable by te code that needs it. You might want to load it
at runtime or install it into the GAC.
 
Ok, so what exactly was breaking in the example I gave? The files didn't
move. All I did was change the Copy Local value to false. Why did that
cause a problem?
 
When a change is made to a property of the project, the project is rebuilt
before running.
When the project is being built, the output directory (bin) is cleared. And
since the 'Copy Local' was set to false, the library containing the
interface was not copied back into the output directory leading to it not
being found at runtime.
 
Back
Top