This is a migrated thread and some comments may be shown as answers.

Exception when trying to load assembly with custom functions

2 Answers 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Håvard
Top achievements
Rank 1
Håvard asked on 03 Sep 2015, 09:37 PM

I have a very small library which consists of a single class;

 public static class DateTimeFunctions
    {
        [Function(Category = "​xxx", Namespace = "​xxx", Description = "Get the start of current month")]
        public static DateTime StartOfMonth()
        {
            var now = DateTime.Now;
            return new DateTime(now.Year, now.Month, 1);
        }

        [Function(Category = "​xxx", Namespace = "xxx", Description = "Get the end of current month")]
        public static DateTime EndOfMonth()
        {
            return StartOfMonth().AddMonths(1) - TimeSpan.FromSeconds(1);
        }
    }

 In my app.config file I have the following:

 

configuration>
  <configSections>
    <section name="Telerik.Reporting"
             type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting"
             allowLocation="true"
             allowDefinition="Everywhere"/>
  </configSections>

  <Telerik.Reporting>
    <AssemblyReferences>
      <add name="Name.Of.My.Assembly" version="1.0.0.0" culture="neutral" publicKeyToken="null" />
    </AssemblyReferences>
  </Telerik.Reporting>​

I have verified that both Telerik.Reporting.dll and my own assembly is located in the root folder of my applicattion.

 When I try to load the WPF ReportViewer component I get the following exception

Object reference not set to an instance of an object.

at Telerik.ReportViewer.Wpf.ReportViewerModel.ApplyValuesOnReportSource(ReportSource rs)
   at Telerik.ReportViewer.Wpf.ReportViewerModel.CreateReportSourceSnapshot(ReportSource source)
   at Telerik.ReportViewer.Wpf.ReportViewerModel.CreateHistoryRecord(ReportSource source, Boolean isTemporary)
   at Telerik.ReportViewer.Wpf.ReportViewerModel.LogHistory(ReportSource source, LogHistoryRecord logHistory, Boolean logTemporaryHistoryRecord)
   at Telerik.ReportViewer.Wpf.ReportViewerModel.RefreshReportCore(Boolean reloadParameters, LogHistoryRecord logHistory)
   at Telerik.ReportViewer.Wpf.ReportViewerModel.RefreshReport()
   at Telerik.ReportViewer.Wpf.ReportViewer.Refresh()
   at Telerik.ReportViewer.Wpf.ReportViewer.OnLoaded(Object sender, RoutedEventArgs e)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at MS.Internal.FrameworkObject.OnLoaded(RoutedEventArgs args)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Interop.HwndTarget.OnResize()
   at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(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, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

2 Answers, 1 is accepted

Sort by
0
Håvard
Top achievements
Rank 1
answered on 03 Sep 2015, 09:52 PM

I resolved the issue. I'll post the solution in case someone else makes the same mistake as me: 

 The problem was that I included the class name in my report binding [=My.Assembly.DateTimeFunctions.StartOfMonth()] but the class name should actually be omitted, I suppose it might be because I declared the namespace like this (not included in the original post):

 [Function(Category = "​xxx", Namespace = "​My.Assembly", Description = "Get the start of current month")]

0
Stef
Telerik team
answered on 07 Sep 2015, 12:48 PM
Hi Håvard,

I am glad to hear the issue is resolved.

For anyone concerned, please check the Previewing a report definition that uses an external assembly KB article, The article elaborates on how to deploy reports with custom functions.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Håvard
Top achievements
Rank 1
Answers by
Håvard
Top achievements
Rank 1
Stef
Telerik team
Share this question
or