Reputation: 85
I have created MS Visual Studio project for creating an ActiveX control.For that I performed steps mentioned here. I have created a class file called HelloWorld.cs and create a method that will return "Hello World..". Step that I have performed were.. Created New Project -> New Class-> Sign the Project using HelloWorld.snk file. In class File I added “ProgId”, “Guid”, “ComVisible” to implement my logic.Here is my code, That is HelloWorld.cs.
using System;
using System.Runtime.InteropServices;
namespace ActiveXClass
{
/// <summary>
/// Demo`enter code here` HelloWorld class
/// </summary>
[ProgId("ActiveXClass.HelloWorld")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("415D09B9-3C9F-43F4-BB5C-C056263EF270")]
[ComVisible(true)]
public class HelloWord
{
[ComVisible(true)]
public String SayHello()
{
return "Hello World!";
}
}
}
I have also set [assembly: ComVisible(true)] in AssemblyInfo.cs file. Then I have created a sample HTML page that will create Object of ActiveX class and then called SayHello() method. Then I have created msi for above project by following below steps. New Project->Other Project Types->Setup and Deployment->Visual Studio Installer-> Setup Project named Setup1. Next I have register my ActiveX project by following command.
regasm /codebase "FULLPATH OF MY ACTIVEX DLL"
response from cmd is :"Type Registers Successfully." Then i have created Sample HTML page in FileSystem e.g, "D:\ActiveX\Test.html". Below is my Sample HTML code. NOTE : I have not created .cab file.
<!DOCTYPE>
<html>
<head>
<title>ActiveX webpage</title>
</head>
<body>
<OBJECT id="ACtive" classid="clsid:415D09B9-3C9F-43F4-BB5C-C056263EF270">
</OBJECT>
<script type="text/javascript">
try {
var obj = document.ACtive;
if (obj) {
alert(obj.SayHello());
} else {
alert("Object is not created!");
}
} catch (ex) {
alert("Some error happens, error message is: " + ex.Description);
}
</script>
I have run this page by File System (e.g D:\ActiveX\Test.HTML) it will pop up message "Hello World.." successfully. but When I add this HTML file on IIS server and when I browsed it it will return message that "Some error happens, error message is: undefined". So whats going wrong here..? I have also created C# web page for same. but the result is same. Is there any configuration problem from IIS side or from IE side. I have already experimented many of them but failed.
One more thing when I run that webpage on localhost like localhost:8080/Test.html
this will run but when I replace it with IP address it fails.for e.g http://192.168.1.xx:8080/Test.html
Please get me out of this. I am very much new to ActiveX Components.
Looking forward to solutions.
Any ideas would greatly be appreciated. Please help. Thanks In Advance.
Upvotes: 2
Views: 4454
Reputation: 58
First register your dll in the pc you want to run the activex ,
Take cmd in run as Administrator mode ,
type cd C:\Windows\Microsoft.Net\Framework\<version of your application>
.
For example if you are using .net 4 then C:\Windows\Microsoft.Net\Framework\v4.0.30319
enter,
then type regasm <path of your dll>
Example: C:\Windows\Microsoft.Net\Framework\v4.0.30319> regasm d:\myfile.dll
enter.
you will get message ends with type registered successfully
.If not the check the version your application
then Check your IE security. Go to Internet Explorer , Tools -> Internet options-> Click on advanced tab -> Under security Check first three options . Then got security tab click Trusted sites, click the button "Sites" ,then add your url to the trusted sites list (http://192.168.10.xx/*) Then go to Custom level and find Activex controls and plugins and check enable everything except "Only allow approved domains to use ActiveX without prompt" Then restart the IE
Upvotes: 2
Reputation: 6372
Try installing the ActiveX component on the IIS server.
Also check your internet zone and security settings, specifically you might try adding the site in question to your trusted sites zone.
Upvotes: 0