我得到了一个1001错误并且使用InstallShield LE(Visual Studio 2013)在Windows XP上部署简单的Windows服务时遇到了很多问题.
有时错误发生,有时不发生.
c# windows-services setup-project installshield-le visual-studio-2013
当运行安装了react-bootstrap的create-react-app应用程序时,我在尝试添加按钮时收到下面的错误
我的导入是这样的:
import 'bootstrap/dist/css/bootstrap.min.css';
import './App.css';
import PropTypes from "prop-types";
import { Button } from "bootstrap";
import { PureComponent } from "react";
Run Code Online (Sandbox Code Playgroud)
和渲染代码:
render() {
return (
<div className="App">
<header />
<Button>Test</Button>
...
Run Code Online (Sandbox Code Playgroud)
我研究了许多其他有关 Babel、Webpack 和编译器配置的问题。但我在 create-react-app 中没有看到所有这些配置。
我有一个类从一个串行读取数据,具有高阈值(1个字节).
我有一个变量存储来自串口的所有数据:_dataReceived.
private volatile string _dataReceived;
Run Code Online (Sandbox Code Playgroud)
我正在使用DataReceived事件来存储这些数据,然后我开始一个动作来处理它.
private void _port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string newData = _port.ReadExisting();
_dataReceived += newData;
new Action(() =>
{
Debug("Data received: {0}", newData);
ParseAnswers();
}).BeginInvoke(null, null);
}
Run Code Online (Sandbox Code Playgroud)
处理它,包括从变量中删除它并处理答案.ParseAnswers方法如下所示:
private void ParseAnswers()
{
string cmd = null;
int idx = -1;
lock (_dataReceived)
{
idx = _dataReceived.IndexOf(Environment.NewLine);
if (idx != -1)
{
cmd = _dataReceived.Substring(0, idx);
_dataReceived = _dataReceived.Substring(idx + 2);
}
else
return;
}
...
}
Run Code Online (Sandbox Code Playgroud)
这有99.9%的时间.
但有时我会在这一行得到一个ArgumentOutOfRangeException:
cmd = _dataReceived.Substring(0, idx);
Run Code Online (Sandbox Code Playgroud)
现在,我的问题是:我的变量是volatile,这意味着我总是访问真正的值而不是缓存.我很确定我的DataReceived事件一直在增加(快速),但是我使用lock语句来阻止任何其他线程更改此值.如果没有在字符串中使用NewLine,就无法运行这段代码(子字符串).而且这个IndexOf无法从字符串中返回索引.
那么......这里到底发生了什么? …