c# - Interaction.CreateObject creating the old Object -


i converting vb6 application c#.net , working on shared add ins. on clicking button in ms word want open application, creating object of class this.

objapp = interaction.createobject("docsys.application"); 

but line of code return old vb6 application instace while adding refrance of .net project. should .net object.

there more 1 way fumble this. forgetting make interface , classes [comvisible(true)] example. or forgetting register com server, explicitly done regasm.exe /codebase /tlb. or using wrong version of regasm.exe, 64-bit version write wrong registry keys.

more relevant createobject(), [progid] attribute on c# class essential ensure create exact substitute vb6 server. if client code ever uses binding essential [guid] attribute on interfaces , classes exact match guids used vb6 server. , of course methods , properties must exactly match ones used vb6 server, order important.

the best way compare orange apple use oleview.exe utility. run visual studio command prompt , use file + view typelib. select vb6 server first. copy/paste idl see in text file , save don't have repeatedly.

run tlbexp.exe on c# assembly create type library c# server. run oleview.exe again , select .tlb file. can compare idl server against 1 vb6 server. sure exact match on guids, methods , properties.


last not least, if client code uses interaction.createobject() .net application. means should not create [comvisible] com server @ all. should regular .net assembly, add reference , use public class directly.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -