I recently implemented the SQL UDF/CLR solution found in this thread to help me with recurrence parsing:
I am now getting the following error when running the store procedure that uses the UDF:
"Failed to open malformed assembly 'mscorlib' with HRESULT 0x80070008."
The error is directly related to the SP attempting to call the UDF.
I've included a copy of the stored procedure that is throwing the error.
Any ideas on what might be causing the issue?
CREATE PROCEDURE [dbo].[sp_Events_GetNext10EventsIncludeRecurring]
SET NOCOUNT ON;
DECLARE @StartDate DATETIME;
DECLARE @EndDate DATETIME;
SET @StartDate = CAST(CONVERT(VARCHAR,GETDATE(),21) AS DATETIME);
SET @EndDate = CAST(CONVERT(VARCHAR,GETDATE()+365,21) AS DATETIME);
-- List all appointments (recurring or not) in the given range
SELECT TOP 10 a.[EventID] as [EventID], a.[EventName] as [EventName], a.[Description] as [Description], a.[Location], ISNULL(o.StartDate, a.[StartDateTime]) as [StartDateTime], ISNULL(o.EndDate, a.[EndDateTime]) as [EndDateTime], a.[RecurrenceRule] as [RecurrenceRule], a.[RecurrenceParentID] as [RecurrenceParentID], a.[EventTypeID] as [EventTypeID], a.[EventType] as [EventType], a.[EventCategoryID] as [EventCategoryID], a.[EventCategory] as [EventCategory], a.[VenueID] as [VenueID], a.[VenueName] as [VenueName], a.[IsCityVenue] as [IsCityVenue], a.[RSVP] as [RSVP], a.[MinAttendees] as [MinAttendees], a.[MaxAttendees] as [MaxAttendees], a.[Notes] as [Notes], a.[AddedBy] as [AddedBy], a.[EditedBy] as [EditedBy], a.[DateAdded] as [DateAdded], a.[LastEdited] as [LastEdited], a.[Status] as [Status]
FROM [vw_Details_Events_Active] a
OUTER APPLY [dbo].[ExpandRecurrence](a.[RecurrenceRule], @Startdate, @EndDate) AS o
-- Include non-recurring appointments in the range
(a.[RecurrenceRule] IS NULL AND a.[StartDateTime] < @EndDate AND a.[EndDateTime] > @StartDate) OR
-- And recurring appointments in range.
(a.[RecurrenceRule] IS NOT NULL AND o.[StartDate] < @EndDate AND o.[EndDate] > @StartDate)
ORDER BY [StartDateTime]