我越来越"“评估和演示”未声明。它可能无法访问由于其保护级别"在ASCX [英] I'm getting "'Eval' is not declared. It may be inaccessible due to its protection level" in a ascx

查看:316
本文介绍了我越来越"“评估和演示”未声明。它可能无法访问由于其保护级别"在ASCX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用eval在转发这样一个ASCX:

I have an ascx that uses Eval in a repeater like this:

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Similar.ascx.vb" Inherits="x.y.z.Similar" %>
<asp:repeater runat="server" id="rptAlternatives" visible="false" Enableviewstate="false">
    <HeaderTemplate>
        <section id="similar" class="sidelist sideModule">
            <h3>Possible Alternatives:</h3> 
            <ul class="sideborder">
    </HeaderTemplate>
    <ItemTemplate>
        <li>
            <a href="/bar/<%# Eval("URL")%>" class="box">foo</a>
        </li>
    </ItemTemplate>
    <FooterTemplate>
            </ul>
        </section>
    </FooterTemplate>
</asp:repeater>

这工作正常,我的开发PC上,但是当我把它部署到我们活的服务器失败说:编译器错误信息:BC30451:评估和演示未声明。它可能无法访问由于其保护级别。什么是真正奇怪的是,有时会重新启动应用程序池,使之消失,然后有时再回来。此外,它不是使用评估

This works fine on my development PC, but when I deploy it to our live server it fails saying: Compiler Error Message: BC30451: 'Eval' is not declared. It may be inaccessible due to its protection level. What's really odd is that sometimes restarting the application pool makes it go away and then sometimes it comes back again. Also it's not breaking on every page that uses Eval.

当地环境是IIS 7.5.7600.16385与应用程序池运行ASP.NET v4.0的经典。服务器环境是相同的。我从VS发表我的机器上,然后复制这个到现场服务器部署。

The local environment is IIS 7.5.7600.16385 with an application pool running ASP.NET v4.0 Classic. The server environment is the same. I publish from VS on my machine and copy this onto the live server to deploy.

在此部署的直播现场,使用V2.0。升级网站V4.0是我们试图以释放部分修改。这code并没有改变,因为这版本的一部分。它一直使用评估和演示,而这一直是很好。

Before this deployment the live site was using v2.0. Upgrading the site to v4.0 is part of the changes we're trying to release. This code has not changed as part of this release. It has always used Eval, and this has always been fine.

我已经安装了Visual Studio的11测试版,但是我使用2010这个项目。

I have installed the Visual Studio 11 beta, but I'm using 2010 for this project.

任何想法可能会导致什么呢?

Any ideas what could be causing this?

编辑:

此专家交流后似乎描述如出一辙行为。他们的固定它通过改变两个ASCX和ascx.vb文件及其类的名称。他们改变之前匹配,他们改变后匹配,但变化明显慢跑东西编译。我可以给这个一展身手,但它似乎并不令人满意,一个特定的ASCX只想停止工作。

This experts exchange post seems to describe exactly the same behaviour. They "fixed" it by changing the name of their class in both ascx and ascx.vb files. They matched before the change and they matched after the change, but the change obviously jogged something in the compiler. I might give this a go, but it doesn't seem satisfactory that a particular ascx would just stop working.

我还发现很多帖子建议将其改为的DataBinder.Eval(的Container.DataItem,URL)的。然而,我又不愿意这样做时,code前工作,突然停了下来。这是一个神奇的和随机的修复,我很不愿意使用。

I've also found plenty of posts suggesting changing it to DataBinder.Eval(Container.DataItem, "URL"). However, I'm again reluctant to do this when the code worked before and has suddenly stopped. It's a magic and random "fix" that I'm unwilling to use.

推荐答案

重要细节竟然是我们从V2.0到V4.0的更新,而我们在$ P $的顶部复制文件pvious部署。

The important detail turned out to be that we were updating from v2.0 to v4.0 and that we were copying files over the top of the previous deployment.

有2.0 precompiled网站的DLL仍处于从previous部署在服务器上的bin目录。由于precompiled DLL名称版本之间改变旧的没有更换。不知怎的,有v2.0和v4.0的DLL文件在同一目录混淆了服务器。由于我没有这些老的DLL在我的机器我没有看到了同样的问题。

There were v2.0 precompiled website DLLs still in the bin directory on the server from the previous deployment. As the precompiled DLL names change between releases the old ones were not replaced. Somehow having v2.0 and v4.0 DLLs in the same directory was confusing the server. As I didn't have these old DLLs on my development machine I was not seeing the same problems.

删除旧的DLL已经解决了该问题。

Deleting the old DLLs has fixed the issue.

这篇关于我越来越&QUOT;“评估和演示”未声明。它可能无法访问由于其保护级别&QUOT;在ASCX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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