.net框架为何与其自己的生成文件冲突 [英] why .net framework conflicts with its own generated file

查看:99
本文介绍了.net框架为何与其自己的生成文件冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我多次遇到错误,需要永远的指导以解决它:



编译错误

 描述:


服务此请求所需的资源。请查看以下
个特定的错误详细信息,并适当地修改您的源代码。




 编译器错误消息:CS0433:类型

'ASP.controls_sites_linkbox_ascx'在
'd:\WindowsdMicrosoft.NET\Framework\v4.0.30319中都存在ASP临时ASP.NET
文件\marja\8d9a​​6443\9cb45dad\App_Web_1hpsmwqz.dll'和
'd:\Windows\Microsoft.NET\Framework\v4.0.30319 ASP临时ASP.NET
文件\marja\8d9a​​6443\9cb45dad\App_Web_4lhnbswq.dll'


我关闭Visual Studio时将解决问题。但是,这不正常,当我们在服务器上发布应用程序时,它是否会一次又一次出现呢?

解决方案

如果您不希望遇到此问题,请尽量避免使用网站项目,而应选择 Web应用程序。



实际上,网站 项目只是一个常规的Web应用程序,唯一的区别是。程序集的名称会自动生成(在您的情况下为App_Web_1hpsmwqz.dll),而不是为您的应用程序使用命名的.dll(例如Something.Web.dll)。



现在,您的问题源于这样的事实:已经发生了两次,并且您正在运行一个较旧的自动生成文件-该文件仍在应用程序的dll搜索路径中。因此,编译器最终会找到两个具有完全相同名称空间的类。



您可以按照Ankur的建议进行操作,然后删除临时文件。从长远来看,我会考虑将其转变为合适的Web应用程序。



我做了一个,也就是一个网站。我几次遇到这个问题,并决定不再做任何事情。回到Web应用程序,(显然)再也没有问题了。


I face with an error many times I need some guide to solve it for ever:

Compilation Error

Description: An error occurred during the compilation of a

resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0433: The type

'ASP.controls_sites_linkbox_ascx' exists in both 'd:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\marja\8d9a6443\9cb45dad\App_Web_1hpsmwqz.dll' and 'd:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\marja\8d9a6443\9cb45dad\App_Web_4lhnbswq.dll'

the problem will be solved when I close the visual studio. but it is not normal isn't it dangerous when we published application on the server it might be appear again and again ?

解决方案

If you don't want to run into this problem, avoid "Web Site" projects if you can - and favour "Web applications".

Really, a "Web Site" project is just a regular web application, with one key difference. Instead of having a named .dll for your application ( e.g. Something.Web.dll ), the name of your assembly is auto-genned ( in your case, App_Web_1hpsmwqz.dll ).

Now, your problem stems from the fact that this has happened a couple of times, and you've got an older auto-generated file kicking around - which is still in your app's dll search path. So the compiler ends up finding two classes with the exact same namespace. It doesn't know which to pick.

You can do as Ankur suggests, and delete the temporary files. Long-term, I'd consider turning this into a proper web application.

I did one, and precisely one "Web Site". I hit this problem a couple of times and resolved that I'd never do one again. Moved back to web applications and (obviously) never had the problem again.

这篇关于.net框架为何与其自己的生成文件冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆