Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Using Include statements in ASP.NET

Using Include statements in ASP.NET

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netvisual-studiosysadminhelp
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beacon dartmouth
    wrote on last edited by
    #1

    I have a Utilities.vb page that contains a number of classes (not compiled) being referenced by a number of (in-line coded) aspx pages. Since I'm not too familiar with either ASP or ASP.NET, I was wondering if the statement used extensively in ASP classic: would still apply in .NET in this context. This application was not created using a Visual Studio Project, and the above referenced Include statement doesn't work as the server keeps returning: 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. BC30002: Type 'Utilities.DPAPI' is not defined. etc. etc.........

    C M 2 Replies Last reply
    0
    • B beacon dartmouth

      I have a Utilities.vb page that contains a number of classes (not compiled) being referenced by a number of (in-line coded) aspx pages. Since I'm not too familiar with either ASP or ASP.NET, I was wondering if the statement used extensively in ASP classic: would still apply in .NET in this context. This application was not created using a Visual Studio Project, and the above referenced Include statement doesn't work as the server keeps returning: 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. BC30002: Type 'Utilities.DPAPI' is not defined. etc. etc.........

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      No, you want to include the file in your project, then you can reference it where-ever you like. If you don't have a project, you don't have an asp.net site. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • B beacon dartmouth

        I have a Utilities.vb page that contains a number of classes (not compiled) being referenced by a number of (in-line coded) aspx pages. Since I'm not too familiar with either ASP or ASP.NET, I was wondering if the statement used extensively in ASP classic: would still apply in .NET in this context. This application was not created using a Visual Studio Project, and the above referenced Include statement doesn't work as the server keeps returning: 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. BC30002: Type 'Utilities.DPAPI' is not defined. etc. etc.........

        M Offline
        M Offline
        minhpc_bk
        wrote on last edited by
        #3

        Hi there, There's no Include directive in the ASP.NET, to add the utility methods written in VB.NET to the web pages aspx there are two options which you may consider: + You can use the script tag, and specify the source file in the src attribute, also remember to add the stuff runat="server":

        <script runat="server" language="vb" src="Utilities.vb" />

        + You can use the Assembly directive in the web page to point to the code file:

        <%@ Assembly Name="MyWebApp" %>
        <%@ Assembly Src="Utilities.vb" %>

        MyWebApp is an assembly which should be existing in the bin foler, and the Utilities.vb file contains the server code for the web page. You can specify the assembly of the ASP.NET application in the Name attribute. Note: Here, I assume your ASP.NET application is written in VB.NET.

        B 2 Replies Last reply
        0
        • M minhpc_bk

          Hi there, There's no Include directive in the ASP.NET, to add the utility methods written in VB.NET to the web pages aspx there are two options which you may consider: + You can use the script tag, and specify the source file in the src attribute, also remember to add the stuff runat="server":

          <script runat="server" language="vb" src="Utilities.vb" />

          + You can use the Assembly directive in the web page to point to the code file:

          <%@ Assembly Name="MyWebApp" %>
          <%@ Assembly Src="Utilities.vb" %>

          MyWebApp is an assembly which should be existing in the bin foler, and the Utilities.vb file contains the server code for the web page. You can specify the assembly of the ASP.NET application in the Name attribute. Note: Here, I assume your ASP.NET application is written in VB.NET.

          B Offline
          B Offline
          beacon dartmouth
          wrote on last edited by
          #4

          Hi minhpc_bk, Thank you for your response. In fact, I had a feeling that non-precompiled ASP.NET cannot take advantage of supporting classes. That I need to compile at least those support/utility classes into an assembly that is accessible by the pages, and you just confirmed it for me. Yes, this pages was coded in VB.NET. I appreciate your time and care in explaining the issue in elegant text.

          1 Reply Last reply
          0
          • M minhpc_bk

            Hi there, There's no Include directive in the ASP.NET, to add the utility methods written in VB.NET to the web pages aspx there are two options which you may consider: + You can use the script tag, and specify the source file in the src attribute, also remember to add the stuff runat="server":

            <script runat="server" language="vb" src="Utilities.vb" />

            + You can use the Assembly directive in the web page to point to the code file:

            <%@ Assembly Name="MyWebApp" %>
            <%@ Assembly Src="Utilities.vb" %>

            MyWebApp is an assembly which should be existing in the bin foler, and the Utilities.vb file contains the server code for the web page. You can specify the assembly of the ASP.NET application in the Name attribute. Note: Here, I assume your ASP.NET application is written in VB.NET.

            B Offline
            B Offline
            beacon dartmouth
            wrote on last edited by
            #5

            minhpc_bk: I've been trying to make your suggestions work for me, but... Indistinctly of the way I call the methods in the Utilities.vb code ('script' or 'Assembly') I keep getting the same response from the server: 'Namespace or type 'ADODB' for the Imports 'ADODB' cannot be found.' with a reference to the source error: Line 1: Imports ADODB Line 2: Imports System Line 3: Imports System.Text I'm lost here. Do I need to compile the utilities.vb into a .dll ?? Angelo D.

            M 1 Reply Last reply
            0
            • B beacon dartmouth

              minhpc_bk: I've been trying to make your suggestions work for me, but... Indistinctly of the way I call the methods in the Utilities.vb code ('script' or 'Assembly') I keep getting the same response from the server: 'Namespace or type 'ADODB' for the Imports 'ADODB' cannot be found.' with a reference to the source error: Line 1: Imports ADODB Line 2: Imports System Line 3: Imports System.Text I'm lost here. Do I need to compile the utilities.vb into a .dll ?? Angelo D.

              M Offline
              M Offline
              minhpc_bk
              wrote on last edited by
              #6

              Hi there, In the Utilities.vb, you import the namespace ADODB, but you did not provide the assemly which contains this namespace and as a result the asp.net could not find this namespace and threw the error occurs. Try to deploy the assembly containing the ADODB namespace.

              B 1 Reply Last reply
              0
              • M minhpc_bk

                Hi there, In the Utilities.vb, you import the namespace ADODB, but you did not provide the assemly which contains this namespace and as a result the asp.net could not find this namespace and threw the error occurs. Try to deploy the assembly containing the ADODB namespace.

                B Offline
                B Offline
                beacon dartmouth
                wrote on last edited by
                #7

                I'm back w/ questions. I tried to compile an assembly that would contain the namespaces needed, just as you suggested. Since I'm working outside of Visual Studio and w/out a project, I tried doing it manually, but I got errors. The Utilities.vb file imports the following: Imports ADODB Imports System Imports System.Text Imports System.Collections.Specialized Imports System.Security.Cryptography Imports System.Web.Mail Imports System.Runtime.InteropServices Imports System.ComponentModel Imports Microsoft.VisualBasic and my batch file contains: cls C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\vbc /out:bin\Utilities.dll /t:library /r:System.Data.dll /r:ADODB.dll /r:System.Text.dll /r:System.Collections.Specialized.dll /r:System.Security.Cryptography.dll /r:System.Web.Mail.dll /r:System.Runtime.InteropServices.dll /r:System.ComponentModel.dll /r:Microsoft.VisualBasic.dll Utilities.vb pause When I try running it the server returns: vbc: Command Line error BC2017 : could not find library 'ADODB.dll' vbc: Fatal error BC2000 : compiler initialization failed unexpectedly: The system cannot find the file specified. I'm new at this and it's possible I'm screwing it up. In general though, if I comment out the ADODB, the next one: System.Text appears not to be in the library, and if I comment out this one, the next one is not in the library, and so on. My guess is I'm missing something important here, any guesses?? btw, I appreciate you help.

                M 1 Reply Last reply
                0
                • B beacon dartmouth

                  I'm back w/ questions. I tried to compile an assembly that would contain the namespaces needed, just as you suggested. Since I'm working outside of Visual Studio and w/out a project, I tried doing it manually, but I got errors. The Utilities.vb file imports the following: Imports ADODB Imports System Imports System.Text Imports System.Collections.Specialized Imports System.Security.Cryptography Imports System.Web.Mail Imports System.Runtime.InteropServices Imports System.ComponentModel Imports Microsoft.VisualBasic and my batch file contains: cls C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\vbc /out:bin\Utilities.dll /t:library /r:System.Data.dll /r:ADODB.dll /r:System.Text.dll /r:System.Collections.Specialized.dll /r:System.Security.Cryptography.dll /r:System.Web.Mail.dll /r:System.Runtime.InteropServices.dll /r:System.ComponentModel.dll /r:Microsoft.VisualBasic.dll Utilities.vb pause When I try running it the server returns: vbc: Command Line error BC2017 : could not find library 'ADODB.dll' vbc: Fatal error BC2000 : compiler initialization failed unexpectedly: The system cannot find the file specified. I'm new at this and it's possible I'm screwing it up. In general though, if I comment out the ADODB, the next one: System.Text appears not to be in the library, and if I comment out this one, the next one is not in the library, and so on. My guess is I'm missing something important here, any guesses?? btw, I appreciate you help.

                  M Offline
                  M Offline
                  minhpc_bk
                  wrote on last edited by
                  #8

                  Hi there, + It looks like you don't specify the full path to the ADODB.dll assembly. Because, you run the vbc.exe compiler from the C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 while the ADODB.dll is placed in the bin folder of your application. + There are no such many assemblies listed in your batch file like System.Text.dll, System.Collections.Specialized.dll ... They all are the namespaces in the .Net framework, and you need to specify which assemblies contain those namespaces, you can look for that information in the MSDN library or in the summary below: System.Text - Mscorlib.dll System.Collections.Specialized - System.dll System.Security.Cryptography - Mscorlib.dll System.Web.Mail - System.Web.dll System.Runtime.InteropServices - Mscorlib.dll System.ComponentModel - System.dll + If you run your batch file in the normal command prompt window (Run/cmd.exe), you'll have to specify the paths to the .net framework assemblies in the batch file. Or you can use the Visual Studio 2003 command prompt utility. Building From the Command Line[^]

                  B 1 Reply Last reply
                  0
                  • M minhpc_bk

                    Hi there, + It looks like you don't specify the full path to the ADODB.dll assembly. Because, you run the vbc.exe compiler from the C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 while the ADODB.dll is placed in the bin folder of your application. + There are no such many assemblies listed in your batch file like System.Text.dll, System.Collections.Specialized.dll ... They all are the namespaces in the .Net framework, and you need to specify which assemblies contain those namespaces, you can look for that information in the MSDN library or in the summary below: System.Text - Mscorlib.dll System.Collections.Specialized - System.dll System.Security.Cryptography - Mscorlib.dll System.Web.Mail - System.Web.dll System.Runtime.InteropServices - Mscorlib.dll System.ComponentModel - System.dll + If you run your batch file in the normal command prompt window (Run/cmd.exe), you'll have to specify the paths to the .net framework assemblies in the batch file. Or you can use the Visual Studio 2003 command prompt utility. Building From the Command Line[^]

                    B Offline
                    B Offline
                    beacon dartmouth
                    wrote on last edited by
                    #9

                    minhpc_bk, I just wanted to thank you for sharing your knowledge in this particular issue. Your insights made a big difference in working out a viable solution and ultimately prevented a full conversion to the Visual Studio-based model, which has its benefits, but it may have not been well justified for adoption in this particular case. Thanx again and have a happy and prosperous 2006. angelo

                    M 1 Reply Last reply
                    0
                    • B beacon dartmouth

                      minhpc_bk, I just wanted to thank you for sharing your knowledge in this particular issue. Your insights made a big difference in working out a viable solution and ultimately prevented a full conversion to the Visual Studio-based model, which has its benefits, but it may have not been well justified for adoption in this particular case. Thanx again and have a happy and prosperous 2006. angelo

                      M Offline
                      M Offline
                      minhpc_bk
                      wrote on last edited by
                      #10

                      Hi Angelo, I also wish you a successful year 2006 :-D!

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups