Exception when calling DataPortal.Fetch

Exception when calling DataPortal.Fetch

Old forum URL: forums.lhotka.net/forums/t/7824.aspx


Devman posted on Tuesday, October 20, 2009

Hi,

Im a newbie and cant see what the issue is here.

Im using CSLA 3.6.1,I have a BO which derives from BusinessBase and a Static method GetById() which calls the DataPortal.Fetch(). This is in the assembly XXX.Domain. I also have a test as shown below

[Test]
public void can_get_item_with_hierarchy()
        {
            Item i = Item.GetById(new Guid("6da31878-fd2c-4446-bc9c-9c9200c8e2ee"));
            Assert.That(i.ChildLinks.Count > 0);
        }
This is in the assembly XXX.Domain.Tests and the test passes with no problems, so far so good.

However when i try to call the same piece of code ie

Item i = Item.GetById(new Guid("6da31878-fd2c-4446-bc9c-9c9200c8e2ee"));

from my UI assembly i get the following error as the DataPortal.Fetch is called;

"The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047"

After googling the error I tried  unchecking the "Enable the Visual Studio Hosting Process" option in Project properties to no avail. Has anyone else had and solved this issue? Any help would be much appreciated. :o)

The full error is below;

System.IO.FileLoadException was unhandled
  Message="The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)"
  Source="mscorlib"
  StackTrace:
       at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
       at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
       at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
       at System.Type.GetType(String typeName)
       at Csla.Server.ObjectFactoryLoader.GetFactoryType(String factoryName)
       at Csla.Server.DataPortalMethodCache.GetFetchMethod(Type objectType, Object criteria)
       at Csla.DataPortal.Fetch(Type objectType, Object criteria)
       at Csla.DataPortal.Fetch[T](Object criteria)
       at Csla.Extentions.PBusinessBase`1.GetById(Guid id) in C:\WORKING\Visual Studio 2008\Projects\proxima\src\CSLA.Extentions\PBusinessBase.cs:line 101
       at Proxima.WPF.Tests.WorkSpaceTest.Button_Click(Object sender, RoutedEventArgs e) in C:\WORKING\Visual Studio 2008\Projects\proxima\src\Proxima.WPF.Tests\WorkSpaceTest.xaml.cs:line 483
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
       at System.Windows.Controls.Primitives.ButtonBase.OnClick()
       at System.Windows.Controls.Button.OnClick()
       at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
       at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
       at System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e)
       at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at Proxima.WPF.Tests.App.Main() in C:\WORKING\Visual Studio 2008\Projects\proxima\src\Proxima.WPF.Tests\obj\Debug\App.g.cs:line 0
  InnerException:










RockfordLhotka replied on Tuesday, October 20, 2009

The data portal dynamically loads the business assembly based on the type information you provide. This means that your business library DLL must exist in the .NET type loader path where the data portal is running.

So if the data portal is running in local mode, the library DLL must be in the same folder as your client EXE.

Or if the data portal is running in remote mode, the library DLL must be in the \bin folder of your application server's virtual root.

Devman replied on Wednesday, October 21, 2009

Cheers for the quick reply Rocky,

Well dont I feel daft now, I had all the assemblies in the right place, but my App.config had gone astray. Ooops :).

Thanks again



Copyright (c) Marimer LLC