Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ambiguous class Reference when using Linked File in Different Projects in Razor?

I have 5 to 6 projects. Project A and B use a same file via Linked File. Now, if I use this class in Razor I will get,

The call is ambiguous between the following methods or properties:

Because Razor views reference all the dlls in bin. It is referencing the same class from Project A and B. How to tell the Razor during compilation use Project A and not Project B?

like image 374
Imran Qadir Baksh - Baloch Avatar asked Oct 01 '22 21:10

Imran Qadir Baksh - Baloch


1 Answers

You should not use Linked Files when including the assembly too. Why do you need the referenced class twice? There is no point in that.

You have to put that file in a separate project and reference that one in A, B and your MVC project. This makes you don't need the linked files any more.

Another way is to get the assembly and from this assembly, get the type using reflection and then call the method.

like image 181
Patrick Hofman Avatar answered Oct 03 '22 11:10

Patrick Hofman