小编Dev*_*van的帖子

如何在unix中杀死tty

这是该finger命令的结果(今天(星期一)我(Vidya)登录时)

sekic1083 [6:14am] [/home/vidya] -> finger
Name        Tty       Idle   Login Time    Where
Felix   pts/0        -       Thu 10:06  sekic2594.rnd.ki.sw.
john        pts/1       2d       Fri 15:43
john        *pts/2      2d       Fri 15:43
john      *pts/3       4     Fri 15:44
john      *pts/7       -         Thu 16:25
Vidya      pts/0       -         Mon 06:14
Vidya     *pts/5       -         Mon 06:14
Vidya     *pts/6       -         Tue 10:13
Vidya     *pts/9       -         Wed 05:39
Vidya     *pts/10      -         Wed 10:23
Run Code Online (Sandbox Code Playgroud)

在列下,Tty pts/0 and pts/5是当前活动终端.

除了那两个pts/6,pts/9并且pts/10也在场,我上周登录了这些.但是他们的空闲时间显示为" - "(不是空闲). …

unix linux

29
推荐指数
4
解决办法
12万
查看次数

如何在C#上阅读打开的excel文件

我想用C#读取已打开的excel文件.我正在使用此方法,但它在Microsoft Excel中打开文件时无法读取excel文件.

FileStream stream = File.Open("myfile.xlsx", FileMode.Open, FileAccess.Read);
Run Code Online (Sandbox Code Playgroud)

它给 IOException: The process cannot access the file 'myfile.xlsx' because it is being used by another process.

我希望你明白我的意思.我想保持excel文件打开,当文件在Microsoft Excel打开时,我想从C#中读取它.我正在使用C#net framework 4.0

c# excel file-io ioexception

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

C++中的工厂模式 - 正确执行此操作?

我对"设计模式"相对较新,因为它们在正式意义上被提及.我很久没有成为一名专业人士,所以我对此很陌生.

我们有一个纯虚拟接口基类.这个接口类显然是提供了派生子进程应该做什么功能的定义.软件中的当前用法和情况决定了我们想要使用什么类型的派生子,因此我建议创建一个包装器,它将传达我们想要的派生子类型,并返回指向新派生对象的Base指针.据我所知,这个包装器是一个工厂.

好吧,我的一位同事在Base类中创建了一个静态函数来充当工厂.这有两个原因导致我麻烦.首先,它似乎打破了Base类的接口性质.我认为界面本身需要知道从中衍生出来的孩子,这对我来说是错误的.

其次,当我尝试在两个不同的Qt项目中重用Base类时,会导致更多问题.一个项目是我实现第一个(可能只是这个类的真正实现......虽然我想对其他两个具有几个不同派生类的特性使用相同的方法)派生类,第二个是实际最终将使用我的代码的应用程序.在我编写代码时,我的同事创建了一个派生类,作为真实应用程序的测试人员.这意味着我必须将他的标题和cpp文件添加到我的项目中,这似乎是错的,因为我在实现我的部分时甚至没有使用他的代码用于项目(但是当它完成时他将使用我的).

我是否正确认为工厂真的需要成为Base类的包装而不是作为工厂的Base?

c++ design-patterns interface factory-pattern

12
推荐指数
1
解决办法
8638
查看次数

Win32 EXCEPTION_INT_OVERFLOW与EXCEPTION_INT_DIVIDE_BY_ZERO

我有关于EXCEPTION_INT_OVERFLOW和EXCEPTION_INT_DIVIDE_BY_ZERO异常的问题.

Windows将捕获由IDIV指令生成的#DE错误,并最终使用这两个代码之一生成SEH异常.

我的问题是它如何区分这两个条件?英特尔手册中有关idiv的信息表明它将在"除以零"和"下溢情况"中生成#DE.

我快速浏览了intel手册第3卷中#DE错误的部分,我能收集的最好的是操作系统必须解码DIV指令,加载除数参数,然后将其与零进行比较.

这对我来说似乎有点疯狂.为什么芯片设计者不会使用某种标志来区分错误的两个原因?我觉得我必须遗漏一些东西.

有谁知道操作系统如何区分两种不同的故障原因?

windows x86 assembly exception

10
推荐指数
1
解决办法
1322
查看次数

WCF有异常传递给客户端

我有一个可能会抛出异常的服务.我希望能够在客户端捕获异常.我感兴趣的主要例外是DbUpdateExceptionInvalidOperationException.对于其余的异常,足以知道异常已被抛出.

如何在客户端捕获异常?

wcf exception

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

代表heirarchical枚举

我有一组枚举值(准确的故障代码).代码是16位无符号整数.我正在寻找一个可以代表这种枚举的数据结构.这里也提出了类似的问题:使用枚举实现层次结构的最佳C#模式是什么?.但这种等级更深层次.


示例枚举值

Current = 0x2000,
Current_DeviceInputSide = 0x2100,
ShortToEarth = 0x2120,
ShortToEarthInPhase1 = 0x2121,
ShortToEarthInPhase2 = 0x2122,
ShortToEarthInPhase3 = 0x2123
Run Code Online (Sandbox Code Playgroud)


用例
当用户提供代码时,UI必须显示具有层次结构的代码的等效含义.
例如,如果用户提供值,0x2121则必须显示UI Short to earth in phase 1 in the current at device input side.表示这一点的最好方法是使用分层表示法:Current : DeviceInputSide : ShortToEarth : ShortToEarthInPhase1.


竞争方法
我有三种竞争方法来表示枚举:

  1. 在层次结构的每个级别创建枚举.然后使用控制器类来解析名称.
  2. 将枚举值存储在xml中,并使用LINQ生成代码的含义.
  3. 将枚举值存储在xml中.在应用程序启动期间.创建单例实例以检索含义.该实例包含一个填充了xml值的字典.


方法1
枚举:

enum WarnCodes
{
    None= 0x000,
    Current = 0x2000
}

enum WarnCodes_Current
{
    DeviceInputSide = 0x2100,
    DeviceOutputSide = 0x2200
}

enum WarnCodes_Current_DeviceInputSide
{
    ShortToEarth = …
Run Code Online (Sandbox Code Playgroud)

.net c# enumeration

8
推荐指数
2
解决办法
1822
查看次数

"功能已经有了身体"

这是什么意思?

1>c:\users\vitali\documents\visual studio 2010\projects\salam\tools.cpp(107): error C2084: function 'bool readXMLInteger(xmlNodePtr,const char *,int &)' already has a body
1>c:\users\vitali\documents\visual studio 2010\projects\salam\tools.h(52) : see previous definition of 'readXMLInteger'
Run Code Online (Sandbox Code Playgroud)

tools.cpp(107):

bool readXMLInteger(xmlNodePtr node, const char* tag, int32_t& value)
{
    char* nodeValue = (char*)xmlGetProp(node, (xmlChar*)tag);
    if(nodeValue)
    {
        value = atoi(nodeValue);
        xmlFreeXOXL(nodeValue);
        return true;
    }

    return false;
}
Run Code Online (Sandbox Code Playgroud)

的Tools.h(52)

bool readXMLInteger(xmlNodePtr node, const char* tag, int& value);
Run Code Online (Sandbox Code Playgroud)

visual-c++

5
推荐指数
2
解决办法
4万
查看次数

System.ExecutionEngineException 被抛出

当这行代码执行时抛出此异常

retobj = Marshal.PtrToStructure( buffer, anytype );
Run Code Online (Sandbox Code Playgroud)

我不知道是什么原因造成的,因为我尝试运行的应用程序在其他开发人员的计算机上运行良好。

public static object RawDeserialize(byte[] rawdatas, Type anytype) 
{
    int rawsize = Marshal.SizeOf(anytype);

    if (rawsize > rawdatas.Length)
    {  
        return null;
    }

    IntPtr buffer = Marshal.AllocHGlobal(rawsize);
    object retobj = null;

    try 
    {
         Marshal.Copy(rawdatas, 0, buffer, rawsize);
         retobj = Marshal.PtrToStructure(buffer, anytype);
    }
    finally 
    {
         Marshal.FreeHGlobal(buffer);
    }

    return retobj;
}
Run Code Online (Sandbox Code Playgroud)

我已多次尝试修复 .NET Compact Framework,但似乎没有任何效果,有人知道解决此问题的方法吗?

.net c# .net-3.5

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

SQLiteException:没有这样的表

我正在使用自己的SQLite3数据库,而不是每次我的应用程序运行时创建一个新数据库,因为我有一些表,我正在尝试显示静态数据.我创建了我的数据库并将其放在我的资源文件夹中.然后我创建了我的数据库助手,当我启动我的应用程序时,我可以毫无问题地打开我的数据库但是当我尝试使用以下代码打开我的第一个表时

private Cursor getData() 
{
    try
    {
        myDbHelper = new DatabaseHelper(this);
        SQLiteDatabase db = myDbHelper.getReadableDatabase();
        Cursor cursor = db.query("exhibitor", FROM, null, null, null,null, ORDER_BY);
        startManagingCursor(cursor);
        return cursor;
    }
    catch(SQLiteException e)
    {
        String err = e.toString();
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)


它引发了一个错误说android.database.sqlite.SQLiteException: no such table: exhibitor: , while compiling: SELECT _id, EXHIBITOR FROM exhibitor ORDER BY EXHIBITOR,但当我检查数据库参展商在那里.

我错过了什么?

database sqlite android

4
推荐指数
3
解决办法
3万
查看次数

使用WPF的ShowDialog打开表单时出现异常


我有一个WPF应用程序,当尝试使用时打开一个表单ShowDialog(),我在下面的一台机器上得到了这个奇怪的例外.
知道问题可能是什么?

异常消息=操作已中止(HRESULT异常:0x80004004(E_ABORT))异常堆栈跟踪=
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode,IntPtr errorInfo)System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, MS.Internal.FontCache.FamCollection.LookupFamily上的MS.Internal.Text.TextInterface.FontCollection.FindFamilyName(String familyName,UInt32&index)中的MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32hr)处的IntPtr errorInfo) System.Windows.Media.FontFamily.LookupFontFamilyAndFace(CanonicalFontFamilyReference canonicalFamilyReference,FontStyle&style,FontWeight&weight,FontStretch&stretch)在System.Windows.Media.FontFamily.FindFirstFontFamilyAndFace上的字符串familyName,FontStyle&fontStyle,FontWeight&fontWeight,FontStretch&fontStretch(FontStyle&style,在Syste的System.Windows.Media.Typeface.ConstructCachedTypeface()的FontWeight&weight,FontStretch&stretch)m.Windows.Media.Typeface.get_CachedTypeface()在MS.Internal.TextFormatting.SimpleTextLine..ctor(FormatSettings设置,的Int32 cpFirst,的Int32 paragraphWidth,ArrayList中运行时,的Int32&后,的Int32&trailingSpaceWidth)
在MS.Internal.TextFormatting.SimpleTextLine.在MS.Internal.TextFormatting的MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource,Int32 firstCharIndex,Int32 lineLength,Double paragraphWidth,TextParagraphProperties paragraphProperties,TextLineBreak previousLineBreak,TextRunCache textRunCache)中创建(FormatSettings设置,Int32 cpFirst,Int32 paragraphWidth). System.Windows.Controls.TextBoxLine.Format(Int32 dcp,Double formatWidth,Double paragraphWidth,LineProperties lineProperties,TextRunCache textRunCache,TextFormatter formatt)中的TextFormatterImp.FormatLine(TextSource textSource,Int32 firstCharIndex,Double paragraphWidth,TextParagraphProperties paragraphProperties,TextLineBreak previousLineBreak,TextRunCache textRunCache)呃)System.Windows上的System.Windows.FrameworkElement.MeasureCore(Size availableSize)上的System.Windows.Controls.TextBoxView.MeasureOverride(Size constraint)中的System.Windows.Controls.TextBoxView.FullMeasureTick(Double constraintWidth,LineProperties lineProperties). UIElement.Measure(尺码availableSize)在MS.Internal.Helper.MeasureElementWithSingleChild(的UIElement元件,尺寸约束)在System.Windows.Controls.ScrollContentPresenter.MeasureOverride(尺寸约束)在System.Windows.FrameworkElement.MeasureCore(尺码availableSize)在系统.Windows.UIElement.Measure(尺码availableSize)在System.Windows.Controls.Grid.MeasureCell(的Int32细胞,布尔forceInfinityV)在System.Windows.Controls.Grid.MeasureCellsGroup(的Int32 cellsHead,尺寸referenceSize,布尔ignoreDesiredSizeU,布尔forceInfinityV) System.Windows.UIElement.Measure上的System.Windows.FrameworkElement.MeasureCore(Size availableSize)中的System.Windows.Controls.Grid.MeasureOverride(Size约束)(大小可用)System.Windows.Controls.Border.MeasureOverride上System.Windows.UIElement.Measure(Size availableSize)的System.Windows.FrameworkElement.MeasureCore(Size availableSize)上的System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)处的ableSize) System.Windows.FrameworkElement.MeasureCore上System.Windows.Controls.Control.MeasureOverride(Size constraint)上System.Windows.UIElement.Measure(Size availableSize)的System.Windows.FrameworkElement.MeasureCore(Size availableSize)上的(大小约束) System.Windows.Controls.Grid.MeasureCell(Int32 cell,Boolean forceInfinityV)中的System.Windows.UIElement.Measure(Size availableSize)上的(size availableSize)System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,Size referenceSize,系统中的System.Windows.FrameworkElement.MeasureCore(Size availableSize)上的System.Windows.FrameworkElement.MeasureCore(Size availableSize)中的系统布局ignoreDesiredSizeU,布尔forceInfinityV)在Sys的System.Windows.UIElement.Measure(Size availableSize)tem.Windows.Controls.StackPanel.MeasureOverride(尺寸约束)在System.Windows.FrameworkElement.MeasureCore(尺码availableSize)在System.Windows.UIElement.Measure(尺码availableSize)在MS.Internal.Helper.MeasureElementWithSingleChild(的UIElement元件,尺寸System.Windows.Documents.AdasurenerDecorator.MeasureOverride上System.Windows.UIElement.Measure(Size availableSize)的System.Windows.FrameworkElement.MeasureCore(Size availableSize)上的System.Windows.Controls.ContentPresenter.MeasureOverride(Size约束)处理约束. System.Windows.FrameworkElement.MeasureCore上System.Windows.Controls.Border.MeasureOverride(Size constraint)的System.Windows.UIElement.Measure(Size availableSize)上的System.Windows.FrameworkElement.MeasureCore(Size availableSize)的(大小约束) System.Windows.Uasurelement.Measure(Size availableSize)的System.Windows.Uasurelement.Measure(Size availableSize)的大小(available availableSize)位于Syste的System.Windows.Window.MeasureOverride(Size availableSize)的System.Windows.WindOverrideHelper(Size constraint)System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)at的System.Windows.Interop.HwndSource.SetLayoutSize()处的System.Windows.UIElement.Measure(Size availableSize)中的m.Windows.FrameworkElement.MeasureCore(Size availableSize) System.Windows.Interop.HwndSource.set_RootVisual(视觉值)System.Windows.Window.SetRootVisual()在System.Windows.Window.SetRootVisualAndUpdateSTC()在System.Windows.Window.SetupInitialState(双人间requestedTop,双requestedLeft,双requestedWidth …

.net wpf exception

4
推荐指数
1
解决办法
2640
查看次数