c# - No definition and no extension method of assembly method missing? -


it's common error , i'm able solve it.

i have class:

hierarchydata.cs

using system; using system.collections.generic; using system.linq; using system.web; using system.configuration; using system.data; using system.data.sqlclient;  namespace ct_wmt.app_code {     public class hierarchydata     {         string sqlconnectionstring = configurationmanager.connectionstrings["snaggingmasterconnection"].connectionstring;          public datatable gethierarchydata()         {             using (sqlconnection connection = new sqlconnection(sqlconnectionstring))             {                 sqlcommand command = new sqlcommand("sp_gethierachy", connection);                 command.commandtype = commandtype.storedprocedure;                  datatable dt = new datatable();                  try                 {                     command.connection.open();                     dt.load(command.executereader());                 }                 catch (exception ex)                 {                     string errormessage = ex.message.tostring();                 }                  return dt;             }         }     } } 

here's calling webform:

screenshot

i think i'm missing , it's right in front of eyes!

the system cannot distinguish between hierarchydata page (full name ct_wmt.secure.hierarchydata.hierarchydata) , hierarchydata data loading class (full name ct_wmt.app_code.hierarchydata).

you can:

  1. use full name:

    ct_wmt.app_code.hierarchydata myclass = new ct_wmt.app_code.hierarchydata(); datatable dt = myclass.gethierarchydata(); 
  2. declare alias hierarchydata data loading class

    using hierarchydataloader = ct_wmt.app_code.hierarchydata;  ... hierarchydataloader myclass = new hierarchydataloader(); datatable dt = myclass.gethierarchydata(); 
  3. rename 1 or both of them each class has unique name, e.g. add page suffix page, or loader suffix loader class.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -