Dbtocodedemo example project source code dalfactory cannot reflect common error descriptions for creating class instances

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.