[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

c# x64 COM Add References Problem

Pablo Sullivan

8/20/2007 1:56:00 PM

I have a problem building a c# project that references a COM object built for
x64. The problem is that the x64 DLL is missing under the "Add References"
COM tab for the C# project. Also when I attempt to add a reference via the
BROWSE tab, an error message is displayed saying â??Please make sure that the
file is accessible and, that it is a valid assembly or COM component.�
I can regsvr32 the DLL and instantiate objects in the DLL via JavaScript, so
it is unclear why Visual Studio cannot find it. Maybe it has to do with
Visual Studio running in 32 bit mode.
My machine is running an Intel(R) Pentium(R) D CPU with Windows XP
Professional x64 Edition, and I am running Visual Studio 2005, The C# project
settings are â??Any CPUâ? and the settings for the C++ ATL COM project are:
Project- x64
Linker/Advanced/Target Machine - x64
MIDL/General/Target Environment- x64
If I change the MIDL/General/Target Environment to 32-bit then the DLL does
show up under Add References of the c# project. Unfortunately this is not a
solution since the DLL has to run as x64.
Does anyone have any ideas as to how to solve this?
Thank you for any help you can provide.

3 Answers

Christian Fröschlin

8/20/2007 2:13:00 PM

0

> If I change the MIDL/General/Target Environment to 32-bit then the DLL does
> show up under Add References of the c# project. Unfortunately this is not a
> solution since the DLL has to run as x64.

> Does anyone have any ideas as to how to solve this?

You need both versions of the DLL and you can register both of
them as Win64 keeps a separate registry section for the WOW64
stuff. Visual Studio 2005 will only see the 32-bit version
but when you run the app it loads the 64-bit version.

Pablo Sullivan

8/23/2007 1:28:00 AM

0



"Christian Fröschlin" wrote:

> > If I change the MIDL/General/Target Environment to 32-bit then the DLL does
> > show up under Add References of the c# project. Unfortunately this is not a
> > solution since the DLL has to run as x64.
>
> > Does anyone have any ideas as to how to solve this?
>
> You need both versions of the DLL and you can register both of
> them as Win64 keeps a separate registry section for the WOW64
> stuff. Visual Studio 2005 will only see the 32-bit version
> but when you run the app it loads the 64-bit version.
>
Thanks for your response. We have solved it by adding the following
Post-Build-Event to my C++ project: tlbimp /machine:x64 "MyX64Com.DLL".
This generates MyX64ComLib.DLL which enables COM interop between my C#
program and MyX64Com.DLL. Apparently, Visual Studio omits TLBIMP after
building and registering x64 COM C++, which was the source of the problem,
but Visual Studio does not omit TLBIMP after building and registering x32 COM
C++, which explains my original observations.

Christian Fröschlin

8/23/2007 7:53:00 AM

0

> Thanks for your response. We have solved it by adding the following
> Post-Build-Event to my C++ project: tlbimp /machine:x64 "MyX64Com.DLL".
> This generates MyX64ComLib.DLL which enables COM interop between my C#
> program and MyX64Com.DLL.

Ok, so you reference the wrapper assembly in your c# project and
not the COM dll? You would still need a 32-bit version if your
DLL contained ActiveX controls for use in the form designer,
otherwise it should work fine.