I'm getting “'Eval' is not declared. It may be inaccessible due to its protection level” in a ascx












0















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>


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.



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.



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.



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



Any ideas what could be causing this?



Edit:



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.



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.










share|improve this question





























    0















    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>


    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.



    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.



    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.



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



    Any ideas what could be causing this?



    Edit:



    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.



    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.










    share|improve this question



























      0












      0








      0








      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>


      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.



      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.



      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.



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



      Any ideas what could be causing this?



      Edit:



      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.



      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.










      share|improve this question
















      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>


      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.



      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.



      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.



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



      Any ideas what could be causing this?



      Edit:



      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.



      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.







      asp.net .net vb.net .net-4.0 webforms






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 2 '12 at 22:06









      Hanlet Escaño

      14.5k74461




      14.5k74461










      asked Jun 28 '12 at 13:51









      alnorth29alnorth29

      2,31622646




      2,31622646
























          2 Answers
          2






          active

          oldest

          votes


















          0














          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.



          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.



          Deleting the old DLLs has fixed the issue.






          share|improve this answer































            0














            This happened in VS2017, in my case, when adding classes from other or older projects (Add->Existing Item) or when you add a Control/WebForm and than cut&paste code from other or older projects.



            The workarond is as follows:




            1. Don't use Add->Existing Item

            2. Add a new EMPTY Control/WebForm (leave the default name)

            3. Open the code behind and RUN COMPILE on the empty default files

            4. Add some code in .aspx like a DIV tag

            5. Compile again

            6. Reference DIV tag from code behind file (i.e. DivId.Visible = False)

            7. Compile again

            8. Now the assembly/compiler is hooked to the new file/class

            9. Now cut&paste the code from the other projects to the editor


              1. Compile again

              2. NO MORE ERRORS!!




            Enjoy!






            share|improve this answer

























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11246155%2fim-getting-eval-is-not-declared-it-may-be-inaccessible-due-to-its-protectio%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              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.



              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.



              Deleting the old DLLs has fixed the issue.






              share|improve this answer




























                0














                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.



                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.



                Deleting the old DLLs has fixed the issue.






                share|improve this answer


























                  0












                  0








                  0







                  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.



                  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.



                  Deleting the old DLLs has fixed the issue.






                  share|improve this answer













                  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.



                  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.



                  Deleting the old DLLs has fixed the issue.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 3 '12 at 9:35









                  alnorth29alnorth29

                  2,31622646




                  2,31622646

























                      0














                      This happened in VS2017, in my case, when adding classes from other or older projects (Add->Existing Item) or when you add a Control/WebForm and than cut&paste code from other or older projects.



                      The workarond is as follows:




                      1. Don't use Add->Existing Item

                      2. Add a new EMPTY Control/WebForm (leave the default name)

                      3. Open the code behind and RUN COMPILE on the empty default files

                      4. Add some code in .aspx like a DIV tag

                      5. Compile again

                      6. Reference DIV tag from code behind file (i.e. DivId.Visible = False)

                      7. Compile again

                      8. Now the assembly/compiler is hooked to the new file/class

                      9. Now cut&paste the code from the other projects to the editor


                        1. Compile again

                        2. NO MORE ERRORS!!




                      Enjoy!






                      share|improve this answer






























                        0














                        This happened in VS2017, in my case, when adding classes from other or older projects (Add->Existing Item) or when you add a Control/WebForm and than cut&paste code from other or older projects.



                        The workarond is as follows:




                        1. Don't use Add->Existing Item

                        2. Add a new EMPTY Control/WebForm (leave the default name)

                        3. Open the code behind and RUN COMPILE on the empty default files

                        4. Add some code in .aspx like a DIV tag

                        5. Compile again

                        6. Reference DIV tag from code behind file (i.e. DivId.Visible = False)

                        7. Compile again

                        8. Now the assembly/compiler is hooked to the new file/class

                        9. Now cut&paste the code from the other projects to the editor


                          1. Compile again

                          2. NO MORE ERRORS!!




                        Enjoy!






                        share|improve this answer




























                          0












                          0








                          0







                          This happened in VS2017, in my case, when adding classes from other or older projects (Add->Existing Item) or when you add a Control/WebForm and than cut&paste code from other or older projects.



                          The workarond is as follows:




                          1. Don't use Add->Existing Item

                          2. Add a new EMPTY Control/WebForm (leave the default name)

                          3. Open the code behind and RUN COMPILE on the empty default files

                          4. Add some code in .aspx like a DIV tag

                          5. Compile again

                          6. Reference DIV tag from code behind file (i.e. DivId.Visible = False)

                          7. Compile again

                          8. Now the assembly/compiler is hooked to the new file/class

                          9. Now cut&paste the code from the other projects to the editor


                            1. Compile again

                            2. NO MORE ERRORS!!




                          Enjoy!






                          share|improve this answer















                          This happened in VS2017, in my case, when adding classes from other or older projects (Add->Existing Item) or when you add a Control/WebForm and than cut&paste code from other or older projects.



                          The workarond is as follows:




                          1. Don't use Add->Existing Item

                          2. Add a new EMPTY Control/WebForm (leave the default name)

                          3. Open the code behind and RUN COMPILE on the empty default files

                          4. Add some code in .aspx like a DIV tag

                          5. Compile again

                          6. Reference DIV tag from code behind file (i.e. DivId.Visible = False)

                          7. Compile again

                          8. Now the assembly/compiler is hooked to the new file/class

                          9. Now cut&paste the code from the other projects to the editor


                            1. Compile again

                            2. NO MORE ERRORS!!




                          Enjoy!







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Nov 24 '18 at 21:56

























                          answered Nov 24 '18 at 21:01









                          user3305711user3305711

                          191313




                          191313






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11246155%2fim-getting-eval-is-not-declared-it-may-be-inaccessible-due-to-its-protectio%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Create new schema in PostgreSQL using DBeaver

                              Deepest pit of an array with Javascript: test on Codility

                              Costa Masnaga