none
AxHost IPropertyNotify Exception RRS feed

  • Question

  • I've a ActiveX Control. I try to load this in C#.

    Sample C# Class

    public class ActiveXForm : AxHost
    {
      private object ocx;
      private string filePath;
      private string clsid;
    
      public CdnPaneForm(string filePath)
       : base("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
      {
      }
    
      protected override object CreateInstanceCore(Guid clsid)
      {
        IClassFactory icf = null;
        if (filePath != null)
        {
          icf = RegFreeActivation.GetClassFactoryFromDll(filePath, this.clsid.ToString());
          Guid pdmWindowGuid = new Guid(clsid.ToString());
          Guid IDispatchGuid = new Guid("00020400-0000-0000-C000-000000000046");
          icf.CreateInstance(null, ref IDispatchGuid, out ocx);
        }
    
        return ocx;
      }
    
       protected override void AttachInterfaces()
        {
          try
          {
            this.ocx = ((this.GetOcx()));
          }
          catch (System.Exception)
          {
          }
        }
    }

    Sample using this class:

      System.Windows.Forms.Form mainForm = new System.Windows.Forms.Form();
      mainForm.Visible = true;
      mainForm.Location = new System.Drawing.Point(10,10);
      mainForm.Size =  new System.Drawing.Size(55, 50);
      mainForm.Show();
    
      ActiveXForm aForm = new ActiveXForm(filePath, clsid);
    
      ((ISupportInitialize)(aForm)).BeginInit();
      aForm.Enabled = true;
      aForm.Location = new System.Drawing.Point(10, 10);
      aForm.Name = "ActiveXForm";
      aForm.Size = new System.Drawing.Size(55, 50);
      ((ISupportInitialize)(aForm)).EndInit();
      aForm.Visible = true;
    
      mainForm.Controls.Add(aForm);
    
    At Controls.Add I get the exception:

    A first chance exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll
    Additional information: Source object does not expose 'IPropertyNotifySink' event interface.

    Indeed the ActiveX control has no IPropertyNotifySink. How can I use the AxHost anyway?

    What should I implement in the ActiveXForm to solve this issue?

    Thanks

    Monday, January 28, 2013 5:49 PM

Answers

  • Issue solved. The ActiveX did not implement one of the following Interfaces

    IPersistStreamInit
    IPersistStream
    IPersistStorage
    IPersistPropertyBag

    These Interfaces were remove because of MS09-035.

    @Microsoft: A little more information (that one of these Interfaces is missing) in the Exception inside DepersistControl would be helpful.


    Tuesday, January 29, 2013 2:23 PM

All replies

  • Hi Rger,

    Welcome to the MSDN Forum.

    I am trying to involve some other one into this case, wait it patiently, please.

    Thank you.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, January 29, 2013 10:13 AM
    Moderator
  • Issue solved. The ActiveX did not implement one of the following Interfaces

    IPersistStreamInit
    IPersistStream
    IPersistStorage
    IPersistPropertyBag

    These Interfaces were remove because of MS09-035.

    @Microsoft: A little more information (that one of these Interfaces is missing) in the Exception inside DepersistControl would be helpful.


    Tuesday, January 29, 2013 2:23 PM
  • Hi Rgerlach,

    Thank you for come back to verify this.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 30, 2013 2:22 AM
    Moderator