473,406 Members | 2,705 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,406 software developers and data experts.

Boolean Function Use in .NET

I'm calling a function in .NET (ASP/VB) this way:

If Not myFunction(var1, var2) Then
....
End If

myFunction is declared as: -
Function myFunction(var1 as String, var2 as String) As Boolean
...
End Function
I'm getting an error on the 1st line of code (the IF statement), the
error reads:
Collection is read-only.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Collection is
read-only.

Stack Trace:
[NotSupportedException: Collection is read-only.]
System.Collections.Specialized.NameValueCollection .Set(String name,
String value)
System.Collections.Specialized.NameValueCollection .set_Item(String
name, String value)
ASP.login_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer)
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Page.ProcessRequestMain()
Any idea?

Nov 19 '05 #1
6 1959
Looks like some kind of side effect. The arguments are really just strings ?
What does the function ? From the stack trace, it looks like a control is
rendered and a collection change is attempted at some point...

Add perhaps a trace at the very beginning of the function to see if the
function is called...

--
Patrice

"No_Spam" <no********@comcast.net> a écrit dans le message de
news:11*********************@g44g2000cwa.googlegro ups.com...
I'm calling a function in .NET (ASP/VB) this way:

If Not myFunction(var1, var2) Then
....
End If

myFunction is declared as: -
Function myFunction(var1 as String, var2 as String) As Boolean
...
End Function
I'm getting an error on the 1st line of code (the IF statement), the
error reads:
Collection is read-only.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Collection is
read-only.

Stack Trace:
[NotSupportedException: Collection is read-only.]
System.Collections.Specialized.NameValueCollection .Set(String name,
String value)
System.Collections.Specialized.NameValueCollection .set_Item(String
name, String value)
ASP.login_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer)
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Page.ProcessRequestMain()
Any idea?

Nov 19 '05 #2
You renamed the function for the purposes of posting in this newsgroup? If
so, tell us the actual name of your function and post the real code you are
using.

"No_Spam" <no********@comcast.net> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
I'm calling a function in .NET (ASP/VB) this way:

If Not myFunction(var1, var2) Then
....
End If

myFunction is declared as: -
Function myFunction(var1 as String, var2 as String) As Boolean
...
End Function
I'm getting an error on the 1st line of code (the IF statement), the
error reads:
Collection is read-only.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Collection is
read-only.

Stack Trace:
[NotSupportedException: Collection is read-only.]
System.Collections.Specialized.NameValueCollection .Set(String name,
String value)
System.Collections.Specialized.NameValueCollection .set_Item(String
name, String value)
ASP.login_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer)
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Page.ProcessRequestMain()
Any idea?

Nov 19 '05 #3
PL
> I'm getting an error on the 1st line of code (the IF statement), the
error reads:


It is just pointing to the function call, the error is in your function and has nothing
to do with the code your posted or boolean returns from functions.

Obviously you are using somekind of collection or accessing a collection and
trying to change it, the collection however is readonly and cannot be changed.

Post the whole code if you want more help.

PL.
Nov 19 '05 #4
Function CheckCode(ByRef sMemberID As String, ByRef sGroupID As String)
As Boolean
Select Case sGroupID
Case "1"
If Len(sMemberID) = 11 Then
Return True
Else
Return False
End If
...
End Select
End Function

Nov 19 '05 #5
I don't think it is the call to this function causing the problem. It is
some other piece of code that you are not showing here related to a
collection. I think QueryString is one property that is a
NameValueCollection, might be others.

"No_Spam" <no********@comcast.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Function CheckCode(ByRef sMemberID As String, ByRef sGroupID As String)
As Boolean
Select Case sGroupID
Case "1"
If Len(sMemberID) = 11 Then
Return True
Else
Return False
End If
...
End Select
End Function

Nov 19 '05 #6
Thank you all.
I found the problem was related when I'm calling the function and not
using "toString()" for the parameters. Instead of
If Not myFunction(var1, var2) Then

I did: -
If Not myFunction(var1.toString(), var2.toString()) Then

That seems to work.

Nov 19 '05 #7

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

Similar topics

14
by: greg | last post by:
Discussion is invited on the following proto-PEP. ------------------------------------------------------------- PEP ??? - Overloadable Boolean Operators...
0
by: Sachin Narasimhan via .NET 247 | last post by:
(Type your message here) Hi, I am at my wits end. It would be great if someone can help. Wehave a Stored Function(Oracle) that returns a boolean that wecannot change to return something else and we...
3
by: Max Speransky | last post by:
Hello My task is to validate expression and get value of it in boolean variable. I try to do following: CREATE OR REPLACE FUNCTION get_value(integer) RETURNS boolean AS' DECLARE Ret ...
4
by: MLH | last post by:
The following function declaration confuses me... Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef sReason As String) As Boolean I tried pasting it and its code into an...
1
by: Eric Gofoth | last post by:
Hello There doesn't appear to be an iformatprovider for to specify the format to convert a boolean to. i.e. MyBool.ToString("YES/NO") does not work Any workarounds?
10
by: Henri | last post by:
In java for instance there's a way to use booleans as objects and not as value types. I would like to do the same in VB.NET so that I can check if the boolean has been explicitely defined (is not...
5
by: Rob Meade | last post by:
Hi all, Quick question if I may... I have a function which depending on whether it was succesful to do something or not returns True or False as a boolean. I have another function which...
2
by: John | last post by:
My application needs to call Oracle function using oracle client 9.2. The oracle function returns boolean value from its returned parameter. The name space that I used is system.data.oracleclient....
1
by: vbisjustforme | last post by:
Hello, I am working on a windows dll and this is my problem: 'api Public Declare Function myFunction Lib "Functionmine.dll" (byval ProgieName as String) as Boolean 'entry point in module...
4
by: Ironr4ge | last post by:
Hi everyone, I am trying to open the form "Languages" with a diffrent record source to the "Contacts" form where I conducted the search or filter... . I was wondering whether there was a vba...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.