Error in dynamically loading DAL provider

Error in dynamically loading DAL provider

Old forum URL:

kyuze posted on Saturday, December 17, 2011

Hello, Rocky.

I am implementing the (preferred) encapsulated model using provider pattern.  Any idea why I get the following error in my DALFactory? This seems to be referencing a file local to your machine?

Locating source for 'D:\Users\Illiante\Documents\Visual Studio 2010\Projects\csla\Source\Csla\Reflection\MethodCaller.cs'. Checksum: MD5 {76 4e 81 85 6c 39 8b 4a 5d 2a 2 86 28 c0 c4 8d}

The file 'D:\Users\Illiante\Documents\Visual Studio 2010\Projects\csla\Source\Csla\Reflection\MethodCaller.cs' does not exist.

My code looks like:

namespace TechSlice.DAL
    public static class DALFactory
        private static Type _dalType;

        public static IDALManager GetManager()
            if (_dalType == null)
                var dalTypeName = ConfigurationManager.AppSettings["DalManagerType"];
                if (!string.IsNullOrEmpty(dalTypeName))
                    _dalType = Type.GetType(dalTypeName);
                    throw new NullReferenceException("DalManagerType");
                if (_dalType == null)
                    throw new ArgumentException(string.Format("Type {0} could not be found", dalTypeName));
            return (IDALManager)Activator.CreateInstance(_dalType);

Value of key in App.config is "TechSlice.DAL.Mock.DALManager,TechSlice.DAL.Mock"


kyuze replied on Saturday, December 17, 2011

p.s. I am running the latest version, CSLA 4.2.2.

RockfordLhotka replied on Sunday, December 18, 2011

That error is because Visual Studio is trying to load the source file so you can step through the code. Perhaps the pdb file contains my build path as one location where it looks for the source.

That has nothing to do with the actual issue you are seeing which would be revealed by the runtime exception information. It is that information (along with the stack trace) we need to see to help you.

kyuze replied on Monday, December 19, 2011

Here is the call stack.  The error is : Csla.DataPortalException: DataPortal.Fetch failed (Type TechSlice.DAL.Mock.DALManager,TechSlice.DAL.Mock could not be found) ---> Csla.Reflection.CallMethodException: DataPortal_Fetch method call failed ---> System.ArgumentException: Type TechSlice.DAL.Mock.DALManager,TechSlice.DAL.Mock could not be found

My DALFactory is located in TechSlice.DAL and DALManager is located in namespace TechSlice.DAL.Mock.  The value I assign to dalTypeName in DALFactory is "TechSlice.DAL.Mock.DALManager,TechSlice.DAL.Mock".

> Csla.dll!Csla.Reflection.MethodCaller.CallMethod(object obj, Csla.Reflection.DynamicMethodHandle methodHandle, object[] parameters) Line 547 C#

  Csla.dll!Csla.Reflection.MethodCaller.CallMethod(object obj, string method, object[] parameters) Line 413 + 0xe bytes C#

  Csla.dll!Csla.Reflection.LateBoundObject.CallMethod(string method, object[] parameters) Line 93 + 0x19 bytes C#

  Csla.dll!Csla.Server.SimpleDataPortal.Fetch(System.Type objectType, object criteria, Csla.Server.DataPortalContext context) Line 131 + 0x56 bytes C#

  Csla.dll!Csla.Server.DataPortalSelector.Fetch(System.Type objectType, object criteria, Csla.Server.DataPortalContext context) Line 77 + 0x13 bytes C#

  Csla.dll!Csla.Server.DataPortal.Fetch(System.Type objectType, object criteria, Csla.Server.DataPortalContext context) Line 195 + 0x12 bytes C#

  Csla.dll!Csla.DataPortalClient.LocalProxy.Fetch(System.Type objectType, object criteria, Csla.Server.DataPortalContext context) Line 49 + 0x1b bytes C#

  Csla.dll!Csla.DataPortal.Fetch(System.Type objectType, object criteria) Line 215 + 0x12 bytes C#

  Csla.dll!Csla.DataPortal.Fetch<TechSlice.Lib.PersonEditBO>(object criteria) Line 170 + 0x3f bytes C#

  TechSlice.Lib.dll!TechSlice.Lib.PersonEditBO.GetPersonEditBO(int id) Line 61 + 0x29 bytes C#

  TechSlice.UI.exe!TechSlice.UI.Form1.button1_Click(object sender, System.EventArgs e) Line 22 + 0x27 bytes C#

  [External Code]

  TechSlice.UI.exe!TechSlice.UI.Program.Main() Line 18 + 0x1d bytes C#

JonnyBee replied on Monday, December 19, 2011

See this thread: 

Same issue.

kyuze replied on Tuesday, December 20, 2011

Thanks, JonnyBee.  As a temporary work around, I had created another layer that allows me to have a reference to my DALManager dll in my DALFactory project while still maintaining a reference to the DALFactory in the DALManager without creating a circular reference.  This obviously was not sustainable. Thanks again for your help.

Copyright (c) Marimer LLC