dcsimg
Results 1 to 6 of 6

Thread: Server is not declared . It may be inaccessible due to its protection level.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    669

    Server is not declared . It may be inaccessible due to its protection level.

    Hi

    ON server.mapath i am getting error - Server is not declared . It may be inaccessible due to its protection level.

    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/rpt1.rdlc")

    Thanks

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,506

    Re: Server is not declared . It may be inaccessible due to its protection level.

    Is this a VB.Net question or an ASP.Net question?

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,294

    Re: Server is not declared . It may be inaccessible due to its protection level.

    Server is a property of the System.Web.UI.Page class. If you aren't using that code in a Web Forms page then you're trying to magic a method into existence.

    Please make the effort to provide a FULL and CLEAR explanation of the problem. After over 600 posts, we shouldn't have to tell you that providing the briefest description possible is rarely sufficient. If you'd like us to volunteer our time to help you, maybe take a bit more time to help us and provide all the relevant information you can upfront.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    669

    Re: Server is not declared . It may be inaccessible due to its protection level.

    Hi

    It is Vb.Net windows based application.

    Thanks

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,506

    Re: Server is not declared . It may be inaccessible due to its protection level.

    As jm told you, the Server Property is something you'd use in an ASP.Net web application, and not in a Windows Desktop application.

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,294

    Re: Server is not declared . It may be inaccessible due to its protection level.

    The point of Server.MapPath in a Web Forms app is to take a URL within the current app and map it to a physical file/folder path. What reason could you have for wanting to do that in the first place in a WinForms app?

    If you want the path of a file that is in the same folder as your EXE then you use Application.StartupPath and Path.Combine. This is why you need to provide a FULL and CLEAR explanation of the problem. We shouldn't have to guess what you're actually trying to achieve.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width