?
Solved

really easy question about interfaces and assemblies

Posted on 2003-02-23
4
Medium Priority
?
265 Views
Last Modified: 2012-05-04
I am trying to do such a basic thing.  I have written an interface and I have a class that implements the interface.  The interface is defined in COSPPanels assembly, and the class that is implementing the interface is defined in the assembly COSPDialogs.  

Here is my interface:

using System;

namespace COSPPanels
{
   public interface EnableNotify
   {
     void setEnable( bool value );
   }
}

And here is the main line in my implementing class:
using COSPPanels;

namespace COSPDialogs
{
   public class BaseDialog : System.Windows.Forms.Form,
         COSPPanels.EnableNotify, ICloneable

And I have a reference to COSPPanels in my COSPDialogs assembly.  But I always get the following error when I build my COSPDialogs assembly:

C:\cosp_ui_solution\cosp_ui\WindowsApplication1\bin\Debug\COSPDialogs.dll Referenced class 'COSPDialogs.BaseDialog' has base class or interface 'COSPInterfaces.EnableNotify' defined in an assembly that is not referenced.  You must add a reference to assembly 'COSPInterfaces'.


But I have a reference to the assembly with the interface defined!

What can be wrong?  What else can I do to write and use an interface?  

If I add a dummy class to the assembly with the interface, and I make an instance of that class, it works fine.  The problem only shows up when I implement the interface.  I noticed I get the error message twice. If I add a reference to the main application project, one of the two errors goes away.  But the main application has no knowledge of the interface. If I dont implement the method the interface declares, then I get an error about the missing implementation, and about the reference not found. So it seems to be reading the interface correctly and the system expects to see my class implementing the interface expected.

thanks
Bryan

0
Comment
Question by:bryanwells
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Accepted Solution

by:
Kevinlin earned 300 total points
ID: 8006191
Have u put "using COSPPanels;" in ur implementing class file?

eg.
using COSPPanels;
namespace COSPDialogs
{
  public class BaseDialog : System.Windows.Forms.Form,
        COSPPanels.EnableNotify, ICloneable
...

If not, then it should be the problem.
0
 

Author Comment

by:bryanwells
ID: 8007744
Yes, I did put using COSPPanels in my dialog class.

I was begining to think that interfaces behave differently than classes as far as assemblies go.  Do interfaces end up in a DLL the same way as a class? If I make an assembly that only contains interfaces, do I still get a DLL built?  In C++, I would get only an ".h" file which would not end up in a library.  But C# does not have include files or include paths.
0
 

Author Comment

by:bryanwells
ID: 8007846
I tried creating a totally separate project with nothing but the interface definition.  I still get the same error message (twice).  Then I tried adding a "real" class and making an instance of that class in my dialog.  This worked fine, as long as I dont try and implement the interface.  So I know my COSPDialogs package has a valid reference to the COSPPanels assembly.  

I ran ILDASM on the dll with my interface, and it shows that the "real" class extends System.Object, and the interface does not extend anything and is public abstract.


If I drill into the method using ILDASM, I see the following:

.method public hidebysig newslot virtual abstract
        instance void  setEnable(bool 'value') cil managed
{
} // end of method EnableNotify::setEnable


Is that what you would expect to see? what does hidebysig mean?

0
 

Author Comment

by:bryanwells
ID: 8007869
What is interesting is that I added a reference to my COSPPanels assembly in my main application project, and one of the two errors went away.  So it appears that the assembly of the main application needs a reference to the dll as well as the assembly that is actually implementing the interface.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question