在C#.net visual studio 2010中创建activex控件。 [英] Creating activex control in C#.net visual studio 2010.

查看:64
本文介绍了在C#.net visual studio 2010中创建activex控件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我打开了一个类库项目并添加以下代码!

 使用系统; 
使用 System.Runtime.InteropServices;
使用 System.Collections.Generic;
使用 System.Drawing.Printing;
使用 System.Windows.Forms;
使用 System.Text;


命名空间 unamespace
{
interface iclass
{
string fname();
string sname();
void box();
}

[ClassInterface(ClassInterfaceType.AutoDual)]

public class uclass:iclass
{
public string fname()
{
return umair;

}
public string sname()
{

return ali ;

}
public void box()
{
MessageBox.Show( 测试winform工具);

}

}
}





2 - 然后关注一些教程,我使用csc.exe编译器编译我的.cs文件

3 - 然后我使用regasm注册unamespae.dll。

都正确完成。

4-我写了一个测试html页面来检查我的activex控件。

<!DOCTYPE html PUBLIC     -  // W3C // DTD XHTML 1.0 Transitional // EN   http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> 
< html xmlns = http://www.w3.org/1999/xhtml>
< head>
< title> umairXXX < / title >
< script type = text / javascript> ;
var x = new ActiveXObject(unamespace.uclass);
alert(x.fname());
alert(x.sname());
alert(x.box());


< / script>
< / head >
< body>

< / body >
< / html >





但是当我打开那个html页面时,没有任何反应。只发出一个警告,寻求permision以允许activex控件运行,即。 nd nthing nothing: - (

解决方案

 ActiveX也可以在Chrome上运行,只需一个简单的插件。你会发现StoreIn中的PlugIn。试试在Google上搜索ActiveX for Chrome。
针对您的问题,请参阅< a href = http://forums.asp.net/p/1947676/5551928.aspx?Loading+ActiveX+with+object+tag > ; 使用对象标记加载ActiveX < / a > ,加载dll cab的语法在javascript中不正确。您应该使用& lt; OBJECT id =myCabclassid =clsid:YOUR_CAB_GUID>& lt; / OBJECT>


first of all, i opened a class library project and add the following code!

using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Text;


namespace unamespace
{
    interface iclass
    {
        string fname();
        string sname();
        void box();
    }

    [ClassInterface(ClassInterfaceType.AutoDual)]
   
    public class uclass : iclass
    {
        public string fname()
        {
            return "umair";
        
        }
        public string sname()
        {

            return "ali";
        
        }
        public void box()
        {
            MessageBox.Show("testing winform tools");
        
        }

    }
}



2-then following some tutorial, i compiled the my .cs file using csc.exe compiler
3-then i registered unamespae.dll using regasm.
all done correctly.
4- i wrote a test html page to check my activex control.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>umairXXX</title>
    <script type="text/javascript">
        var x = new ActiveXObject(unamespace.uclass);
        alert(x.fname());
        alert(x.sname());
        alert(x.box());
    
    
    </script>
</head>
<body>

</body>
</html>



but when i opened that html page in ie, nothing happens. only a warning occurs that seeks permision to allow activex controls to run in ie. nd nthing happens :-(

解决方案

ActiveX can also run on Chrome with a simple plugin. You find that PlugIn in Store. try it. Search for "ActiveX for Chrome" on google.
For your problem, see <a href="http://forums.asp.net/p/1947676/5551928.aspx?Loading+ActiveX+with+object+tag">Loading ActiveX with object tag</a>, Syntax for loading dll cab is not correct in javascript. You should use &lt;OBJECT id="myCab" classid="clsid:YOUR_CAB_GUID">&lt;/OBJECT>


这篇关于在C#.net visual studio 2010中创建activex控件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆