Solved

C# ActiveX to call local program

Posted on 2009-04-08
5
1,456 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
Comment Utility
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now