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

No accessible overloaded

I am getting the following error which makes no sense. I am doing this in
asp.net. I get the following error:

No accessible overloaded

If you look at the error, there is one overloaded function that can be
called (int, string, int, int).

The first variable is constant that should work fine as an int and works
everywhere else.
The second variable is a string.
The third variable is a System.Int32. (from trace)
The fourth variable is a System.Int64. (from trace)

The code:
************************************************** ****
trace.warn("type = User - " & Session("User").UserID.GetType.ToString())
trace.warn("type = ApplicantID - " &
Session("ApplicantID").GetType.ToString())
HistoryLog.WriteHistoryLog(13,"Application Filed for: " &
HeaderJobTitle.Text,Session("User").UserID,session ("ApplicantID"))
************************************************** **********

Trace results:
**************************
type = User - System.Int32
type = ApplicantID - System.Int64
****************************

It turns out if I change the above code to:

HistoryLog.WriteHistoryLog(13,"Application Filed for: " &
HeaderJobTitle.Text,Session("User").UserID,Convert .ToInt32(session("ApplicantID")))

I thought that the different sizes of integers were interchangeable
(obviously the conversion works OK). I would have thought that an Int64
would work fine for an Integer field.

The error messages:
************************************************** ******
Unhandled Execution Error

No accessible overloaded 'HistoryLog.WriteHistoryLog' can be called with
these arguments without a narrowing conversion:
Public Sub WriteHistoryLog ( ByVal historyActionID As Integer, ByVal detail
As String, ByVal userID As Integer, ByVal applicantID As Integer )
Public Sub WriteHistoryLog ( ByVal historyActionID As Integer, ByVal detail
As String, ByVal firstName As String, ByVal lastName As String )
at
Microsoft.VisualBasic.CompilerServices.VBBinder.se t_InternalThrow(Exception
Value)
at Microsoft.VisualBasic.CompilerServices.VBBinder.Bi ndToMethod(BindingFlags
bindingAttr, MethodBase[] match, Object[]& args, ParameterModifier[]
modifiers, CultureInfo culture, String[] names, Object& ObjState)
at Microsoft.VisualBasic.CompilerServices.VBBinder.In vokeMember(String name,
BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object target,
Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at
Microsoft.VisualBasic.CompilerServices.LateBinding .InternalLateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.LateBinding .LateCall(Object o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)
at ASP.applicationCompletedView_aspx.SubmitIt_Click(O bject s,
ImageClickEventArgs e) in
C:\Inetpub\wwwroot\staffingworkshop\applicant\secu re\applicationCompletedView.aspx:line
666
at System.Web.UI.WebControls.ImageButton.OnClick(Imag eClickEventArgs e)
at
System.Web.UI.WebControls.ImageButton.System.Web.U I.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
at System.Web.UI.Page.ProcessRequestMain()
************************************************** *****************

Here is the Function Call that is being called

Public Shared sub WriteHistoryLog (historyActionID as Integer,detail as
String,userID as Integer,applicantID as Integer)

Why doesn't this work with the convert function?

Thanks,

Tom

Jul 25 '06 #1
3 1845
tshad wrote:
I am getting the following error which makes no sense. I am doing this in
asp.net. I get the following error:

No accessible overloaded

If you look at the error, there is one overloaded function that can be
called (int, string, int, int).
In this group we would prefer to say (Integer, String, Integer,
Integer), but we know what you mean.
>
The first variable is constant that should work fine as an int and works
everywhere else.
Well, if it's a constant that the compiler thinks looks like an Integer,
yes.
The second variable is a string.
The third variable is a System.Int32. (from trace)
The fourth variable is a System.Int64. (from trace)
Aha.
>
The code:
************************************************** ****
trace.warn("type = User - " & Session("User").UserID.GetType.ToString())
trace.warn("type = ApplicantID - " &
Session("ApplicantID").GetType.ToString())
HistoryLog.WriteHistoryLog(13,"Application Filed for: " &
HeaderJobTitle.Text,Session("User").UserID,session ("ApplicantID"))
************************************************** **********

Trace results:
**************************
type = User - System.Int32
type = ApplicantID - System.Int64
****************************

It turns out if I change the above code to:

HistoryLog.WriteHistoryLog(13,"Application Filed for: " &
HeaderJobTitle.Text,Session("User").UserID,Convert .ToInt32(session("ApplicantID")))
It works, I presume.
>
I thought that the different sizes of integers were interchangeable
(obviously the conversion works OK). I would have thought that an Int64
would work fine for an Integer field.
What would you like to happen if session("ApplicantID") happened to be
ten billion (which doesn't fit in an Integer) ?
>
The error messages:
************************************************** ******
Unhandled Execution Error

No accessible overloaded 'HistoryLog.WriteHistoryLog' can be called with
these arguments without a narrowing conversion:
As it turns out, the full error message does tell you exactly what the
problem is...
************************************************** *****************

Here is the Function Call that is being called

Public Shared sub WriteHistoryLog (historyActionID as Integer,detail as
String,userID as Integer,applicantID as Integer)

Why doesn't this work with the convert function?
I though it *does* work when you use Convert.ToInt32 (or CInt) ?

One the the things about VB.NET is that it likes to be type-safe,
especially if you (as you always should) have Option Strict On. One of
the type safety features is that when you are doing something which
could result in the loss of information, you must be explicit about it.

So you can say

Dim ss As Short = 32
Dim ii As Integer = ss
with no problem, because all Short values can be held in an Integer. But
were you to try

Dim ii As Integer = 32
Dim ss As Short = ii

you would get a warning, because Integer to Short is a *narrowing*
conversion - there are some Integer values which can't be held in a
Short, so such an assignment is *unsafe*. Even though it is obvious to
us that 32 will fit in a Short, the compiler pretty much only works one
line at a time, and all it sees is that you are trying to fit a
(potential) quart in a pint pot.

It's exactly the same in your problem. Sure, session("ApplicantID")
might only ever *be* a small number, but the *variable* is an Int64, so
the compiler will not *automatically* convert it to an Int32, which is
what would have to happen for the calling signature to match the
definition signature. Thus the error message.

--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Jul 27 '06 #2
"Larry Lard" <la*******@googlemail.comwrote in message
news:4i************@individual.net...
tshad wrote:
>I am getting the following error which makes no sense. I am doing this
in asp.net. I get the following error:

No accessible overloaded

If you look at the error, there is one overloaded function that can be
called (int, string, int, int).

In this group we would prefer to say (Integer, String, Integer, Integer),
but we know what you mean.
Sorry, my C is showing through.
>
>>
The first variable is constant that should work fine as an int and works
everywhere else.

Well, if it's a constant that the compiler thinks looks like an Integer,
yes.
>The second variable is a string.
The third variable is a System.Int32. (from trace)
The fourth variable is a System.Int64. (from trace)

Aha.
>>
The code:
************************************************* *****
trace.warn("type = User - " & Session("User").UserID.GetType.ToString())
trace.warn("type = ApplicantID - " &
Session("ApplicantID").GetType.ToString())
HistoryLog.WriteHistoryLog(13,"Application Filed for: " &
HeaderJobTitle.Text,Session("User").UserID,sessio n("ApplicantID"))
************************************************* ***********

Trace results:
**************************
type = User - System.Int32
type = ApplicantID - System.Int64
****************************

It turns out if I change the above code to:

HistoryLog.WriteHistoryLog(13,"Application Filed for: " &
HeaderJobTitle.Text,Session("User").UserID,Conver t.ToInt32(session("ApplicantID")))

It works, I presume.
Yes it does.
>
>>
I thought that the different sizes of integers were interchangeable
(obviously the conversion works OK). I would have thought that an Int64
would work fine for an Integer field.

What would you like to happen if session("ApplicantID") happened to be ten
billion (which doesn't fit in an Integer) ?
But that would never happen.

I'm not really sure why it is showing as Int64, but I would have thought
that it would convert the type unless, as you say, the value is out of
bounds. Obviously that is not the case, as you explain below.

Thanks,

Tom
>>
The error messages:
************************************************* *******
Unhandled Execution Error

No accessible overloaded 'HistoryLog.WriteHistoryLog' can be called with
these arguments without a narrowing conversion:

As it turns out, the full error message does tell you exactly what the
problem is...
>************************************************* ******************

Here is the Function Call that is being called

Public Shared sub WriteHistoryLog (historyActionID as Integer,detail as
String,userID as Integer,applicantID as Integer)

Why doesn't this work with the convert function?

I though it *does* work when you use Convert.ToInt32 (or CInt) ?
Sorry, I meant "does".
>
One the the things about VB.NET is that it likes to be type-safe,
especially if you (as you always should) have Option Strict On. One of the
type safety features is that when you are doing something which could
result in the loss of information, you must be explicit about it.

So you can say

Dim ss As Short = 32
Dim ii As Integer = ss
with no problem, because all Short values can be held in an Integer. But
were you to try

Dim ii As Integer = 32
Dim ss As Short = ii

you would get a warning, because Integer to Short is a *narrowing*
conversion - there are some Integer values which can't be held in a Short,
so such an assignment is *unsafe*. Even though it is obvious to us that 32
will fit in a Short, the compiler pretty much only works one line at a
time, and all it sees is that you are trying to fit a (potential) quart in
a pint pot.

It's exactly the same in your problem. Sure, session("ApplicantID") might
only ever *be* a small number, but the *variable* is an Int64, so the
compiler will not *automatically* convert it to an Int32, which is what
would have to happen for the calling signature to match the definition
signature. Thus the error message.

--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version

Jul 27 '06 #3
tshad wrote:
"Larry Lard" <la*******@googlemail.comwrote in message
news:4i************@individual.net...
>tshad wrote:
>>I thought that the different sizes of integers were interchangeable
(obviously the conversion works OK). I would have thought that an Int64
would work fine for an Integer field.
What would you like to happen if session("ApplicantID") happened to be ten
billion (which doesn't fit in an Integer) ?

But that would never happen.

I'm not really sure why it is showing as Int64, but I would have thought
that it would convert the type unless, as you say, the value is out of
bounds. Obviously that is not the case, as you explain below.
The compiler has to be strict; it can't know that the applicant ID
values 'will always' be convertible, unless we help it by providing the
explicit conversion - by doing so we are saying "Don't worry dear
compiler, I take full responsibility for the runtime problems that might
occur by trying to convert a too-large Int64 into an Int32. Please carry
on compiling."

As to why it's an Int64 to start with - I don't actually know enough
ASP.NET to be able to suggest an explanation.
--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Jul 28 '06 #4

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

Similar topics

8
by: Nitin Bhardwaj | last post by:
Thanx in advance for the response... I wanna enquire ( as it is asked many a times in Interviews that i face as an Engg PostGraduate ) about the overloading capability of the C++ Language. ...
4
by: Jeffrey Howard | last post by:
We got back "No accessible overloaded. "Streamwriter.writeline is most specific for these arguments: Overrides Public Sub Writeline(ByVal buffer as Char() ). Overrides Public Sub Writeline(ByVal...
44
by: bahadir.balban | last post by:
Hi, What's the best way to implement an overloaded function in C? For instance if you want to have generic print function for various structures, my implementation would be with a case...
3
by: cybertof | last post by:
Hello, Is it possible in C# to have 2 overloaded functions with - same names - same parameters - different return type values If no, is it possible in another language ?
7
by: DF | last post by:
DrawText is overloaded - one of which accepts a ByVal rect and the other accepts a ByRef rect. I get a "no accessible 'DrawText' is most specific" error. How can I resolve this problem by forcing VB...
4
by: P K | last post by:
Hello, I have a console application. I have 2 or 3 classes. I also have a class in which I have nothing other than the main function with the follwoing signature public shared sub Main ...
2
by: Bill Nguyen | last post by:
What do I need to do to add a row to a table with single column? I got the "mnarrowing conversion" ewrror mesage. Thanks Bill -----------------
0
by: tshad | last post by:
I am getting the following error which makes no sense. No accessible overloaded If you look at the error, there is one overloaded function that can be called (int, string, int, int). The...
5
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason...
1
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.