这个问题貌似很多人都遇到了,我也不例外,但是没找到我的问题出在哪了,贴出代码大家帮我看看。
<?xml version="1.0"?>
<!-- 
  数据库连接配置
-->
<configuration>
  <configSections>
  </configSections>
  
  <!--反射 -->
  <appSettings>
    <add key="DAL" value="BoteAutoWMS.SQLServerDAL"/>
  </appSettings>
  
  <!--连接字符串-->
  <connectionStrings>
    <add name="DBconnstring" connectionString="Server=.;uid=sa;pwd=123;database=BoteAutoCMS" providerName="System.Data.SqlClient" />
  </connectionStrings></configuration>
    /// <summary>
    /// 创建抽象工厂模式
    /// </summary>
    public class DataAccess
    {        /// <summary>
        /// 
        /// </summary>
        private static readonly string path = ConfigurationManager.AppSettings["DAL"].ToString().Trim();        /// <summary>
        /// 创建用户层数据接口
        /// </summary>
        /// <returns></returns>
        public static BoteAutoWMS.IDAL.IAdminUser CreateAdminUser()
        {
            try
            {
                string className=path +".AdminUser";
                return (IDAL.IAdminUser)Assembly.Load(path).CreateInstance(className);
            }
            catch(Exception er)
            {
                throw new Exception(er.Message);
            }
        }
    }没发现哪有不合适的地方

解决方案 »

  1.   

    错误是BLL.AdminUser类型初始值设定项引发异常
      

  2.   

    {"无法将类型为“BoteAutoWMS.SQLServerDAL.AdminUser”的对象强制转换为类型“BoteAutoWMS.IDAL.IAdminUser”。"
    "   在 BoteAutoWMS.BLL.AdminUser.CheckUserLogin(AdminInfo admininfo)\r\n   在 BoteAutoWMS.frmLogin.lblSumbit_Click(Object sender, EventArgs e) 位置 D:\\coding\\BoteAutoWMS\\BoteAutoWMS\\BoteAutoWMS\\frmLogin.cs:行号 96\r\n   在 System.Windows.Forms.Control.OnClick(EventArgs e)\r\n   在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\r\n   在 System.Windows.Forms.Control.WndProc(Message& m)\r\n   在 System.Windows.Forms.Label.WndProc(Message& m)\r\n   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n   在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n   在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n   在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n   在 System.Windows.Forms.Form.ShowDialog(IWin32Window owner)\r\n   在 System.Windows.Forms.Form.ShowDialog()\r\n   在 BoteAutoWMS.Program.Main() 位置 D:\\coding\\BoteAutoWMS\\BoteAutoWMS\\BoteAutoWMS\\Program.cs:行号 21\r\n   在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n   在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   在 System.Threading.ThreadHelper.ThreadStart()"
      

  3.   

    你BLL里面有没有AdminUser这个类?名字要完全相同的