none
in VS2017 C# ,I create x64 dll activex ,to debug it in IE F12 ,the object cann't load. RRS feed

  • Question

  • Hi,

    I create a 'hello world' dll x64 activex project using VS2017 C#,and create a html demo file. 

    if I open as IE load the html demo file,it  worked well.

    if I open as IE press F12(IE11 F12 Developer Tools) To debug the html demo file,it don't work.

    os:Microsoft Windows [Version 10.0.18363.535] , win10 pro 64bit.



    IE:



    VS2017

    vs2017 pro version 15.9.1



    source code:









    Class1.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Runtime.InteropServices;
    namespace ClassLibrary1
    {
        [ProgId("DemoClassLibrary1.HelloWorld")]
        [ClassInterface(ClassInterfaceType.AutoDual)]
        [Guid("731632A9-05F4-4B8E-A34E-BCA8168843B9")]
        [ComVisible(true)]
        public class Class1
        {
            [ComVisible(true)]
            public String SayHello()
            {
                return "helloworld";
            }
        }
    }
    ClassLibrary1.csproj

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="15.0" xmlns="/////////////////////">
      <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProjectGuid>{0D958562-8481-4A7F-8482-09EAED3B86C0}</ProjectGuid>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>ClassLibrary1</RootNamespace>
        <AssemblyName>ClassLibrary1</AssemblyName>
        <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
        <Deterministic>true</Deterministic>
        <TargetFrameworkProfile>
        </TargetFrameworkProfile>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <RegisterForComInterop>true</RegisterForComInterop>
        <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
        <Prefer32Bit>false</Prefer32Bit>
        <PlatformTarget>x64</PlatformTarget>
        <FileAlignment>4096</FileAlignment>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\Release\</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <Prefer32Bit>false</Prefer32Bit>
      </PropertyGroup>
      <PropertyGroup>
        <SignAssembly>false</SignAssembly>
      </PropertyGroup>
      <PropertyGroup>
        <AssemblyOriginatorKeyFile>miyao.pfx</AssemblyOriginatorKeyFile>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="System" />
        <Reference Include="System.Core" />
        <Reference Include="System.Xml.Linq" />
        <Reference Include="System.Data.DataSetExtensions" />
        <Reference Include="Microsoft.CSharp" />
        <Reference Include="System.Data" />
        <Reference Include="System.Xml" />
      </ItemGroup>
      <ItemGroup>
        <Compile Include="Class1.cs" />
        <Compile Include="Properties\AssemblyInfo.cs" />
      </ItemGroup>
      <ItemGroup>
        <None Include="miyao.pfx" />
      </ItemGroup>
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    </Project>


    new2.html

    <!DOCTYPE>

    <html>

       <head>

              <title>DemoCSharpActiveX webpage</title>

       </head>

       <body>
       <button>1231123</button>
           <OBJECT id="DemoActiveX" classid="clsid:731632A9-05F4-4B8E-A34E-BCA8168843B9"></OBJECT>   

     

            <script type="text/javascript">

                try {
    var obj = document.DemoActiveX
                    if (obj) {

                        alert(obj.SayHello());

                    } else {

                        alert("Object is not created!");

                    }

                } catch (ex) {

                    alert("Some error happens, error message is: " + ex.Description);

                }

            

            </script>

       </body>

    </html>

     


    register dll:

    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /register /codebase "C:\Users\Dell\Desktop\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll"
    register:

    Windows Registry Editor Version 5.00

    [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
    "TabProcGrowth"=dword:00000000

    ############################

    result:

    NOT Press F12:



    Press F12 To Debug HTML Code:

    steps:

    1.Run IE

    2.press F12

    3.F12 Develop Tools says "Object doesn't support property or method 'SayHello'". it indecates that the activex Object load failed.




    then I suspect this is Microsoft's  bug. What do you think of the problem? If it's a problem with my code, how do I fix it? 
    • Edited by vczxh Sunday, December 29, 2019 10:55 AM
    • Moved by CoolDadTx Monday, December 30, 2019 2:57 PM ASP.NET related
    Sunday, December 29, 2019 10:49 AM

All replies

  • Hi vczxh,

    Thank you for posting here.

     I have some questions want to confirm.

    1. Is this an ordinary class library project? How does it relate to html files?

    2. You showed the csproj file. Did you modify it?

    I encountered this problem for the first time, so I need more information to reproduce this problem.

    Please tell me how to do it.

    Looking forward to your reply.

    Best Regards,

    Timon


    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.



    Monday, December 30, 2019 3:20 AM
  • 1.

    register dll:

    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /register /codebase "C:\Users\Dell\Desktop\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll"

    regedit:

    Windows Registry Editor Version 5.00

    [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
    "TabProcGrowth"=dword:00000000

    2.I refer to this web page :

    https://blogs.msdn.microsoft.com/asiatech/2011/12/05/how-to-develop-and-deploy-activex-control-in-c/

    Monday, December 30, 2019 7:27 AM
  • You already asked this questions once. As said before, please post questions related to web development in the ASP.NET forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, December 30, 2019 2:57 PM