Some of my friends often encounter a class creation error that cannot be reflected in the dalfactory class factory when working on the code of a three-tier architecture sample project based on the interface and factory mode provided by me. If you have encountered the same problem, please refer.
Dalfactory source code:
String Path = system. configuration. configurationsettings. receivettings ["Dal"]; // obtainProgramSet Name
String cachekey = path + ". sysmanage"; // Assembly + class name, get the full name of the class type
Object objtype = datacache. getcache (cachekey );
If (objtype = NULL)
{
Try
{
Objtype = assembly. Load (PATH). createinstance (cachekey); // rows with frequent errors
Datacache. setcache (cachekey, objtype); // write Cache
}
Catch (system. Exception ex)
{
String STR = ex. message;
}
}
Return (addesktop. idal. isysmanage) objtype;
Error description:
1. Whether each layer is an independent assembly(Independent project)
Because the path in assembly. Load (PATH) must be the name of an Assembly, rather than the name of the class namespace.
2. Check whether the data layer has implemented the interface..
Whether the specific classes under sqlserverdal implement the interface definition, such:
3. Check that the Assembly name and namespace are inconsistent..
Because assembly. Load (PATH), the path must be the name of an assembly.
Createinstance (cachekey) The cachekey here is actually the full name of the type to be reflected (including the full path of the namespace ).
Therefore, make sure that the Assembly name is consistent with the namespace. In this way, the full name of the type = Assembly name + class name is obtained.
Otherwise, you need to replace cachekey with the actual full name of the type.
4. Check whether sqlserverdal project reference is added to the BLL layer..
If you find there are other problems, you can paste them back for everyone to learn.
Latest Version Download: http://www.maticsoft.com/softdown.aspx