13

There are a lot of questions floating around with this problem and i've worked through them ll with no joy.

I am receiving this error:

Method 'get_UserImageCDNUrl' in type 'App.Web.WebConfig' from assembly 'App.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

Which is really strange because I am trying to run Api.Web which has no reference to App.Web, the only thing they have in common are references to other projects (Models.Domain and Models.DTO).

I have an interface:

IResourceCompiler in an assembly "Models.Domain"

I have an abstract class which implements this interface in the same assembly (Models.Domain) called WebConfigBase

In the "App.Web" and "Api.Web" projects they each have a class called WebConfig which inherit from WebConfigBase, therefore both WebConfig classes in App and Api are implementations of IResourceCompiler.

I tried to add a property

string UserImageCDNUrl {get;}

to IResourceCompiler and added the property to WebConfigBase

public string UserImageCDNUrl 
{
    get { return ""; } 
}

so the property would be accessible to both Api and Web projects through their own WebConfig classes, and i get the exception above.

I have looked for hours to try and see why this happens with no joy.

I've cleared my Obj folders, cleaned, rebuilt, checked for any instances in GAC (there aren't any) and i'm still stuck on this.

Everything works fine until i try to add a new property to the interface (and base class)

pieperu
  • 2,662
  • 3
  • 18
  • 31

7 Answers7

8

OK, so bizarrely adding a reference to App.Web in Api.Web and removing it again has solved the issue.

I have no idea why, but it did.

I changed the version of App.Web to 1.0.0.1 and the error was still showing 1.0.0.0, which is what prompted me to do it.

I wish there was a more reasonable explanation but there isn't. Such an infuriating issue i'm just glad to be done with it.

Best of luck to anyone else who experiences this, my thought's are with you

pieperu
  • 2,662
  • 3
  • 18
  • 31
  • Weirdly enough I looked at this exact issue, and the version was correct in my case. Despite, re adding the reference did solve it. – Pedro Rodrigues Jul 30 '19 at 13:58
5

For the records, in my case this was caused by two projects referencing different versions of the same package. At least fixing this solved the issue.

Nicholas Reis
  • 118
  • 1
  • 5
2

There can be many reasons for this, all the previous answers represent a case of this problem.

What I suggest doing is:
while your program is running open Resource Monitor -> CPU tab and in the search handles input box, search for the assembly that supposedly doesn't implement that method.

In the search results you'll see the path of your assembly, and most likely the path that you see isn't the one that you expect.
Delete the assembly from this unexpected path so that the correct assembly gets loaded.

1

In many cases I become this error. It seems like Cached assembly and I found them in UserProfile.

My solution is:

  1. Save solution and close Visual Studio
  2. Delete entire folder "c:\Users(user)\AppData\Local\Microsoft\VisualStudio\14.0\ProjectAssemblies\"
  3. Start Visual Studio
  4. Work...

Hope it helps.

1

I just remove the reference of current project (which is showing error) , and add again to other project in which project this was referenced build and it start working fine.

hope this help someone.

Usman Younas
  • 1,323
  • 15
  • 21
  • 1
    +1 for pointing to the right direction, I had to also **clean** the main project and **rebuild** the referenced project **before** adding the reference to the main project again. Note that clean/rebuilding the solution or projects in a wrong order **did not** have any effect. – Bizhan Aug 21 '19 at 09:58
0

try this

public interface IResourceCompiler
{
    string UserImageCDNUrl {get;}
}

public abstract class WebConfigBase : IResourceCompiler
{
    public abstract string UserImageCDNUrl {get;}
}

public class WebConfig : WebConfigBase 
{
    public override string  UserImageCDNUrl { return "whatever you want";}
}

or that way too:

public interface IResourceCompiler
{
    string UserImageCDNUrl {get;}
}

public abstract class WebConfigBase : IResourceCompiler
{
    public virtual string UserImageCDNUrl {get { return string.empty;}}
}

public class WebConfig : WebConfigBase 
{
    public override string  UserImageCDNUrl { return "whatever you want";} // or return base.UserImageCDNUrl ;
}
BriceR
  • 1
  • Thanks for the reply, I tried your suggestion (using virtual) but still no joy. The same error. There are other properties in there that work absolutely fine, it's just this latest change that it causing the problem. It's as if there is a cached version somewhere that isn't getting updated, but i dont know where it is! ggrr! – pieperu Sep 21 '16 at 13:56
  • Another thing that is really baffling me is that the error occurs when i run Api.Web, but the error is complaining that App.Web has the problem. Api.Web and App.Web don't even know about each other – pieperu Sep 21 '16 at 14:33
0

I was seeing this problem in Visual Studio 2017.

Upgrading to visual studio 2019 solved the problem for me.

formUser1
  • 21
  • 1