none
Javascript implemented with ComSourceInterfaces is not getting executed when device guard is on RRS feed

  • Question

  • Hi,

    We have implemented COM control and exposed COM event via ComSourceInterfaces and implemented the same in Javascript.

    But whenever device guard (windows defender) is turned on this java script is not getting called.

    Scenario:

    COM control is embedded in HTML page and is displayed  in web browser control on a winform.

    Code: COM and ComSourceInterfaces

    namespace Test
    {
        [Guid("EEE8DC12-B436-43CD-B306-55C7FC2BF9FB")]
        [ProgId("Test.UserControl1")]
        [ClassInterface(ClassInterfaceType.AutoDual), ComSourceInterfaces(typeof(TestEvents_New))]
        [ComVisible(true)]

        [PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]


        public partial class UserControl1: UserControl
        {
            public UserControl1()
            {
                InitializeComponent();
            }

            private void Display_Click(object sender, EventArgs e)
            {

                if (OnTestEvent_New != null)
                {

                    string usrinput = textBox1.Text;
                    MessageBox.Show("Calling java script with " + usrinput,"User Control");
                    object comObject = OnTestEvent_New.Target;

                    if(comObject == null)
                    {
                        MessageBox.Show("Com object is null");
                    }

                    OnTestEvent_New(usrinput);
                }
                else
                {
                    MessageBox.Show("Not able to Call java script no event handlers");
                }

            }
            public event ControlEventHandlerTest OnTestEvent_New;


        }

        public delegate void ControlEventHandlerTest(string UserText);

        /// <summary>
        /// This interface shows events to javascript
        /// </summary>
        /// 
        [ComVisible(true)]
        [Guid("611B5363-C119-4A19-9510-6DC4E4556C3C")]
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]

        public interface TestEvents_New
        {
            //Add a DispIdAttribute to any members in the source interface to specify the COM DispId.
            [DispId(0x60020001)]
            void OnTestEvent_New(string UserText); //This method will be visible from JS
        }

    HTML and JavaScript:

    <!DOCTYPE html>

    <html>
    <head>
        <title></title>
    </head>
    <body>

        <div>User Text:<h1 id="Header"></h1></div>


        <object id="SaveIssue_New" classid="clsid:EEE8DC12-B436-43CD-B306-55C7FC2BF9FB" codebase="SaveIssue_New.cab"></object>

        <script language="javascript">
            function SaveIssue_New::OnTestEvent_New_Handler(UserText)
    {


    document.getElementById('Header').innerHTML = UserText;

    }
        </script>
    </body>
    </html>

                               
    Tuesday, June 12, 2018 3:46 AM

All replies

  • Hi SUJAI CN,

    Thank you for posting here.

    For your question, have you check that when you turn on the windows defender, does the COM/ port be disabled?

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 14, 2018 7:26 AM
    Moderator