none
Microsoft.Office.Interop.MSProject: unknown exception is raised when I call resource.Calendar.Exceptions.Add(..) method

    Question

  • Hi guys!

    Could anybody help me to understand what is wrong?

    The task I'm trying to do: add object of type Microsoft.Office.Interop.MSProject.Exception to collection of exception items (this ‘exception’ class represents a vacation and is used within calendar).

    I found only one way to do this  - using of Add method of Exceptions collection. But when I invoke it interop library throws some exception that could not identificate itself – no information what kind of exception occurred, only a notice that smth. failed. It confuses me.

    Here is some code to understand what I’m doing. Maybe I’m wrong somewhere but regarding to this page http://msdn.microsoft.com/en-us/library/bb178424.aspx everything looks fine.

    Resource resource = DADataProvider .Instance.Application.ActiveProject.Resources[resourceId];
    
    resource.Calendar.Exceptions.Add(
    
    PjExceptionType .pjYearlyPositional, vacation.Start, vacation.Finish, 0, vacation.Type, 0, 0, 0, 0, 0, 0);


    vacation.Start, vacation.Finish – objects of DateTime type, vacation.Type - string

    public class Vacation
    
        {
    
            private readonly int _resourceId;
    
            private DateTime _start;
    
            private DateTime _finish;
    
            private string _type;
    
    
            public Vacation(int resId)
    
            {
    
                _resourceId = resId;
    
            }
    
     
    
            public int ResourceId
    
            {
    
                get { return _resourceId; }
    
            }
    
     
    
            public DateTime Start
    
            {
    
                get { return _start; }
    
                set { _start = value ; }
    
            }
    
     
    
            public DateTime Finish
    
            {
    
                get { return _finish; }
    
                set { _finish = value ; }
    
            }       
    
     
    
            public string Type
    
            {
    
                get { return _type; }
    
                set { _type = value ; }
    
            }
    
        }
    Any help would be very appreciated!


    Dmitry [dimaka] Pavlov
    Monday, June 08, 2009 8:59 AM

Answers

  • Hi Dmitry

    I recommend you ask this question in the Project Developement newsgroup. You'll find a link in the forum's Please Read First message.

    the VSTO forum targets the VSTO technology and not general automation of individual Office applications. The only thing VSTO has for Project is a Visual Studio .NET template for creating a VSTO add-in. But it in no way extends or does anything with the Project object model. So you'll find little to no technical expertise for "how do I.." types of questions for Project.

    When you post, please always remember to specify which version of Project (or any other office application) you're working with.
    Cindy Meister, VSTO/Word MVP
    Monday, June 08, 2009 10:05 AM
    Moderator

All replies

  • Hi Dmitry

    I recommend you ask this question in the Project Developement newsgroup. You'll find a link in the forum's Please Read First message.

    the VSTO forum targets the VSTO technology and not general automation of individual Office applications. The only thing VSTO has for Project is a Visual Studio .NET template for creating a VSTO add-in. But it in no way extends or does anything with the Project object model. So you'll find little to no technical expertise for "how do I.." types of questions for Project.

    When you post, please always remember to specify which version of Project (or any other office application) you're working with.
    Cindy Meister, VSTO/Word MVP
    Monday, June 08, 2009 10:05 AM
    Moderator
  • Hi Cindy, 

    Thank you for the tip. I have posted my question here in the "Discussions in Microsoft Project General Questions": http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.project&lang=en&cr=US

    It seems it requires some time to be published - I don't see it in the questions list for now. But I hope it will appear there. I named the question as "Unknown exception is raised when I call resource.Calendar.Exceptions.Add(..) method". So everybody can search fo that title later if needed. 

    Best wishes, 

    Dmitry [dimaka] Pavlov
    Monday, June 08, 2009 12:39 PM