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# / July 2007

Tip: Looking for answers? Try searching our database.

Type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
OldButStillLearning - 16 Jul 2007 16:02 GMT
I want to use a static method of a class using only the text name of the
class and the text name of the method.

The Assembly Name for this Static class is "DALLibrary"
The Namespace name for the Static Class is "GL.DAL"
The Class name of the Static class is "GL_ACCOUNT_TBL_DAL"

I tried to create a "Type" object with the following set of instructions...

string myclass = "DALLibrary.GL.DAL.GL_ACCOUNT_TBL_DAL";
Type myType = Type.GetType(myclass);

This returns "null".  What is wrong with how I am constructing my "Type"?

Thanks in advance for your assistance!!
Tom Porterfield - 16 Jul 2007 16:23 GMT
> I want to use a static method of a class using only the text name of the
> class and the text name of the method.
[quoted text clipped - 9 lines]
>
> This returns "null".  What is wrong with how I am constructing my "Type"?

As it appears that GL_ACCOUNT_TBL_DAL is in a different assembly, you
need to pass the assembly qualified name to your GetType call.  That
format would like similar to:

TopNamespace.SubNameSpace.ContainingClass+NestedClass, MyAssembly,
Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
Signature

Tom Porterfield

OldButStillLearning - 16 Jul 2007 16:36 GMT
As my example shows, I am passing the assembly name...
Tom Porterfield - 16 Jul 2007 16:44 GMT
> As my example shows, I am passing the assembly name...

And as my reply shows in comparison, you are passing it incorrectly.
Yours should look something like:

GL.DAL.GL_ACCOUNT_TBL_DAL, DALLibrary, Version=<assembly version>,
Culture=neutral, PublicKeyToken=<assembly public key>

Replace <assembly version> with the version of DALLibrary.  Replace the
neutral culture with the assembly culture if it has one.  Replace
<assembly public key> with the public key token for the assembly, or
null if it doesn't have one.  The basic format is:

Namespace.Class, Assembly, Version, Culture, PublicKeyToken
Signature

Tom Porterfield

OldButStillLearning - 16 Jul 2007 20:16 GMT

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.