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  |  

$4.95 Windows Hosting at Webhost4life.com
  Ads  
OnyakTech
 


  Sponsors  

Meet Our Sponsors

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.
SmarterTools
Verndale
The Official Microsoft ASP.NET Website
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  VS Class question?
Previous Previous
 
Next Next
New Post 4/14/2008 12:43 PM
User is offline Blake Harris
18 posts
10th Ranked


VS Class question? 

I know this my not be the appropriate forum to post this but I need some help and I know that DNN developers are the best to ask. I am developing a module for a DNN site. I have numerous class files each containing different Procedures. These classes are based on quarters of the year. For example (Q12008.vb ,Q22008.vb, Q32008vb, etc.) The reason that I have these class files is because my procedures change each quarter.

My question is how can I call these classes in a dynamic way. PLEASE HELP!

Example:

Dim x as string

x = Q12008

call class (x)

X.DoThisProcedure

 

 

 
New Post 4/14/2008 1:41 PM
User is offline Fooberichu
467 posts
www.seeleyware.com
8th Ranked


Re: VS Class question? 

I'm going to give a crappy answer (no code samples) but hopefully it gets you to start looking in the right direction -- you'll need to use Reflection to load up those classes dynamically and then work with them.  If you have them all inheriting from a base class you can use reflection to load them and then cast them to the base class and call the methods (if the base class were abstract, for example).

Doing a simple Google search for .NET Reflection gave a few results that may or may not be good:

http://msdn2.microsoft.com/en-us/library/ms227224(VS.80).aspx

http://my.execpc.com/~gopalan/dotnet/reflection.html


-- Fooberichu
http://www.seeleyware.com
 
New Post 4/14/2008 7:52 PM
User is offline Blake Harris
18 posts
10th Ranked


Re: VS Class question? 

I have been trying multiple ways to use Reflection but with no success. I am not doing it in the right way. Can somebody give me an example? I have looked at multiple sites but so far no luck in finding a good example. PLEASE HELP ME!!!

 
New Post 4/14/2008 8:48 PM
User is offline JK
351 posts
www.bestwebsites.co.nz
8th Ranked


Re: VS Class question? 

Reflection is not easy the first time ;)

It can work like this (this is just one of many possible ways):

Dim typeName = "Q12008"
Dim t As Type
= Type.GetTypeFromProgID(typeName)
Dim x As Object = Activator.CreateInstance(t)
Dim flags As BindingFlags = BindingFlags.IgnoreCase Or BindingFlags.Instance Or BindingFlags.InvokeMethod Or BindingFlags.Public
Dim myParam As Object = "hello world"
Dim arguments As Object() = {myParam}
Dim pm As ParameterModifier() = {New ParameterModifier(1)}
pm(0)(0) = False ' false for input param, true for output param
t.InvokeMember("DoThisProcedure", flags, Nothing, x, arguments, pm, Nothing, Nothing)

See .. its simple ;) 

JK


You know your website is cool, so why not let your users help you by spreading the word on social networking sites - get the DotNetNuke Social Bookmarks Module with 55 different ways to add social bookmarks to your site ... or download the FREE demo right now
 
New Post 4/15/2008 1:31 PM
User is offline Blake Harris
18 posts
10th Ranked


Re: VS Class question? 

JK,

Thanks for the reply. The code is not working though. It throws a Null reference execption at the Dim X as Object line. The reason why is because t is nothing. Is there something else that I can use besides Type.GetTypeFromProgID ?

 

Thanks!

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  VS Class question?
 


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.

 


DotNetNuke Marketplace - Modules & Skins
The DotNetNuke Marketplace is the official e-commerce gateway for the DNN ecosystem. It's the place to buy and sell DotNetNuke modules, DotNetNuke skins, and other DNN offerings.
DotNetNuke Marketplace
ExactTarget Email Marketing Software and Solutions
ExactTarget delivers on-demand email software solutions for permission-based email marketing. ExactTarget offers solutions that meet the needs of all industry verticals and all size organizations, including SMB, corporate divisions, not-for-profits, large retail/direct marketers, agencies and enterprises.
ExactTarget.com
Sunset Hill Solutions - Consulting and Development
We offer general DNN consulting services - including custom module development and commercial module integration/setup.
www.sunsethill.ca

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