7

I will start abruptly with a peculiar error message (I'm a beginner, building a website in ASP.NET with C#, the file where the error was found is a .ascx = user control file):

Compiler Error Message: CS0433: The type 'Link' exists in both '...\Temporary ASP.NET Files\root\901650e7\5e27d040\App_Code.ybv-vo7n.dll' and '...\Temporary ASP.NET Files\root\901650e7\5e27d040\assembly\dl3\f6cf02ac\a93eed1d_ab32cd01\Project1C.DLL'

Line 10 is apparently where the error stems from (colored in red). Can you give a few pointers? I'm having trouble knowing where to start looking/fixing. Thank you!

Line 9:<ItemTemplate>
Line 10:<asp:HyperLink ID="HyperLink1" runat="server" 
Line 11:NavigateUrl='<%# Link.ToFilms(Eval("FilmsID").ToString()) %>'
Line 12:Text='<%# HttpUtility.HtmlEncode(Eval("Nume").ToString()) %>'
Anna T
  • 1,027
  • 7
  • 21
  • 29
  • 1
    Check if the project doesn't reference itself – Fabske May 15 '12 at 15:13
  • Just check the project/References if you see that it reference itself, i.e. a link to the dll generated by the project – Fabske May 15 '12 at 16:31
  • Thanks Fabske! No, the project doesn't reference itself. I am not that advanced to have added a self-reference anyway. I checked nevertheless and no. – Anna T May 15 '12 at 17:21
  • Oh VS is bugged enough to add it itself, I already had the case several times (but indeed for winform or wpf project, never yet with asp) – Fabske May 15 '12 at 19:06

6 Answers6

8

I know it is a bit late for an answer, but might be of some help to someone else.

Issue: Had a similar problem with this scenario:

  • VS2010 WebAppProject (not WebSiteProject)
  • Had some isolated classes in App_Code (with property [Build Action] set to [Compile])
  • Builds successfully but when loading the web app in the browser, it throws Compilation Error CS0433: The type 'Namespace.Classname' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\7e10b43d\77c16432\App_Code.itpfsoon.dll' and 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\7e10b43d\77c16432\assembly\dl3\2055583c\0bc450de_1589ce01\ WebAppName.DLL'

Solution: Put isolated classes which require property [Build Action] set as [Compile] to any folder other than App_Code since the App_Code folder will be compiled as a separate assembly, having the same Class compiled in 2 assemblies (the App_Code and the WebApp which includes all code from the App_Code itself).

Reference: http://vishaljoshi.blogspot.com/2009/07/appcode-folder-doesnt-work-with-web.html

mrd3650
  • 1,371
  • 3
  • 16
  • 24
4

You will have a path similar to the following:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

Delete the contents of this entire folder (no harm will be done), then try and Clean and Rebuild your solution.

Barry Kaye
  • 7,682
  • 6
  • 42
  • 64
3

Context: I had a very similar problem with ASP with DevExpress and Visual Studio 2012. The problem was our \bin folder in the server was not cleared out, so there were DevExpress 's dlls of two versions v10.1 and v8.3.

Solution: I just removed the dlls files of the incorrect version and it works. Another alternative (better) is to remove all the files in that directory and put your entire folder and files of a new clear publication.

WalterAgile
  • 191
  • 1
  • 4
1

Go to your project's -> References and delete "System.ComponentModel.DataAnnotations"

use EntityFramework is enough.

Yehor Androsov
  • 4,885
  • 2
  • 23
  • 40
kargarf
  • 51
  • 4
0

I have a very similar problem with ASP WCF service and Visual Studio 2010 and new beta. For me helps if I edit service code file (app_code). Adding new line is enough to force VS to rebuild the page. Than this "random" error dissapears.

Ondra
  • 1,619
  • 13
  • 27
  • Thank you Barry and Ondra, I tried both suggestions but they don't work unfortunately. Are there other solutions, perhaps? The type 'Link' exists in both files... what else could this mean? – Anna T May 15 '12 at 15:38
  • From your code it seems that you have created a class called "Link", probably some link helper. I believe there is also another Link class coming from .NET framework (Link ASP control). Try to rename your Link to something else (MyLink, ...) – Ondra May 15 '12 at 17:34
  • I tried that too, after your suggestion I replaced the Link class name with "MyLink" and still the same error. I probably attempted a pretty complex thing for a newbie so now I am twisting and working my head for a fix. **Thanks so far and for any new suggestions.** – Anna T May 15 '12 at 19:26
0

Right Click on Application Name in Solution Explorer and Convert it to Web Application.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
BornToCode
  • 207
  • 2
  • 7