设计文件的生成失败:无法加载文件或程序 [英] Generation of designer file failed: Could not load file or assembly

查看:171
本文介绍了设计文件的生成失败:无法加载文件或程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个引用另一个项目叫ModusCore(或Modus.Core)ASP.NET Web应用程序项目。我们有各种各样的使用ModusCore到现在为止,没有问题的控制,但是有一个我最近创建了一个已经造成麻烦。这里的code:

I have an ASP.NET web application project which references another project called ModusCore (or Modus.Core). We've had a variety of controls that use ModusCore up until now with no problem, but there's one I created lately that's been causing trouble. Here's the code:

public class PortalLinkNew : WebControl
{
    public string Text { get; set; }
    public bool AllowPush { get; set; }

    public PortalLinkNew()
    {
        AllowPush = true;
    }

    public IChannelRequest ChannelRequest { get; set; }

    protected override HtmlTextWriterTag TagKey
    {
        get { return HtmlTextWriterTag.A; }
    }

    protected override void AddAttributesToRender(HtmlTextWriter writer)
    {
        try
        {
            base.AddAttributesToRender(writer);
            if (DesignMode || Page == null || !(Page is IPortalPage))
            {
                return;
            }
            string href = "/";
            if (ChannelRequest != null)
            {
                var portalPage = (IPortalPage)Page;
                href = portalPage.Module.PortalRouter.GetLinkUrl(portalPage, ChannelRequest, AllowPush);
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Href, href);
        }
        catch (Exception)
        {

        }
    }

    public override void RenderEndTag(HtmlTextWriter writer)
    {
        writer.Write(Text);
        base.RenderEndTag(writer);
    }
}

在上面的code, IPortalPage IChannelRequest 在Modus.Core定义的接口。

In the above code, IPortalPage and IChannelRequest are interfaces defined in Modus.Core.

我的意图是在我的code使用此控件如下:

My intent is to use this control in my code as follows:

<tnl:PortalLinkNew ID="CancelButton" runat="server" Text="Cancel" OnInit="CancelButton_Init" />

这实际上编译并没有问题上运行,但是当我编辑在Visual Studio 2008的页面(源视图),我得到以下警告:

This actually compiles and runs without a problem, but when I'm editing the page (source view) in Visual Studio 2008, I get the following warning:

设计文件的生成失败:无法加载文件或程序集Modus.Core,版本= 1.0.0.0,文化=中性公钥= null或它的一个依赖。该系统找不到指定的文件。

Generation of designer file failed: Could not load file or assembly 'Modus.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

,因为它说,它不会重新设计文件,这意味着任何试图请参考 CancelButton 控制code-落后导致编译器错误。以下建议我在网上找到的,我已经试过删除相应.ascx.designer.cs文件,并使用转换为Web应用程序在该网页上,但它告诉我,它无法重建设计文件同样的理由以上。

As it says, it doesn't regenerate the designer file, meaning any attempt to refer to the CancelButton control in code-behind results in a compiler error. Following advice I've found online, I've tried deleting the corresponding .ascx.designer.cs file and using "Convert to Web Application" on that page, but it tells me that it cannot rebuild the designer file for the same reason mentioned above.

我用尽了一切我能想到的:清洁解决方案,重新启动Visual Studio中,重新启动我的电脑,删除code目录,并从仓库中的新鲜拉,删除并重新添加项目和dll引用,在我使用多台计算机等出现同样的问题。

I've tried everything I can think of: cleaning the solution, restarting Visual Studio, rebooting my computer, deleting the code directory and pulling it fresh from the repository, removing and re-adding the project and dll references, etc. The same problem occurs on multiple computers I use.

我怎样才能获得VS设计师停止失败?

How can I get the VS designer to stop failing?

推荐答案

我有一个非常类似的问题(我不能没有解决)。应用我有一个从网站项目转变,虽然这个问题,我无法摆脱,这有什么用它做的感觉。而我在2005年VS

I have a very similar problem (which I could not solve yet). The Application I have the problem with was converted from a "Web Site Project" though and I can't get rid of the feeling that this has something to do with it. And I am on VS 2005.

现在我可以补充的是,

一)有时(我想不出确切时间尚)转换为Web应用程序对我来说-trick作品(但不总是)

a) "sometimes" (I could not figure out when exactly yet) the "Convert to Web Application"-trick works for me (but not always)

二)有时(同上),它有助于切换到设计器视图,改变一些东西,保存 - > *了.Designer.cs得到再生

b) "sometimes" (same as above) it helps to switch to the designer view, change something and save -> *.designer.cs gets regenerated

我通常尝试几件事情中没有固定的命令后,我增加了一个控制我的网页,直到东西的作品。

I usually try several things in no fix order after I added a control to my page until "something" works.

有很多在互联网上这个噪音,但我无法找到一个真正的修复它(还)。有一件事我除了已经提到的阅读是它可能有一些做的(不匹配/不存在)的命名空间。

There is a lot of noise about this on the internet but I could not find a "real fix" for it (yet). One thing I read besides the already mentioned is that it could have something to do with (not matching/not existing) namespaces.

当我检查我的应用程序真的没有命名在*的.cs-文件declarartions。所以我说他们(在*的.cs和*的.aspx),并在一段时间认为它的伎俩。但可悲的是现在我知道这是不是这样的...

When I checked my application there really were no namespace declarartions in the *.cs-files. So I added them (in *.cs and *.aspx) and for some time thought it did the trick. But sadly by now I know that this was not the case...

这篇关于设计文件的生成失败:无法加载文件或程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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