3

I'm using a 3rd party COM Library with C#, all works fine on 32 bit XP. I use tlbimp to create the wrapper, add a reference all works. However, when porting to our Server environment which is 64 bit Windows Server 2008, I've run into a road block.

The code below only runs properly when I right click and test it, ie run within the VS environment. The code does not work when compiled to a Console App, nor does the code work in an Assembly whether in test or called from a console App. In an attempt to get it working I'm running as Administrator and in a 32bit command window - still nothing grouper is always null, and no exception is thrown, indicating that GrpSvr.GrpCall is a valid Com Library name.

    string sMessage = "no grouper";
    GrpSvr.GrpCall grouper = Activator.CreateInstance(
        Type.GetTypeFromProgID("GrpSvr.GrpCall")) as GrpSvr.GrpCall;
    if (grouper != null)
        sMessage = grouper.GroupInit(@"C:\CmdGrp.txt", true, true);

    Console.WriteLine(sMessage);
casperOne
  • 73,706
  • 19
  • 184
  • 253
MrTelly
  • 14,657
  • 1
  • 48
  • 81
  • Are you trying to load a 32-bit DLL into a 64-bit process? – Gabe May 17 '11 at 02:16
  • Do you have any evidence that this COM library works properly on 64-bit Server 2008? – Gabe May 17 '11 at 03:32
  • @Gabe, every thing is set to target x86, and I've forced the console app to run from a 32 bit command window. Maybe I'm missing something but I don't know what – MrTelly May 17 '11 at 10:25
  • How do you know that the problem isn't that your COM library simply isn't compatible with a 64-bit OS? What do you get back from `GetTypeFromProgID`? – Gabe May 17 '11 at 11:59

2 Answers2

3

Try using COM+ as host, and keep your application compiled for 64 bits. For more info see this link

Community
  • 1
  • 1
lsalamon
  • 7,998
  • 6
  • 50
  • 63
  • Thank you for the excellent link. This may solve a similar issue I am having with ESRI runtimes in x64 ASP.NET. – hsmiths May 17 '11 at 03:47
2

It sounds like the 3rd party COM DLL is 32 bits only. You have to configure your app to run as 32 bits only, instead of any cpu.

Windows programmer
  • 7,871
  • 1
  • 22
  • 23