Solved

C# ActiveX to call local program

Posted on 2009-04-08
5
1,472 Views
Last Modified: 2013-11-18
I am trying to figure out how to write an ActiveX control in C# to call a local program, lets call it Program1.  I want to pass a XML files through the server to the client and load that XML file into Program1.  Most of the stuff I have found online is about how to write a user control in a webpage, I am trying to actually pass a file  to the client's machine and execute Program1 with the XML file.
0
Comment
Question by:htn5ca
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24104312
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 24104323
http://www.dreamincode.net/forums/showtopic38890.htm
http://www.c-sharpcorner.com/UploadFile/dsandor/ActiveXInNet11102005040748AM/ActiveXInNet.aspx 

using System;
using System.Runtime.InteropServices;
namespace AXComponent 
{
 
public interface AXTest
{
string callMe();
}
 
[ClassInterface(ClassInterfaceType.AutoDual)]
public class AxComp :AXTest
{
public string callMe()
{
return "My dog has no nose, how does it smell?";
}
}
}
 
Compile this using:
csc /t:library AxComp.cs
 
Register and generate Typelib with:
regasm AxComp.dll /tlb:AxCompNet.dll /codebase
 
Try the control: ( testControl.htm )
<html>
<head>
<script language="javascript">
var obNewAXComponent = new ActiveXObject("AXComponent.AXComp");
alert(obNewAXComponent.callMe());
</script>
</head>
<body>
<h1>Awful!</h1>
</body>
</html>

Open in new window

0
 

Author Comment

by:htn5ca
ID: 24163431
Sorry its been awhile but I have been trying this like crazy.  Nothing seems to work.  Right now it says that IE is done but has a problem, it says it cannot create activeX object.  
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24183156
u will need to enble certain propertis in IE to do that ? is that done ? under tools -> internert options - > advanced
0
 

Author Comment

by:htn5ca
ID: 24187422
The only document that seems to work is
http://www.c-sharpcorner.com/UploadFile/dsandor/ActiveXInNet11102005040748AM/ActiveXInNet.aspx   

But when I try putting in System.Diagnostics.Process.Start("C:\\something.txt") it will not display the text file and says "Request Failed"

I have attached what my IE -> advanced settings are.  In the picture, the last couple are all checked.
IEadvanced.JPG
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Connecting to multiple databases to create a Dashboard 5 49
Sort GridView by ID Descending 1 17
Name Space error VS2015 1 27
VS2010 Build fails to install 14 39
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question