Click here to Skip to main content
15,902,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey there :)
I am currently trying to find a way to import an .ICS link/URL in my calendar. I tried using one I found here on this site: Dday.Ical (https://www.codeproject.com/Articles/17980/Adding-iCalendar-Support-to-Your-Program-Part-1), but kept getting the exception: System.TypeLoadException.. I have the newest version of .NET framework and also I added the DDay.iCal package.

The code I am executing is (also as shown in the link):
C#
using System;
using System.Collections.Generic;
using System.Text;

// Required DDay.iCal namespace
using DDay.iCal;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Load the calendar file
            IICalendarCollection calendars = iCalendar.LoadFromFile(@"Business.ics");

            //
            // Get all events that occur today.
            //
            IList&occurrence> occurrences = calendars.GetOccurrences
				(DateTime.Today, DateTime.Today.AddDays(1));

            Console.WriteLine("Today's Events:");

            // Iterate through each occurrence and display information about it
            foreach (Occurrence occurrence in occurrences)
            {
                DateTime occurrenceTime = occurrence.Period.StartTime.Local;
                IRecurringComponent rc = occurrence.Source as IRecurringComponent;
                if (rc != null)
                    Console.WriteLine(rc.Summary + ": " + 
				occurrenceTime.ToShortTimeString());
            }

            //
            // Get all occurrences for the next 7 days, starting tomorrow.
            //
            occurrences = calendars.GetOccurrences
		(DateTime.Today.AddDays(1), DateTime.Today.AddDays(7));

            Console.WriteLine(Environment.NewLine + "Upcoming Events:");

            // Start with tomorrow
            foreach (Occurrence occurrence in occurrences)
            {
                DateTime occurrenceTime = occurrence.Period.StartTime.Local;
                IRecurringComponent rc = occurrence.Source as IRecurringComponent;
                if (rc != null)
                    Console.WriteLine(rc.Summary + ": " + occurrenceTime.ToString());
            }
        }
    }
}


I have got no clue why it is not working.. are there maybe easier ways to import events to a calendar in an android app?

What I have tried:

I have tried the things I mentioned in the question
Posted
Updated 16-Dec-18 5:17am

1 solution

You should post your question in the forum at the end of the article so the author of the iCalendar class can help you.
 
Share this answer
 
v2
Comments
Member 14091316 16-Dec-18 13:00pm    
It's a very old post, which is why I wouldn't rely on it too much
Richard MacCutchan 17-Dec-18 4:10am    
So why are you using it?
Member 14091316 17-Dec-18 5:20am    
I wouldn't rely on people responding!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900