Click here to Skip to main content
12,458,246 members (54,553 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
List formatters = BillingFileManager.GetFormatterByIdWithChilden((Guid)QueueInfo.BillingFileFormatterId);
foreach (BillingFileFormatter formatter in formatters)
{
List LineItemList = new List();
ACH testobject = new ACH();
//string typeName = "Billing.Ach." + formatter.ClassName + ", Billing.Ach, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
string typeName = formatter.ClassName;
Type filetype = Type.GetType(typeName);
IBillingFile billingFile = (IBillingFile)Activator.CreateInstance(filetype);
LineItemList = billingFile.ProcessBillingQueue(QueueInfo, new List(OrdersToProcess.Values.ToList()));



Above is the code that is failing for me, the GetType is coming back null and I dont know why. Any help would be appreciated.
Posted 25-Dec-12 19:04pm
bobb024397
Comments
   
I don't think your observation is correct. You need to execute it under the debugger to see what happens. Check up the string value you pass to Type.GetType and make sure it represents the really existing type. But better — don't do it. This is not a good way to obtain some instance of System.Type.

Also, you need to explain what you want to achieve. Your could does not seem to make any sense at all.

—SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Please see my comment to the question. You really need to explain what do you want to achieve.

You are using the static method System.Type.GetType(System.String): http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx[^].

Read this help page. This method really should not give you non-null value. It will be null if the string does not represent any existing type.

I doubt you really need it.

—SA
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

thank you guys, I had the namespace incorrectly referenced and until I create the other iBillingFile References in the Billing.Ach class library, I just did IBillingFile billingFile = new ACH();. I was trying to make a generic wrapper for all the different types of Objects inside the ACH class library. I really appreciate all the help!!!
  Permalink  
Comments
Sergey Alexandrovich Kryukov 29-Apr-13 18:10pm
   
Not an answer, should be removed.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 26 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100