Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

How to get a 64bit ActiveX control to work in Visual Studio 2012?

$
0
0

We create ActiveX controls in Embarcadero Delphi for resale to clients to work in dozens of development environments. Our OCX file works in every development environment we tested, including 64 bit Internet Explorer using VBScript or JavaScript. We believe the issue is faulty assemblies. What do we have to do to get this to work? Is there a bug in VS creating 64 bit assemblies for ActiveX controls? Here are our steps:

1. Install and register a 32bit version of the OCX in Program Files(x86)\ourcompany\myControl\  (32 bit version of the OCX)
2. Install and register a 64bit version of the OCX in System32 (64 bit version of the OCX)
3. Create a new windows forms project in VS2012, VB personality
4. Make sure both platform and target are set for "any cpu"
4. Drag the controls onto a form and create a small sample program. This creates the assemblies.

5. Run the program.

The first problem is a warning:

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualStudio.HostingProcess.Utilities.dll

The program then works just fine until any events fire. The controls calls into the windows API and the message from the callback function has 3 parameters that are DWORD_PTR types now. So I am guessing that a message with a 64bit parameter fires and crashes my system with the next series of errors:

{"Access violation at address 0000000000737967 in module 'MyControl.ocx'. Read of address 0000000046DB4898"}
{System.Collections.ListDictionaryInternal}
Error Code: -2147418113
Source: MyControl.Control1
So "MyControl.Control1" is the assembly call to a method that returns a message (event) back from the API.
System.Runtime.InteropServices.COMException was unhandled
  ErrorCode=-2147418113
  HResult=-2147418113
  Message=Access violation at address 0000000000737967 in module 'MyControl.ocx'. Read of address 000000006EAB4898
  Source=myControl.Control1
  StackTrace:
       at MyControl.IControl1.Send()
       at AxMyControl.Control1.Sendl()
       at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) in C:\Users\Fred\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb:line 12
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

  InnerException: 

Do I need to manually create 64bit assemblies for the OCX? If so, where do I put them? Why doesn't Visual Studio generate the correct ones? How can I debug into the process to see which line inside the ActiveX or the interop assemblies is causing the problem? Thank you.

Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>