使用C#开发 调用电子秤com端口 将数据插入到ie的textbox中 控件ActiveX插件
How to get started with developing Internet Explorer extensions?http://
http://blog. C# ActiveX控件开发
http://bbs. ActiveX安全性
http://www. 有没有人会用API来编写串口通讯的
Connecting to a client pc's serial port from the Web Server
https://social.msdn.
description:
I have a web application that reads weight from the scale and display weight on the text box, I have works well on my laptop. However the serve doesn't see the scale after deploying the web site. The server is looking at the local com port not at the client's.
please help with the code to direct the serve to the client's com port not the local com port.
Yes I am referencing the serial port in the Web application and using a C# code like this:
using
SerialPort _serialPort;
//Change COM port number
portNumber = COMDownList.Text;
///<summary>
///Create a com port, set it's variables and open it
///</summary>
_serialPort = new SerialPort(portNumber, 9600, Parity.None, 8, StopBits.One);
_serialPort.Handshake = Handshake.None;
_serialPort.ReadTimeout = 500;
_serialPort.WriteTimeout = 500;
_serialPort.RtsEnable = true;
_serialPort.Open();
string data = _serialPort.ReadLine().Trim();
string temp = data.Replace(" kg", "");
Convert.ToDouble(temp);
WeightTextBox.Text = temp.ToString();
_serialPort.Close();
Sign in to vote
And the magic trick IS !!!
After one week and several hundred compile roundtrips ....
Drum roll ....
[SuppressUnmanagedCodeSecurityAttribute()]
put this in the namespace of the class that you are calling from the web page.
Then do a
SecurityPermission sx = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
sx.Assert();
you can then access the serial port on the client machine from the browser.
Typical code being ;
serialPort1.PortName = "COM6";
serialPort1.BaudRate = 2400;
serialPort1.Parity =
serialPort1.DataBits = 7;
serialPort1.StopBits =
serialPort1.Open();
serialPort1.ReadExisting();
thanks to all who answered my various posts.
PatC
accessing serial port from web page
How to use the AllowPartiallyTrustedCallers attribute to call an assembly that has a strong name from a Web page by using Visual C# .NET, Visual C# 2005 or later versions
https://support. 发布网站
Ahead in what areas
Unexpected delays or issues
Related Documents
USB Devices
https://developer.
http://www. POS SERIAL RS-232 DRIVERS -- BASIC INSTALLATION AND TEST KIT
SERIALPORT (RS-232 SERIAL COM PORT) IN C# .NET
http://blogs.
Budget http://www.
怎样让IE认为你的对象安全
实现了这个接口,剩下的事情就很简单了。前面提到过如果按照正规的途径你需要确保你的代码没有访问系统的本地自然,然后按照文档要求,当该对象被不同的接口调用查询的时候,做不同的反馈。具体实现可以在MSDN的Sample中找到。
当然我们可以写一个对象读写本地文件,但是支持IObjectSafety接口,并且始终声明自己是合法的,这样来欺骗浏览器,那么代码就很简单了,如下:
// implement functions of IObjectSafety
public void GetInterfacceSafyOptions(System.Int32 riid,out System.Int32 pdwSupportedOptions,out System.Int32 pdwEnabledOptions)
{
pdwSupportedOptions = CLsObjectSafety.INTERFACESAFE_FOR_UNTRUSTED_CALLER;
pdwEnabledOptions = CLsObjectSafety.INTERFACESAFE_FOR_UNTRUSTED_DATA;
}
public void SetInterfaceSafetyOptions(System.Int32 riid,System.Int32 dwOptionsSetMask,System.Int32 dwEnabledOptions)
{
}
来源: http://blog.
How to display weight from weighing scale into a textbox via serial port RS-232 or usb converter?
http://
How can a web page read from the user's serial port? [duplicate]
http://