Using Include statements in ASP.NET
-
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.........
-
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.........
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++
-
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.........
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 thescript
tag, and specify the source file in thesrc
attribute, also remember to add the stuffrunat="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 theName
attribute. Note: Here, I assume your ASP.NET application is written in VB.NET. -
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 thescript
tag, and specify the source file in thesrc
attribute, also remember to add the stuffrunat="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 theName
attribute. Note: Here, I assume your ASP.NET application is written in VB.NET.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.
-
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 thescript
tag, and specify the source file in thesrc
attribute, also remember to add the stuffrunat="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 theName
attribute. Note: Here, I assume your ASP.NET application is written in VB.NET.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. -
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.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.
-
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.
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. -
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.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[^]
-
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[^]
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
-
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