小编pen*_*ght的帖子

System.Diagnostics.EventLog - 连接到系统的设备无法运行

我做了一些谷歌,没有任何"设备附加"错误与事件日志有任何关系.我也在Micosoft fourm发布了问题,但没有回复.以为我会给你们一个机会.这里是问题的链接.https://social.msdn.microsoft.com/Forums/en-US/d484d9dc-d9eb-4d19-97b8-9ae4db63e041/systemdiagnosticseventlog-a-device-attached-to-the-system-is-not-functioning?forum= netfxbcl

这是错误消息:

System.ComponentModel.Win32Exception was caught
  ErrorCode=-2147467259
  HResult=-2147467259
  Message=A device attached to the system is not functioning
  NativeErrorCode=31
  Source=System
  StackTrace:
       at System.Diagnostics.EventLogInternal.InternalWriteEvent(UInt32 eventID, UInt16 category, EventLogEntryType type, String[] strings, Byte[] rawData, String currentMachineName)
       at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
       at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type)
       at VB_Braums_ClassLib.LogIt.WriteEventLog(String Entry, EventLogEntryType eventType, String Source) in \\Corp01\Vol1\Mis\Pccode\Ms.net\ProductionLibs\ProductionLibs\ProdLibCommon.vb:line 3666
  InnerException: 
Run Code Online (Sandbox Code Playgroud)

这段代码在库中,所以我创建了一个"hello world"来演示这个问题.我会在最后发布.这个.net 4框架已经在我们的代码中存在了一段时间.我们开始从XP升级到Win 7.基本上,事件日志大小限制为32667号码.所以我们进行了测试,如果字符串大于那个,那么我们将把它写成32000字节的卡盘.在两个不同的win7框中,我们收到"设备附加"错误消息.在XP机器上运行相同的代码,它的工作原理.哦,Win 7盒子是64位.我想知道胜利7 32位是否会有同样的问题?其他人可以复制它吗?tmpsize似乎是不同的数字,但如果你玩它,你可以把它降到数字x作品和(x + 1)没有.大约在30000到32000之间.从大多数snighfict值开始,向下移动,

Module Module1
    Sub Main()

        Dim logName As String = "BraumsLog" …
Run Code Online (Sandbox Code Playgroud)

.net windows-xp custom-eventlog windows-7

5
推荐指数
1
解决办法
2462
查看次数

初始化脚本“ / dev / tty:无此设备或地址”重定向时出错

我将在底部包含整个脚本,以供参考。该脚本在初始化脚本的末尾被调用。如果我在登录后运行该脚本,则该脚本将正常运行。30000英尺视图,试图执行rsync命令并将任何错误捕获到一个变量中。我正在使用bash 3.5.6pl。

这是罪魁祸首:

LogMessage+=$(rsync -rpltDzv --delete --progress /mnt/WinPrimary /mnt/WinBackup 2>&1 >/dev/tty)$'\n'
Run Code Online (Sandbox Code Playgroud)

变量中存储的内容(确实写入日志)是:

/etc/Braums/scripts/Sync1to2.sh: line 47: /dev/tty: No such device or address
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索了捕获stderr而不是stdout的语法技术。我希望显示进度,而不是捕获所有屏幕内容。因此,初始化将脚本称为“ Sync1to2.sh”。其中具有以上命令。如果我登录后从命令行运行相同的脚本,则它将按预期运行。

这是整个Sync1to2.sh脚本。我不经常执行bash脚本,因此要小心,不要伤自己大笑。下面的另一点是我尝试使用/ dev / stdout时,它具有一些诊断功能。我敢打赌,盖蒂跑了什么事?

#!/bin/bash
#
#Variable to set if an error occurs at any point during the process.
ErrorOccured="False"
LogMessage=""

LogMessage+=$0$' was stated at '$(date)$'\n'

if !(mount | grep -cq "/mnt/WinPrimary")
then
    LogMessage+=$'=============================================\n'
    LogMessage+=$'][ No Windows Primary found.               ][\n'
    LogMessage+=$'][  Check drives and try again.            ][\n'
    LogMessage+=$'=============================================\n'
    ErrorOccured="True"
fi
if !(mount | grep -cq "/mnt/WinBackup")
then …
Run Code Online (Sandbox Code Playgroud)

linux variables bash shell stderr

2
推荐指数
1
解决办法
3405
查看次数

标签 统计

.net ×1

bash ×1

custom-eventlog ×1

linux ×1

shell ×1

stderr ×1

variables ×1

windows-7 ×1

windows-xp ×1