468,161 Members | 1,964 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,161 developers. It's quick & easy.

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 1615
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Simon | last post: by
5 posts views Thread by Gang Zhang | last post: by
reply views Thread by tshad | last post: by
13 posts views Thread by Schizoid Man | last post: by
11 posts views Thread by Latina | last post: by
reply views Thread by kamranasdasdas | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.