V
vczxh
Guest
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?
Continue reading...
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?
Continue reading...