Yet another Visio interop programming problem
Roger Billsdon
Posts: 14
Hi all
I've hit yet another Visio interop programming problem, this time with the simple Visio add layer method which works fine in the original program but in the SmartAssembly obfuscated version it crashes with:
Specified cast is not valid System.StubHelpers.InterfaceMarshaler.ConvertToNative(Object objSrc, IntPtr itfMT, IntPtr classMT, Int32 flags)
at Microsoft.Office.Interop.Visio.IVLayer.Add(Shape SheetObject, Int16 fPresMems)
Does anyone have any thoughts please?
Best regards
Roger
I've hit yet another Visio interop programming problem, this time with the simple Visio add layer method which works fine in the original program but in the SmartAssembly obfuscated version it crashes with:
Specified cast is not valid System.StubHelpers.InterfaceMarshaler.ConvertToNative(Object objSrc, IntPtr itfMT, IntPtr classMT, Int32 flags)
at Microsoft.Office.Interop.Visio.IVLayer.Add(Shape SheetObject, Int16 fPresMems)
Does anyone have any thoughts please?
Best regards
Roger
Comments
However, if you're sure Reflection is not involved, I'll have a big head-scrath and see if we can help further.
Do you define the Shape struct yourself or is it part of the Microsoft.Office.Interop.Visio namespace?
What field types are defined in the Shape struct and do any of them have a explicit cast that you have defined?
Many thanks for those thoughts, but I'm not processing any 3rd party assemblies or defining any shape structs. I've excluded the Microsoft.Office.Interop.Visio namespace and all of my classes that provide Visio helper functions and I've completely disabled pruning.
All the problems seem to be related to Visio functions that affect the Visio graphical user interface. For example, the select method causes the Visio shape to be surrounded by a green selection box. With this type of operation I think Visio interop can sometimes be a bit slow and I suspect more than one thread is being used so that objects requested via interop may not have been created unless you pause to allow events on the Visio UI thread to be processed. Is it possible that the thread synchronisation has somehow been changed in the obfuscated version of the program or something?
Sorry if this is a little garbled, but I don’t really know much about the internals of Visio or COM interop and this is just a little conjecture on my part as I'm now really clutching at straws.
Best regards
Roger