473,320 Members | 1,841 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,320 software developers and data experts.

non-shared member errors

I have a program I am trying to compile into a dll and am getting a bunch
of: the following errors:

error BC30469: Reference to a non-shared member requires an object
reference.

At first, I thought it was because I had the sub set as shared, but I get
the same error if it take the Shared out.

What is causing these errors?

************************************************** ************************
Imports System
Imports System.Web
Imports System.IO
Imports System.Web.UI
Imports System.Web.SessionState
Imports System.Web.Mail
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpCookie
Imports System.Web.HttpCookieCollection
Imports System.Web.HttpResponse
Imports System.Web.HttpRequest
Imports System.Web.HttpApplication
Imports System.Web.HttpApplicationState
Imports Microsoft.VisualBasic

Namespace MyComponents

Public Class Emails

Shared sub sendTheEmail( )
dim URLPath As String = Left(request.path, InStrRev(request.path, "/") -
1)
Dim objStreamReader as StreamReader
objStreamReader = File.OpenText(MapPath("mail.htm"))
end sub

End Class
End Namespace
************************************************** ********************

And got the following errors:
************************************************** *****************************************
C:\Inetpub\wwwroot\Development>vbc /t:library emailClassgood.vb
/r:system.web.dl
l /r:system.data.dll /r:system.dll /r:Microsoft.VisualBasic.dll
Microsoft (R) Visual Basic .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322.2032
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.

C:\Inetpub\wwwroot\Development\EmailClassgood.vb(2 2) : error BC30469:
Reference
to a non-shared member requires an object reference.

dim URLPath As String = Left(request.path, InStrRev(request.path,
"/") -
1)
~~~~~~~

C:\Inetpub\wwwroot\Development\EmailClassgood.vb(2 2) : error BC30469:
Reference
to a non-shared member requires an object reference.

dim URLPath As String = Left(request.path, InStrRev(request.path,
"/") -
1)
~~~~~~~

C:\Inetpub\wwwroot\Development\EmailClassgood.vb(2 4) : error BC30469:
Reference
to a non-shared member requires an object reference.

objStreamReader = File.OpenText(MapPath("mail.htm"))
~~~~~~~
************************************************** ****************************************
Thanks,

Tom
Nov 19 '05 #1
2 2939
I assume that the class Emails inherits from Page, though that's not shown
here. The trouble is that you refer to the Request object inside a shared
method. A shared method does not have access to instance-specific variables
like Request. The Request object is unique for each instance of a Page
object. So a shared method can't refer to it. It can only refer to objects
that are shared across all instances of a given class. So if your class had
declared a class-level shared variable, then your shared method could refer
to it.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:es****************@TK2MSFTNGP09.phx.gbl...
I have a program I am trying to compile into a dll and am getting a bunch
of: the following errors:

error BC30469: Reference to a non-shared member requires an object
reference.

At first, I thought it was because I had the sub set as shared, but I get
the same error if it take the Shared out.

What is causing these errors?

************************************************** ************************
Imports System
Imports System.Web
Imports System.IO
Imports System.Web.UI
Imports System.Web.SessionState
Imports System.Web.Mail
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpCookie
Imports System.Web.HttpCookieCollection
Imports System.Web.HttpResponse
Imports System.Web.HttpRequest
Imports System.Web.HttpApplication
Imports System.Web.HttpApplicationState
Imports Microsoft.VisualBasic

Namespace MyComponents

Public Class Emails

Shared sub sendTheEmail( )
dim URLPath As String = Left(request.path, InStrRev(request.path, "/") -
1)
Dim objStreamReader as StreamReader
objStreamReader = File.OpenText(MapPath("mail.htm"))
end sub

End Class
End Namespace
************************************************** ********************

And got the following errors:
************************************************** **************************
*************** C:\Inetpub\wwwroot\Development>vbc /t:library emailClassgood.vb
/r:system.web.dl
l /r:system.data.dll /r:system.dll /r:Microsoft.VisualBasic.dll
Microsoft (R) Visual Basic .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322.2032
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.

C:\Inetpub\wwwroot\Development\EmailClassgood.vb(2 2) : error BC30469:
Reference
to a non-shared member requires an object reference.

dim URLPath As String = Left(request.path, InStrRev(request.path,
"/") -
1)
~~~~~~~

C:\Inetpub\wwwroot\Development\EmailClassgood.vb(2 2) : error BC30469:
Reference
to a non-shared member requires an object reference.

dim URLPath As String = Left(request.path, InStrRev(request.path,
"/") -
1)
~~~~~~~

C:\Inetpub\wwwroot\Development\EmailClassgood.vb(2 4) : error BC30469:
Reference
to a non-shared member requires an object reference.

objStreamReader = File.OpenText(MapPath("mail.htm"))
~~~~~~~
************************************************** **************************
************** Thanks,

Tom

Nov 19 '05 #2
"Dan Nuttle" <d_******@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
I assume that the class Emails inherits from Page, though that's not shown
here. The trouble is that you refer to the Request object inside a shared
method. A shared method does not have access to instance-specific
variables
like Request. The Request object is unique for each instance of a Page
object. So a shared method can't refer to it. It can only refer to
objects
that are shared across all instances of a given class. So if your class
had
declared a class-level shared variable, then your shared method could
refer
to it.
But if I take the "Shared" of the Sub line, it gives me the same errors?

If I change:

Shared sub sendTheEmail( )

to

sub sendTheEmail( )

It is the same.

Is there somewhere I can look to find out the difference between shared and
unshared for my asp.net pages to find out the best way to build these?

Thanks,

Tom


"tshad" <ts**********@ftsolutions.com> wrote in message
news:es****************@TK2MSFTNGP09.phx.gbl...
I have a program I am trying to compile into a dll and am getting a bunch
of: the following errors:

error BC30469: Reference to a non-shared member requires an object
reference.

At first, I thought it was because I had the sub set as shared, but I get
the same error if it take the Shared out.

What is causing these errors?

************************************************** ************************
Imports System
Imports System.Web
Imports System.IO
Imports System.Web.UI
Imports System.Web.SessionState
Imports System.Web.Mail
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpCookie
Imports System.Web.HttpCookieCollection
Imports System.Web.HttpResponse
Imports System.Web.HttpRequest
Imports System.Web.HttpApplication
Imports System.Web.HttpApplicationState
Imports Microsoft.VisualBasic

Namespace MyComponents

Public Class Emails

Shared sub sendTheEmail( )
dim URLPath As String = Left(request.path, InStrRev(request.path,
"/") -
1)
Dim objStreamReader as StreamReader
objStreamReader = File.OpenText(MapPath("mail.htm"))
end sub

End Class
End Namespace
************************************************** ********************

And got the following errors:

************************************************** **************************
***************
C:\Inetpub\wwwroot\Development>vbc /t:library emailClassgood.vb
/r:system.web.dl
l /r:system.data.dll /r:system.dll /r:Microsoft.VisualBasic.dll
Microsoft (R) Visual Basic .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322.2032
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.

C:\Inetpub\wwwroot\Development\EmailClassgood.vb(2 2) : error BC30469:
Reference
to a non-shared member requires an object reference.

dim URLPath As String = Left(request.path, InStrRev(request.path,
"/") -
1)
~~~~~~~

C:\Inetpub\wwwroot\Development\EmailClassgood.vb(2 2) : error BC30469:
Reference
to a non-shared member requires an object reference.

dim URLPath As String = Left(request.path, InStrRev(request.path,
"/") -
1)
~~~~~~~

C:\Inetpub\wwwroot\Development\EmailClassgood.vb(2 4) : error BC30469:
Reference
to a non-shared member requires an object reference.

objStreamReader = File.OpenText(MapPath("mail.htm"))
~~~~~~~

************************************************** **************************
**************
Thanks,

Tom


Nov 19 '05 #3

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

Similar topics

12
by: lothar | last post by:
re: 4.2.1 Regular Expression Syntax http://docs.python.org/lib/re-syntax.html *?, +?, ?? Adding "?" after the qualifier makes it perform the match in non-greedy or minimal fashion; as few...
5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
22
by: Steve - DND | last post by:
We're currently doing some tests to determine the performance of static vs non-static functions, and we're coming up with some odd(in our opinion) results. We used a very simple setup. One class...
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
0
by: amitvps | last post by:
Secure Socket Layer is very important and useful for any web application but it brings some problems too with itself. Handling navigation between secure and non-secure pages is one of the cumbersome...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
13
by: asm23 | last post by:
Hi,I need some help to clarify the warning "initial value of reference to non-const must be an lvalue". I'm searching in this groups to find someone has the same situation like me. I found in...
12
by: puzzlecracker | last post by:
is it even possible or/and there is a better alternative to accept input in a nonblocking manner?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.