我想知道如何在命令提示符下显示Program Files(x86)的位置.我正在使用Windows 7 64位.
我试过了:
echo %programfiles(x86)%并且echo %programfiles%,
两者都只显示C:\Program Files
当我手工检查注册表,
HKLM /软件/微软/窗/ CURRENTVERSION,
该programfilesdir点C:\Program Files与
HKLM /软件/ WOW64 /微软/的Winodws/CURRENTVERSION,
该programfilesdir点C:\Program Files (x86).
但是,为什么我总是用C:\ Program Files?
每当用户报告错误时,例如
System.Runtime.InteropServices.SEHException - 外部组件引发了异常?
我作为程序员可以做些什么来确定原因?
场景:一个用户(使用我公司编写的程序)报告了此错误.这可能是也可能不是一次性错误.他们提到,在上个月,计算机已经两次"停止工作".我从经验中学到了,不是太过于字面意思,因为它通常意味着与计算机有关的人没有按预期工作.他们无法给我更多细节,我找不到任何记录错误.因此它可能是也可能不是这个错误.
从堆栈跟踪中,实际错误是在构造一个不直接调用任何互操作代码的类时,但可能因为该对象可能是与DevExpress Grid数据绑定的列表的一部分而复杂化.
错误被未处理的异常例程"捕获",该例程通常会关闭程序,但可以选择忽略并继续.如果他们选择忽略错误,则程序继续工作,但下次运行此例程时会再次出现错误.但是,在关闭并重新启动应用程序后,它不会再次出现.
有问题的电脑似乎没有压力.它正在运行Vista Business,拥有2GB的内存,根据任务管理器,我们的应用程序只使用了大约一半,只有大约200Mb.
还有一条信息可能相关或不相关.同一程序的另一部分使用第三方组件,它实际上是一个围绕本机dll的dotnet包装器,这个组件确实有一个已知的问题,偶尔,你得到一个
尝试读取或写入受保护的内存.这通常表明其他内存已损坏
组件制造商表示,这已在我们内部使用的最新版本的组件中修复,但尚未向客户提供.
鉴于错误的后果很少(没有工作丢失并重新启动程序并返回到最多只需要一分钟的时间)并且考虑到客户将很快获得新版本(更新后的第三个 - 派对组件),我显然可以交叉手指,希望错误不再发生.
但还有什么我可以做的吗?
当我写这样的代码
[XmlIgnore]
[NonSerialized]
public List<string> paramFiles { get; set; }
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Attribute 'NonSerialized' is not valid on this declaration type.
It is only valid on 'field' declarations.
Run Code Online (Sandbox Code Playgroud)
如果我写
[field: NonSerialized]
Run Code Online (Sandbox Code Playgroud)
我收到以下警告
'field' is not a valid attribute location for this declaration.
Valid attribute locations for this declaration are 'property'.
All attributes in this block will be ignored.
Run Code Online (Sandbox Code Playgroud)
如果我写
[property: NonSerialized]
Run Code Online (Sandbox Code Playgroud)
我再次收到以下错误:
Attribute 'NonSerialized' is not valid on this declaration type.
It is only valid on 'field' declarations.
Run Code Online (Sandbox Code Playgroud)
我怎样才能[NonSerialized]在物业上使用?
刚刚打开VS 2015 Enterprise RTM,打开了一个现有的工作项目,收到以下错误:
Microsoft Visual Studio
'NuGetPackage'包未正确加载.
问题可能是由配置更改或安装另一个扩展引起的.您可以通过检查文件来获取更多信息
C:\Users\REDACTED\AppData\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml.重新启动Visual Studio可以帮助解决此问题.
继续显示此错误消息?
[是] [否]
重启没有帮助.我检查了日志文件,发现以下与nuget相关的部分:
<entry>
<record>555</record>
<time>2015/07/20 16:06:34.364</time>
<type>Error</type>
<source>Extension Manager</source>
<description>Extension will not be loaded because an extension with the same ID
'Microsoft.Dev14.VsixTemplatesPackage.443cca91-ec20-41e5-a165-f28e56b89650'
is already loaded at C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\
EXTENSIONS\G2URSPAC.VAZ\...</description>
<path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\
NUGETIFIEDEXTENSIBILITYTEMPLATES\</path>
</entry>
<entry>
<record>556</record>
<time>2015/07/20 16:06:34.364</time>
<type>Error</type>
<source>Extension Manager</source>
<description>Extension will not be loaded because an extension with the same ID
'Microsoft.VisualStudio.TeamFoundation.TeamExplorer.Extensions' is already
loaded at …Run Code Online (Sandbox Code Playgroud) 因此在a中BufferedImage,您会收到一个整数,其中包含RGB值.到目前为止,我使用以下内容从中获取RGB值:
// rgbs is an array of integers, every single integer represents the
// RGB values combined in some way
int r = (int) ((Math.pow(256,3) + rgbs[k]) / 65536);
int g = (int) (((Math.pow(256,3) + rgbs[k]) / 256 ) % 256 );
int b = (int) ((Math.pow(256,3) + rgbs[k]) % 256);
Run Code Online (Sandbox Code Playgroud)
到目前为止,它的工作原理.
我需要做的是弄清楚如何获得一个整数,以便我可以使用BufferedImage.setRGB(),因为它采用了它给我的相同类型的数据.
是否可以构建一个包含WPF表单的类库 dll?当我尝试构建一个时,我得到以下错误:
错误1库项目文件无法指定
ApplicationDefinition元素.
错误2项目文件包含无效的属性值.
如果我将我的项目设置为Windows应用程序,它将编译并运行.有没有办法解决这个问题?我正在使用VS2010和C#.NET 4.0,如果这可能是你们感兴趣的话.
谢谢
我遇到了Excel Interop的问题.
即使我重新发布实例,Excel.exe也不会关闭.
这是我的代码:
using xl = Microsoft.Office.Interop.Excel;
xl.Application excel = new xl.Application();
excel.Visible = true;
excel.ScreenUpdating = false;
if (wordFile.Contains(".csv") || wordFile.Contains(".xls"))
{
//typeExcel become a string of the document name
string typeExcel = wordFile.ToString();
xl.Workbook workbook = excel.Workbooks.Open(typeExcel,
oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing);
object outputFileName = null;
if (wordFile.Contains(".xls"))
{
outputFileName = wordFile.Replace(".xls", ".pdf");
}
else if (wordFile.Contains(".csv"))
{
outputFileName = wordFile.Replace(".csv", ".pdf");
}
workbook.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, outputFileName,
XlFixedFormatQuality.xlQualityStandard, oMissing,
oMissing, …Run Code Online (Sandbox Code Playgroud) 我有两个.NET应用程序通过命名管道相互通信.第一次通过时一切都很好,但是在发送第一条消息之后,服务器将再次监听,该WaitForConnection()方法抛出一条System.IO.Exception消息管道已损坏.
为什么我在这里得到这个例外?这是我第一次使用管道,但类似的模式在过去使用套接字对我有用.
代码啊!
服务器:
using System.IO.Pipes;
static void main()
{
var pipe = new NamedPipeServerStream("pipename", PipeDirection.In);
while (true)
{
pipe.Listen();
string str = new StreamReader(pipe).ReadToEnd();
Console.Write("{0}", str);
}
}
Run Code Online (Sandbox Code Playgroud)
客户:
public void sendDownPipe(string str)
{
using (var pipe = new NamedPipeClientStream(".", "pipename", PipeDirection.Out))
{
using (var stream = new StreamWriter(pipe))
{
stream.Write(str);
}
}
}
Run Code Online (Sandbox Code Playgroud)
对sendDownPipe的第一次调用让服务器打印我发送的消息就好了,但是当它再循环回来再次监听时,它就会大便.
我有一个应用程序,在所选文件夹中侦听*.log文件.我用过FileSystemWatcher.
但有一个问题.负责制作该文件的另一个应用程序采取以下步骤:
我无法改变这种行为.
所以我FileSystemWatcher为*.gz和*.txt文件做了2 秒.为什么?因为此应用程序有时不解压缩gz文件,有时不会将txt文件重命名为最终的*.log文件.
FileSystemWatcher2 捕获txt文件,然后(在大多数情况下,它被重命名为在接下来的1000毫秒登录)我需要等待一段时间来检查是否存在txt文件(如果没有,它似乎被重命名为最终的*.log文件).
问题是,如何检查文件是否存在而不Thread.Sleep()阻止UI冻结?
我希望很清楚,如果不是,我会尝试更好地描述它.我认为这是一个复杂的问题.
一些代码示例:
Watz for gz文件:
private void fileSystemWatcher_Created(object sender, FileSystemEventArgs e)
{
//this is for gz files in case if gz file is not unpacked automatically by other app
//I need to wait and check if gz was unpacked, if not, unpack it by myself,
//then txt watcher will catch that
Thread.Sleep(5000);
if (File.Exists(e.FullPath))
{
try
{
byte[] dataBuffer = new byte[4096];
using …Run Code Online (Sandbox Code Playgroud) 当我将ListBox直接绑定到ObservableCollection时,我得到了我的ListBox中显示的实时更新,但是只要我在混合中添加其他LINQ方法,我的ListBox就不会再通知ObservableCollection的任何更改.
在这里,让我举一个例子来说明;
public partial class MainPage : PhoneApplicationPage
{
ObservableCollection<String> Words = new ObservableCollection<string>();
public MainPage()
{
InitializeComponent();
listBox1.ItemsSource = Words;
}
private void AddButton_Click(object sender, RoutedEventArgs e)
{
Words.Add(DateTime.Now.ToString());
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我向一个简单的页面添加了一个Button和一个ListBox,然后单击该按钮使新项目立即出现在ListBox中.
但是,如果我改变了
listBox1.ItemsSource = Words;
Run Code Online (Sandbox Code Playgroud)
至
listBox1.ItemsSource = Words.Where(w => w.Contains(":"));
Run Code Online (Sandbox Code Playgroud)
ListBox不再更新.
如何在我的ObservableCollection和ListBox之间添加"过滤器",并且仍然可以在不必再次设置.ItemsSource的情况下进行更新?