tinklerj

Excel VBA addin calling .NET assembly calling PI-SDK: 64-bit COM interop issue?

Discussion created by tinklerj on Sep 10, 2013
Latest reply on Sep 11, 2013 by tinklerj

This issue may not be related to OSIsoft PI-SDK at all but it's hard to tell...

 

I have an Excel addin written in VBA which calls a .NET assembly written by me (uses .NET Framework 4.0) which in turn calls PI-SDK.

 

This used to work OK under Windows XP and Excel 2010 x86.

 

Now I have been given a new PC with WIndows 7 x64 and Office x64.  The addin will no longer run (Error 429: ActiveX component can't create object).

 

My .NET assembly is built (in VS2010) as MSIL (AnyCPU) so I would have thought it can run in 64-bit mode.  So maybe it is PI-SDK.

 

I rebuild my assembly for 64-bit platform and make sure to use 64-bit PI-SDK references from the GAC.

 

Here I hit a bug in Visual Studio: it doesn't automatically call 64-bit regasm to register a 64-bit COM object even when the project file tells it to.

 

So I try entering the command by hand:

 

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm MyAssembly.dll /tlb:MyAssembly.tlb

 

This produces a MyAssembly.tlb file.  In Excel (Visual Basic) I select Tools > References and browse to this TLB file which loads OK.

 

When my VBA addin makes a call to my assembly I get this error: Run-time error '-2147024894 (80070002)': Automation error, the system cannot find the file specified.

 

If I look in the 64-bit COM viewer I can see my assembly's types in the registry but if I try to expand any of them I get the same error 80070002 (The system cannot find the file).

 

I presume the file in question is MyAssembly.dll, but why can't it be found?  Is my regasm command in error?  NB. If I add the /codebase switch I get warnings and then an access denied error.

Outcomes