Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

Reflection problem converting to ASP.NET 2.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TheLongshot - 08 Nov 2006 21:57 GMT
Ok, let's try this again.

I have an ASP.NET 1.1 application that I'm working to convert to 2.0,
but I've run into a snag.

The problem is with this line:

return
(IDataProviderBase)(((ConstructorInfo)cache["IDataProviderBase"]).Invoke(null)
);

This is supposed to create an object that uses the IDataProviderBase
interface.  The cache contents are created here:

cache.Insert( "IDataProviderBase", Assembly.LoadFrom(
assemblyPath).GetType( className ).GetConstructor(new Type[0]), new
CacheDependency( assemblyPath ) );

className is a string from Web.Config with the fully qualified class
name ("AppName.Components.DataAccess.SQLDataAccess", for example).

So, the constructor is stored in the cache, and is invoked when the
first bit of code is executed.  Problem is, I'm getting an
InvalidCastException there, and I have no idea why.  I've tried casting
to the object being created with the same result.  (Unable to cast
object of type 'AppName.Components.DataAccess.SqlDataProvider' to type
'AppName.Components.DataAccess.SqlDataProvider')  I was able to assign
it to an Object object, and doing a GetType returns what I expected,
but I still can't cast it to the appropriate object.

So, any idea why this is happening?
chanmm - 09 Nov 2006 01:45 GMT
ASP.NET 1.1 to 2.0 I do hit a lot of tiny problems too. Are you converting
your 1.1 to 2.0 using VS 2005? If not then please do so. If you are doing
manual converting then ...

chanmm

> Ok, let's try this again.
>
[quoted text clipped - 27 lines]
>
> So, any idea why this is happening?
TheLongshot - 09 Nov 2006 15:22 GMT
Yes, I'm using VS 2005.  I'm still having problems.  Any suggestions?

Jason

> ASP.NET 1.1 to 2.0 I do hit a lot of tiny problems too. Are you converting
> your 1.1 to 2.0 using VS 2005? If not then please do so. If you are doing
[quoted text clipped - 33 lines]
> >
> > So, any idea why this is happening?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.