Been trying off and on for days now and can't figure this out. I have written a C# class file for an Intranet app to control the local serial ports. It works great when I manually register the dll using regasm, however, I need to deploy this control from a web page without having to manually register it. I tried creating a Setup Project in Visual Studio 2010, it compiled fine yet I can not open the object in a webpage.
Here are the pertinent lines of code from my C# class:
namespace wmsSerialPorts
{
[Guid("55D31498-12A5-4FF0-942D-3B0BA449CA7B")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
[ComVisible(true)]
public interface iAxDevices
{
[DispId(1)]
int OpenPort(string sComPort);
[DispId(2)]
int ClosePort();
[DispId(3)]
int SendCmd(string sCmd);
[DispId(4)]
string GetLastError();
//[DispId(5)]
//string ReadLine();
[DispId(6)]
string ReadWeight();
[DispId(7)]
Microsoft.JScript.ArrayObject GetJsPorts();
[DispId(8)]
void prtLabel(string sItemNum, string sQty, string sDesc, string sWoNum, string sBoxID, string sBoxIDBarCode, string sBoxIDorig);
[DispId(9)]
void prtLabelQC(string sItemNum, string sQty, string sDesc, string sWoNum, string sBoxID, string sBoxIDBarCode, string sBoxIDorig, string sNeedDate, string sRecOverride);
[DispId(10)]
void prtReset();
}
[Guid("E59C5B7E-EF1F-4241-A9FD-191EF8FCC167")]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[ProgId("AxDevices")]
public class AXDevices : wmsSerialPorts.SerialCom, iAxDevices, wmsSerialPorts.IObjectSafety
As I mentioned, if I use regasm wmsSerialPorts.dll, the object works great when called from JavaScript like this:
myAx = new ActiveXObject("AXDevices");
My Setup project contains a wmsSerialPorts.inf file:
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Setup Hooks]
install=install
[install]
run=msiexec.exe /package """%EXTRACT_DIR%\ActiveXSetup.msi""" /qn
.... and an ActiveXBuild.ddf file:
.Set DiskDirectoryTemplate=cab
.Set CabinetNameTemplate=ActiveXSetup.cab
Debug\ActiveXSetup.msi
wmsSerialPorts.inf
My wmsSerialPorts.dll file is properly referenced as a detached asseembly and building the Setup Project created the ActiveXSetup.cab and ActiveXSetup.msi files as expected.
I then created this HTML page to load the object:
<!DOCTYPE>
<html>
<head>
<title>Test</title>
</head>
<body>
<!-- <object id="AXDevices" classid="clsid:E59C5B7E-EF1F-4241-A9FD-191EF8FCC167" codebase="https://10.0.2.53/BIDWMS/ActiveXSetup.cab">
</object>-->
<object id="AXDevices" classid="clsid:E59C5B7E-EF1F-4241-A9FD-191EF8FCC167" codebase="ActiveXSetup.cab">
</object>
<script type="text/javascript">
try {
var obj = document.AXDevices;
if (obj) {
alert(obj.SayHello());
} else {
alert("Object is not created!");
}
} catch (ex) {
alert("Error message is: " + ex.Description);
}
</script>
</body>
</html>
... but when I run the page, it generates an error of "undefined" (from the catch(ex) block). Any ideas? Thanks in advance ....... Bob