Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

Maximum ASP
  Ads  
Aspose - The .NET & Java component publisher
 


  Sponsors  

Meet Our Sponsors

Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
SteadyRain
DataSprings - Great Ideas. Always Flowing.
R2integrated - formerly bi4ce
Jango Studios - Skins, Modules and Hosting for DotNetNuke
eUKhost.com is commited to offer exceptional UK Windows Web Hosting solutions with quality 24x7 technical support.Our plans support ASP.Net, ASP, ASP.NET Ajax extensions, XML, MSSQL, MySQL, PHP,DNN, multiple domains and Shared SSL as standard.
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  Unable to cast object exception
Previous Previous
 
Next Next
New Post 4/23/2008 5:00 AM
User is offline Ignas
25 posts
10th Ranked


Unable to cast object exception 

Hello everybody,

i have one very annoying exception when I try to use module, developed separatelly from DotNetNuke project and then packed and installed in DotNetNuke from PA. The exception looks like that: Unable to cast object of type 'DotNetNuke.Modules.xx.SqlDataProvider' to type 'DotNetNuke.Modules.xx.DataProvider' (DotNetNuke.Modules.xx is the namespace).
The exception occures here:
objProvider = ((DataProvider)(Framework.Reflection.CreateObject("data", "DotNetNuke.Modules.xx", "")));

in DotNetNuke.Modules.xx.DataProvider class in static CreateProvider() method.

The DotNetNuke.Modules.xx.SqlDataProvider really extends from DotNetNuke.Modules.xx.DataProvider so I'm confused here. It's certainly is ASP issue, but still, maybe someone have met such thing before, so I would appreciate any help..

Kvietinis

 
New Post 4/23/2008 10:16 AM
User is offline Brandon Haynes
701 posts
brandonhaynes.org
7th Ranked


Re: Unable to cast object exception 

Hi Kvietinis,

I've run across this particular problem a number of times, and it can be very frustrating to solve.  When using the Reflection.CreateObject with a providerType = "Data", DNN will construct the fully qualified object in a very specific manner.  In my experience, it is here that the problem occurs.  Look at the CreateObject overload in Reflection.vb at about line 162 for some details on how this fully qualified object name is constructed.

If I were you, I would add some debugging code before the CreateObject call to ensure that things are happening as you expect.  Something like:

object test = Framework.Reflection.CreateObject("data", "DotNetNuke.Modules.xx", ""));

HttpContext.Current.Response.Write test.GetType().Name;

HttpContext.Current.Response.Write test.GetType().BaseType.Name;

HttpContext.Current.Response.End

 

I'd use this code to ensure (a) that an object is actually created, and (b) that it actually derives from DataProvider.

Hope this gets you started.

Brandon


Brandon Haynes
BrandonHaynes.org
 
New Post 4/23/2008 10:18 PM
User is offline Ignas
25 posts
10th Ranked


Re: Unable to cast object exception 

Hello, Brandon,

i've allready looked what the type of an object, that CreateObject contructs, but I didn't looked what the BaseType of an object. Thanks, for the starting point.

Ignas

 
New Post 4/24/2008 5:22 AM
User is offline Ignas
25 posts
10th Ranked


Re: Unable to cast object exception 

The basetype of an object looks also in way that it has to (Type: DotNetNuke.Modules.xx.SqlDataProvider and the BaseType: DotNetNuke.Modules.xx.DataProvider) so I'm trying to cast DotNetNuke.Modules.xx.SqlDataProvider to DotNetNuke.Modules.xx.DataProvider. I've no idea what the problem is...

 
New Post 4/24/2008 7:28 AM
User is offline Brandon Haynes
701 posts
brandonhaynes.org
7th Ranked


Re: Unable to cast object exception 

Hi Ignas,

I'm afraid that I don't have too many additional ideas to offer.  Clearly there is some sort of strange typing problem going on. 

Have you tried searching the VS object browser for "DataProvider" and checking to make sure that there isn't a ghost object out there that isn't involved in your inheritance chain?  I've accidently misnamed a partial class before that caused problems like this.

I'd also change your (DataProvider) cast to be more explicit (DotNetNuke.Modules.xx.DataProvider), and I'd probably also play around with the debugging code a bit more to see if I could figure out why VS thinks that SqlDataProvider does not inherit from DataProvider.  Perhaps, in the same code file, create a temporary class that inherits from DataProvider.  Instantiate that class and check that its BaseType is equal to SqlDataProvider's BaseType.

Finally, is there an inner exception or any additional debugging information about the cast error?

Brandon


Brandon Haynes
BrandonHaynes.org
 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  Unable to cast object exception
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


EMAS Pro
Strategic Enrollment Management Software for Higher Education Recruitment, Retention and Financial Aid
www.emaspro.com
Subzero Solutions
Dutch / English DotNetNuke consultancy services. Custom module development in any version. Complete application integration. Small business portal hosting. Your ideas our innovation - Your success our motivation. K.v.k Amsterdam: 34236342
www.subzero-solutions.net
Hosting for DotNetNuke
SiteGround.com is the best place to host your DotNetNuke website! Expert DotNetNuke support, reliable servers, low price!
www.SiteGround.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP