Bug in C# 3.0 compiler

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My apoligies if this has been posted already or is already known about.
Using reflection to invoke the constructor of an object, assigning the
constructed object to a member of type object, and then later trying to
upcast that member to the appropriate type throws an
invalidcastexception.

Hammad
 
My apoligies if this has been posted already or is already known about.
Using reflection to invoke the constructor of an object, assigning the
constructed object to a member of type object, and then later trying to
upcast that member to the appropriate type throws an
invalidcastexception.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
That probably isn't a compiler error. It sounds like a CLR error, which
seems unlikely. Could you post a short but complete program that
demonstrates the failure?
 
I would until I found out it was my own error. I was using the wrong
path of the dll that was loaded into my application project.

In other words, my class library built to a specific directory. I had
another project that referenced the the project that built that class
library. In the latter project, I used the full path location of the
dll in the bin\debug directory for the class library project instead of
using the path of the dll that was copied over to the bin\debug
location of the executable project as part of the project dependency.
When I used the full path location to the dll in the executable
location, the casting went fine.

I don't understand why, because I figured that they are the same dlls,
and the one in the class library project is just copied from its
location to the appropriate location in the executable project.

Either way, it may still be a bug, but I'm not sure. I was at least
able to resolve the issue enough to continue coding. I hope you
understood what I said. ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top