473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Calling Global shared sub not working

I just put this together from O'Reillys book (with much of the code stripped
out).

Global.asax:
******************************************
<%@ Application Language="VB" %>

<script runat="server">

public shared sub WriteFile(strText as string)
response.write("<br>inside WriteFile strText = " & strText & "<br>")
end sub

</script>
******************************************

testglobal.aspx
******************************************
<%@ Page Language="VB" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<script runat="server">

sub Page_Load(sender as Object, e as EventArgs)
Global.WriteFile("This is a test")
end sub

<html>
<body>
</body>
</html>
******************************************

It is obviously calling sub, but I don't understand the error:
************************************************** **********
Compiler Error Message: BC30369: Cannot refer to an instance member of a
class from within a shared method or shared member initializer without an
explicit instance of the class.

Source Error:

Line 4:
Line 5: public shared sub WriteFile(strText as string)
Line 6: response.write("<br>inside WriteFile strText = " & strText &
"<br>")
Line 7: end sub
Line 8:
************************************************** *********************

Is it the response.write that is causing the error?

Thanks,

Tom

Nov 19 '05 #1
1 1455
Don't make it shared. You can't call a reference object from a shared
method.

-Oleg.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl...
I just put this together from O'Reillys book (with much of the code
stripped out).

Global.asax:
******************************************
<%@ Application Language="VB" %>

<script runat="server">

public shared sub WriteFile(strText as string)
response.write("<br>inside WriteFile strText = " & strText & "<br>")
end sub

</script>
******************************************

testglobal.aspx
******************************************
<%@ Page Language="VB" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<script runat="server">

sub Page_Load(sender as Object, e as EventArgs)
Global.WriteFile("This is a test")
end sub

<html>
<body>
</body>
</html>
******************************************

It is obviously calling sub, but I don't understand the error:
************************************************** **********
Compiler Error Message: BC30369: Cannot refer to an instance member of a
class from within a shared method or shared member initializer without an
explicit instance of the class.

Source Error:

Line 4:
Line 5: public shared sub WriteFile(strText as string)
Line 6: response.write("<br>inside WriteFile strText = " & strText &
"<br>")
Line 7: end sub
Line 8:
************************************************** *********************

Is it the response.write that is causing the error?

Thanks,

Tom

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dan Elliott | last post by:
Hello, Converting from a working C program to C++, I run into the following error: I have a header: (header.h) namespace shared{ ... struct X{ ...
16
by: aarklon | last post by:
Hi folks, recently i read the book named assembly language step by step by Jeff Duntemann. in the chapter coding for linux, he has got a paragraph named C calling conventions, which he...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
22
by: fd123456 | last post by:
Hi Tom ! Sorry about the messy quoting, Google is playing tricks on me at the moment. > Global.asax is where you normally have the Global Application > and Session variables and code to...
5
by: joeblast | last post by:
I have a Web service that gets the financial periods and hold a reference to a disconnected dataset built at initialization. Web methods work on the dataset inside the web service. Everything is...
13
by: Charles A. Lackman | last post by:
Hello, Is there a way to make a dataset global to all my aspx 2.0 web forms? Thanks, Chuck
8
by: Jeff | last post by:
Still new to vb.net in VS2005 web developer... What is the proper/standard way of doing the following - setting the value of a variable in one sub and calling it from another? E.g., as below....
15
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
11
by: eBob.com | last post by:
I have this nasty problem with Shared methods and what I think of as "global storage" - i.e. storage declared outside of any subroutines or functions. In the simple example below this "global"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.