此程序集看起来可以访问。JavaScript无法找到它
当我使用regasm/codebase/tlb/verbose Whatever.dll时,我得到了以下反馈:此程序集看起来可以访问。JavaScript无法找到它,javascript,.net,com,com-interop,.net-assembly,Javascript,.net,Com,Com Interop,.net Assembly,当我使用regasm/codebase/tlb/verbose Whatever.dll时,我得到了以下反馈: using System; using System.Runtime.InteropServices; using System.ComponentModel; using System.Collections.Generic; using System.Text; using System.Security; using System.Security.Permissions; us
using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Security;
using System.Security.Permissions;
using System.Collections;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AllowPartiallyTrustedCallers]
namespace Whatever
{
[
Guid("AD3EE0B2-4C9F-441B-8E6F-0D1223354EBD"),
InterfaceType(ComInterfaceType.InterfaceIsDual),
ComVisible(true)
]
public interface ISetup
{
[DispId(1)]
string Hello();
[DispId(2)]
int ShowDialog(string msg);
};
[
Guid("81F44339-C03D-444F-95AD-3E86CF8FA514"),
ProgId("Whatever.CSetup"),
ClassInterface(ClassInterfaceType.None),
ComDefaultInterface(typeof(ISetup)),
ComVisible(true)
]
public class CSetup : ISetup
{
#region [ISetup implementation]
[ZoneIdentityPermission(SecurityAction.Demand, Zone = SecurityZone.Intranet)]
public string Hello()
{
MessageBox.Show("Hello world.");
return "Hello from CSetup object";
}
public int ShowDialog(string msg)
{
System.Windows.Forms.MessageBox.Show(msg, "");
return 0;
}
#endregion
};
}
这很好,除了不知道导出的“N”类型是什么意思之外,但是程序集确实以Which.CSetup的形式出现在HKEY_LOCAL_MACHINE\SOFTWARE\Classes\中
如果我启动一个浏览器到包含下面复制的JavaScript的站点,该JavaScript还不能识别被错误调用的.NET汇编方法,我可以在MSIE菜单工具中看到!互联网选项!程序!管理加载项!工具栏和扩展,Whatever.CSetup与“名称”列中的其他几个加载项一起出现,而“状态”列将其报告为已启用。虽然它的加载时间和导航时间列不显示任何内容,但也不会发送到蓝牙设备或其他一些设备
JavaScript:
Microsoft (R) .NET Framework Assembly Registration Utility 4.0.30319.1
Copyright (C) Microsoft Corporation 1998-2004. All rights reserved.
Types registered successfully
Type 'N' exported.
Type 'N' exported.
Assembly exported to 'C:\Users\Whoever\Whatever.tlb', and the type lib
rary was registered successfully
当我转到页面时,我无法获取属性Whatever.CSetup:的值:对象为null或未定义
我知道这一点:如果我通过更改JavaScript中的CLSID进行测试,那么转到页面将不会触发任何东西。如果我把它改回来,我会收到错误信息
我不能确定我将向市场供应什么
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body onload="OpenActiveX()">
<!-- Our activeX object -->
<OBJECT id="Whatever.CSetup" name=”Whatever.CSetup" classid="clsid:81F44339-C03D-444F-95AD-3E86CF8FA514" VIEWASTEXT codebase="Whatever.CSetup"></OBJECT>
<!-- Attaching to an ActiveX event-->
<script language="javascript">
function OurActiveX::OnClose(redirectionUrl)
{
alert(redirectionUrl); <!-- http://otherwebsite.com should be returned-->
//window.location = redirectionUrl;
}
</script>
<script language="javascript">
//Passing parameters to ActiveX object and starting application
function OpenActiveX()
{
try
{
// document.OurActiveX.MyParam = "Hi I am here." //Passing parameter to the ActiveX
document.Whatever.CSetup.Open(); //Running method from activeX
}
catch(Err)
{
alert(Err.description);
}
}
</script>
</body>
</html>