472,352 Members | 1,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Build error in overloaded function

Hi all,

I am having a build error in one of the overloaded functions in my class.
The function takes either a string as a parameter or a type referenced in
another dll as a parameter. My class references the dll where the type of the
parameter is defined. I am able to create to create my class in a form
without any build errors and without any references to the DLL where the
other parameter type is defined. The form only uses the function with the
string parameter and not the other one. But when i try to call the overloaded
function with a string parameter, i get an build error saying a reference to
the DLL containing the other parameter type should be added to the form.

I dont understand why the build error happens only when the function in my
class is called and not when it is created. Also i quite dont get why i
should add a reference in the form to the external parameter type when the
form is never gonna use it.

If the question seems confusing i will be happy to give out more details.
Has anybody faced this kind of error before. I would appreciate it if
somebody can let me know if and how the above problem can be fixed.

Thank You,
-Vish
Nov 29 '05 #1
4 1741
Vish,

That's the thing though, it is going to use that type. Once you decide
to call the overload that uses the type from the other assembly, the
compiler needs the type information to make the call (not to mention the
fact that you are probably going to create an instance of that type if you
are going to pass it to an overload that expects it).

So in the end, you have to set a reference to that assembly if you want
to call that overload.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vish" <Vi**@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.com...
Hi all,

I am having a build error in one of the overloaded functions in my class.
The function takes either a string as a parameter or a type referenced in
another dll as a parameter. My class references the dll where the type of
the
parameter is defined. I am able to create to create my class in a form
without any build errors and without any references to the DLL where the
other parameter type is defined. The form only uses the function with the
string parameter and not the other one. But when i try to call the
overloaded
function with a string parameter, i get an build error saying a reference
to
the DLL containing the other parameter type should be added to the form.

I dont understand why the build error happens only when the function in my
class is called and not when it is created. Also i quite dont get why i
should add a reference in the form to the external parameter type when the
form is never gonna use it.

If the question seems confusing i will be happy to give out more details.
Has anybody faced this kind of error before. I would appreciate it if
somebody can let me know if and how the above problem can be fixed.

Thank You,
-Vish

Nov 29 '05 #2
Hi Nick,

I am going to be calling the overloaded function from the form but never
using the parameter referenced in the external assembly. The form is always
going to use the string parameter. The function will be called with the other
parameter type in other projects and never in the form so why should a
reference to the external assembly be needed in the form. Also why does the
build error happen when i call the function and not when i create class with
the function.

-Vish

"Nicholas Paldino [.NET/C# MVP]" wrote:
Vish,

That's the thing though, it is going to use that type. Once you decide
to call the overload that uses the type from the other assembly, the
compiler needs the type information to make the call (not to mention the
fact that you are probably going to create an instance of that type if you
are going to pass it to an overload that expects it).

So in the end, you have to set a reference to that assembly if you want
to call that overload.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vish" <Vi**@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.com...
Hi all,

I am having a build error in one of the overloaded functions in my class.
The function takes either a string as a parameter or a type referenced in
another dll as a parameter. My class references the dll where the type of
the
parameter is defined. I am able to create to create my class in a form
without any build errors and without any references to the DLL where the
other parameter type is defined. The form only uses the function with the
string parameter and not the other one. But when i try to call the
overloaded
function with a string parameter, i get an build error saying a reference
to
the DLL containing the other parameter type should be added to the form.

I dont understand why the build error happens only when the function in my
class is called and not when it is created. Also i quite dont get why i
should add a reference in the form to the external parameter type when the
form is never gonna use it.

If the question seems confusing i will be happy to give out more details.
Has anybody faced this kind of error before. I would appreciate it if
somebody can let me know if and how the above problem can be fixed.

Thank You,
-Vish


Nov 29 '05 #3
cud ya please try to declare that the "parameter class" to be internal ?
Nov 30 '05 #4
Vish wrote:
Hi Nick,

I am going to be calling the overloaded function from the form but never
using the parameter referenced in the external assembly. The form is always

<snip>

The compiler needs the external assembly because, even though we both
know it can't be in this case, the other parameter which it doesn't know
the type of yet (because the assembly isn't referenced), *could* be
compatible with the String parameter.

In short, you need to provide a reference to the other assembly, or hide
that method from the assembly you want to use (make it internal or
something).

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Nov 30 '05 #5

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

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can...
12
by: Simon | last post by:
Hi, I'm having a problem with templates and specialisation. I'm using it to overload the same function so it can return different things. I can't...
5
by: Gang Zhang | last post by:
Hi, I have 2 overloaded functions as below: myfunc(byval val as Decimal) as string myfunc(byval val as String) as string When calling the...
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...
13
by: Schizoid Man | last post by:
Hi, I have defined a very simple class as follows. I initialize the CInventory object as: CInventory *itemInveotry; The program just performs...
1
by: Angus | last post by:
Why moving a function from protected to public area in class causes error C2556 - overloaded function differs only by return type I have a...
11
by: Latina | last post by:
Hi I am doing a program of sets using overloaded methods. But I am having some error because supposedly the method isValid is undeclared. He is...
7
by: ma740988 | last post by:
Consider the equation (flight dynamics stuff): Yaw (Degrees) = Azimuth Angle(Radians) * 180 (Degrees) / 3.1415926535897932384626433832795...
0
by: Akira Kitada | last post by:
Hi list, I was trying to build Python 2.6 on FreeBSD 4.11 and found it failed to build some of the modules. """ Failed to find the necessary...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.