Solved! My naivete has served me well, in spite of the fact that my F# newbieness has not. It seems that my constructed type had some glitches, in spite of the fact that it seemed to compile just fine. Apparently, the "constructor" part of the type has problems with "naked" imperative statements (i.e., statements not preceded by a "do" keyword) such as the following:

1
2
3
4
5
type RequirementsDocument(doc : Microsoft.Office.Interop.Word.Document) =
	let mutable theDocument = doc
	let mutable theMainDocument = doc.Content
	doc.add_ContentControlOnEnter(new DocumentEvents2_ContentControlOnEnterEventHandler(fun cc -> (ContentControlEnter cc)))
	doc.add_ContentControlOnExit(new DocumentEvents2_ContentControlOnExitEventHandler(fun cc cancel -> (ContentControlExit cc cancel)))

Changing this to the following seems to have done the trick:

1
2
3
4
5
type RequirementsDocument(doc : Microsoft.Office.Interop.Word.Document) =
	let mutable theDocument = doc
	let mutable theMainDocument = doc.Content
	do doc.add_ContentControlOnEnter(new DocumentEvents2_ContentControlOnEnterEventHandler(fun cc -> (ContentControlEnter cc)))
	do doc.add_ContentControlOnExit(new DocumentEvents2_ContentControlOnExitEventHandler(fun cc cancel -> (ContentControlExit cc cancel)))

Can anyone shed some light on why this change fixed the problem, and why the original code wasn't flagged by the compiler?

Thanks

By on 5/30/2008 10:20 AM ()

Hi there,

If you get a chance to post the original code to "fsbugs" at microsoft then please do so.

Kind regards

Don

By on 6/7/2008 11:41 PM ()

Hi Don,

I just sent it off.

Keep up the good work, by the way!

Cheers,
Fred

By on 6/8/2008 9:33 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper