Red Gate forums :: View topic - Yet another Visio interop programming problem
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 5
SmartAssembly 5 forum

Yet another Visio interop programming problem

Search in SmartAssembly 5 forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
Roger Billsdon



Joined: 31 Jul 2010
Posts: 9
Location: Cambs, UK

PostPosted: Tue Aug 03, 2010 11:43 am    Post subject: Yet another Visio interop programming problem Reply with quote

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
Back to top
View user's profile Send private message
slaphead99



Joined: 10 Mar 2010
Posts: 93

PostPosted: Wed Aug 04, 2010 1:59 pm    Post subject: Reply with quote

I searched our whole database of calls and could not find once instance with the string "Specified cast is not valid". My instinct here is that Reflection is involved so a call-by-name is being defeated by an obfuscated method name. If that sounds like it is the case, you would need to exclude this method from being obfuscated by using the "Exclusions" feature within the Obfuscation section in the GUI.

However, if you're sure Reflection is not involved, I'll have a big head-scrath and see if we can help further.
Back to top
View user's profile Send private message
Paul.Martin



Joined: 03 Feb 2010
Posts: 83
Location: Cambridgeshire

PostPosted: Fri Aug 06, 2010 12:21 am    Post subject: Reply with quote

I haven't done any Office interop work, but at a guess something is happening to the Shape struct's data members.

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?
Back to top
View user's profile Send private message
slaphead99



Joined: 10 Mar 2010
Posts: 93

PostPosted: Fri Aug 06, 2010 2:46 pm    Post subject: Reply with quote

Just to tie-up this and your other post- are you processing any 3rd party assembly with smartassembly? Is rare that this ever works.
Back to top
View user's profile Send private message
Roger Billsdon



Joined: 31 Jul 2010
Posts: 9
Location: Cambs, UK

PostPosted: Fri Aug 06, 2010 7:07 pm    Post subject: Reply with quote

Hi both

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
Back to top
View user's profile Send private message
slaphead99



Joined: 10 Mar 2010
Posts: 93

PostPosted: Mon Aug 09, 2010 5:11 pm    Post subject: Reply with quote

I'm pretty sure smartassembly doens't touch any threading logic or thread primitives. I still wonder if there's any serialization going on...
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group