Thank you David, it works great. However i would like to use the
assembly directive without compiling first. On MSDN documentation it is
written that i can use the assembly directive to link to a source .vb
file.
Your sniplet works fine if i pre-compile a part of my program, and it
is great for testing purpose. But i have to work on a huge asp.net
application, and this is why i would like to be able to run all the
program using Code Behind and assembly directive "on the fly", i mean
without any pre-compilation. I have tried to use the <%@ assembly
src="..." %> directive but it doesn't seem to work the way i am using
it.
Here is my test with 3 files in the same folder : Include2.vb
HelloWorld2.vb HelloWorld.aspx
Include2.vb
----------------------------------
Imports System
Imports System.Web.UI
Public Class MyInclude2
Inherits Page
Shared Function MyStrToUpper(byval strText as string)
MyStrToUpper = Microsoft.VisualBasic.Strings.Ucase(strText)
End Function
End Class
HelloWorld2.vb
-----------------------------------------
Imports System
Imports System.Web.UI
Public Class MyHelloWorld2
Inherits MyInclude2
Private sub Page_Load()
System.Web.HttpContext.Current.Response.write(MyStrToUpper("Hello
World !"))
End Sub
End Class
HelloWorld.aspx
-----------------------------------------------------
<%@ Assembly src="Include2.vb" %>
<%@ Page Inherits="MyHelloWorld2" src="HelloWorld2.vb" %>
This is the result i get when i run my page HelloWorld.aspx in Internet
Explorer 6
----------------------------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------
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.
Compiler Error Message: BC30002: Type 'MyInclude2' is not defined.
Source Error:
Line 3:
Line 4: Public Class MyHelloWorld2
Line 5: Inherits MyInclude2
Line 6:
Line 7: Private sub Page_Load()
Source File: D:\dev\test\HelloWorld_Include_CodeBehind\HelloWorld2.vb
Line: 5
Show Detailed Compiler Output:
c:\windows\system32\inetsrv>
"c:\windows\microsoft.net\framework\v1.1.4322\vbc.exe" /t:library
/utf8output /R:"c:\windows\microsoft.net\framework\v1.1.4322\temporary
asp.net
files\root\feae588f\4f1f1709\assembly\dl2\b219fab7\e08a7a39_6310c501\helloworld_.dll"
/R:"c:\windows\assembly\gac\system.web.mobile\1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll"
/R:"c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net
files\root\feae588f\4f1f1709\assembly\dl2\54786a7b\40bf0fcf_1a10c501\mypage.dll"
/R:"c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll"
/R:"c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll"
/R:"c:\windows\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll"
/R:"c:\windows\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll"
/R:"c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll"
/R:"c:\windows\assembly\gac\system.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll"
/R:"c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll"
/R:"c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net
files\root\feae588f\4f1f1709\assembly\dl2\6f380172\e0538477_1510c501\quote.dll"
/out:"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\root\feae588f\4f1f1709\1c4gcic1.dll" /D
EBUG=1 /debug+
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\root\feae588f\4f1f1709\1c4gcic1.0.vb"
Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322.573
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.
D:\dev\test\HelloWorld_Include_CodeBehind\HelloWorld2.vb(5) : error
BC30002: Type 'MyInclude2' is not defined.
Inherits MyInclude2
~~~~~~~~~~
D:\dev\test\HelloWorld_Include_CodeBehind\HelloWorld2.vb(8) : error
BC30451: Name 'MyStrToUpper' is not declared.
System.Web.HttpContext.Current.Response.write(MyStrToUpper("Hello
World !"))
~~~~~~~~~~~~
Show Complete Compilation Source:
Line 1: Imports System
Line 2: Imports System.Web.UI
Line 3:
Line 4: Public Class MyHelloWorld2
Line 5: Inherits MyInclude2
Line 6:
Line 7: Private sub Page_Load()
Line 8:
System.Web.HttpContext.Current.Response.write(MyStrToUpper("Hello
World !"))
Line 9: End Sub
Line 10:
Line 11: End Class
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET Version:1.1.4322.573
====> I have tried to do as indicated in MSDN, and i know the
Include2.vb is processed (because i have tried to put an obvious
mistake in it and it was detected at first). But when it comes to
inheritance in HelloWorld2.vb, the class Include2 seems completely
ignored. Do you have an idea of what's going on ?
Thank you for your great help.