paulsinnema

Hi,

I've got some code I would like to centralize into a separate Project but am running into a CS0115 ''function' : no suitable method found to override' Error.

This is what I've done.

  • I Have a Project called AutoEQ and one called Library.
  • In the AutoEQ Project a Class from the Library is inherited.
  • In the AutoEQ Class an 'override' is done for the Method 'Init' of the base class.
  • Both Projects are in 1 Solution.

When compiling I get the error mentioned above. Below is the (stripped) Code

I think I need another construct but don't know which. Who can help me on my way.

Thanks, Paul.


Re: Visual C# Language Centralizing code problem

OmegaMan

Does the other partial class code have the same namespace in the other file(s) as what is shown in your example





Re: Visual C# Language Centralizing code problem

paulsinnema

Hi OmegaMan,

Thanks for replying so quickly.

Yes. both have the same Namespace. The Code does compile as soon as take the Class CMCPlugin into the AutoEQ Project. When I move it to the Library Project I get the mentioned Error.

Paul.





Re: Visual C# Language Centralizing code problem

IsshouFuuraibou

What happens when you change:
public partial class MainInterface : CMCPlugin
to
public partial class MainInterface : Library.CMCPlugin

Solution is only a grouping of projects, they are allowed to have different namespaces.

Namespaces are the borders between code, CMCPlugin wouldn't have a reference in AutoEQ unless you provide the namespace Library (either by Library.CMCPlugin or by using Library; at the top)





Re: Visual C# Language Centralizing code problem

paulsinnema

Hi IshouFuuraibou,

Good thinking but... the problem remains the same and I had already put in the 'using Library'. I believe it to be something fundamental. If Namespaces are borders for Classes then it must be something in he Settings of the Project(s) properties, because the 'using' is there and the 'Library.CMCPlugin' doesn't help. Do you agree

What's realy frustrating here is that I've got about 5 Books covering .NET (3 come from Microsoft Press). I've bought the Visual Studio 2005 Professional Suite with all the local and online help available. But I can't find anything on this, relatively simple, Subject in either of them. Can't even find anything with Google and friends. I'll get there in the end but these things should be clearly written down somewhere because they are sooooo fundamental.

Or maybe it's just a fried gellpack (oops been watching too much Star Trek lately, no no..... I'm not a Trekky)

Paul.





Re: Visual C# Language Centralizing code problem

boban.s

There is two two posibilities:
First as already mentioned that the namespace is not rigth, i don't know did you have using statement for Library namespace in AutoEQ project file.
Second is that you probably have other errors, not just this, which are in Library Project and you still don't have successfull build of Library project that includes virtual method.




Re: Visual C# Language Centralizing code problem

paulsinnema

Boban,

Thanks for thinking with me.

No, The Library builds fine:

Code Snippet

------ Build started: Project: Library, Configuration: Debug Any CPU ------

Library -> C:\Projects\Library\Library\bin\Debug\Library.dll

========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

There also is a reference added in the AutoEQ Project. But the Build of the AutoEQ Project goes wrong:

Code Snippet

------ Build started: Project: Library, Configuration: Release Any CPU ------

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:TRACE /reference:..\..\SharpDevelopment2\SharpLibrary\bin\Release\SharpLibrary.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Design.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.Design.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:obj\Release\Interop.MediaCenter.dll /debug:pdbonly /optimize+ /out:obj\Release\Library.dll /resource:obj\Release\Library.CMCPlugin.resources /target:library CMCPlugin.cs Properties\AssemblyInfo.cs Properties\Settings.Designer.cs

Compile complete -- 0 errors, 0 warnings

Library -> C:\Projects\Library\Library\bin\Release\Library.dll

------ Build started: Project: AutoEQ, Configuration: Release Any CPU ------

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:TRACE /reference:C:\Projects\Library\Library\bin\Release\Library.dll /reference:..\..\..\SharpDevelopment2\SharpLibrary\bin\Release\SharpLibrary.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Design.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.Design.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:obj\Release\Interop.CDMANAGERLib.dll /reference:obj\Release\Interop.MediaCenter.dll /debug:pdbonly /keyfile:TemplateKey.snk /optimize+ /out:obj\Release\AutoEQ.dll /resource:obj\Release\AutoEQ.MainInterface.resources /resource:obj\Release\AutoEQ.Properties.Resources.resources /target:library CPreset.cs MainInterface.cs MainInterface.Designer.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs

C:\Projects\AutoEQ\Auto EQ Solution\Auto EQ Project\MainInterface.cs(112,30): error CS0115: 'AutoEQ.MainInterface.Init(MediaCenter.MCAutomation)': no suitable method found to override

Compile complete -- 1 errors, 0 warnings

========== Build: 1 succeeded or up-to-date, 1 failed, 0 skipped ==========

This is what the Project Explorer looks like:

http://www.paulsinnema.net/images/MS/ProjectExplorer.gif

Paul.





Re: Visual C# Language Centralizing code problem

decyclone

Hi paul,

in line

public partial class MainInterface : CMCPlugin


right click on the CMCPlugin, and click 'Go to definition' in the context menu. And see where it takes you.

Also add a function say Foo() to the CMCPlugin, and try calling it from MainInterface's method using base.Foo(), and see if IntelliSence supports it and it compiles.

Check it and tell me what happened.





Re: Visual C# Language Centralizing code problem

andypai

Hi Paul,

Did you try this... Comment the method in the inherited class and try to use intellisense to generate it for you...

if you type public override the IDe should lit out a list of methods that can be overridden..






Re: Visual C# Language Centralizing code problem

paulsinnema

decyclone wrote:
Hi paul,

in line

public partial class MainInterface : CMCPlugin


right click on the CMCPlugin, and click 'Go to definition' in the context menu. And see where it takes you.

Also add a function say Foo() to the CMCPlugin, and try calling it from MainInterface's method using base.Foo(), and see if IntelliSence supports it and it compiles.

Check it and tell me what happened.

decyclone

I'll try and do this tonight.

Paul.





Re: Visual C# Language Centralizing code problem

paulsinnema

andypai wrote:

Hi Paul,

Did you try this... Comment the method in the inherited class and try to use intellisense to generate it for you...

if you type public override the IDe should lit out a list of methods that can be overridden..

Andy,

I tried that one already with the same result.

Paul.





Re: Visual C# Language Centralizing code problem

micvos

Try giving your library a strong name (it doesn't have to the same key file as the main application).




Re: Visual C# Language Centralizing code problem

paulsinnema

Micvos,

Thanks for the reply. Could you be a bit more specific. What do you mean with a 'Strong Name' and how do I do that

Paul.





Re: Visual C# Language Centralizing code problem

micvos

Give it a key just like the main application (there you called it TemplateKey.snk)




Re: Visual C# Language Centralizing code problem

paulsinnema

micvos,

Still don't quite understand what you mean but I'll take a look at it when I come home in about 2 hours.

Paul.