小编jav*_*red的帖子

调用 dll 方法时出现 FatalExecutionEngineError

在我这一行的程序中:

int value = MTEConnect(auth_string, err);
Run Code Online (Sandbox Code Playgroud)

我收到这样的例外:

FatalExecutionEngineError 
The runtime has encountered a fatal error. The address of the
error was at 0x68c8a681, on thread 0x2334. The error code is
0xc0000005. This error may be a bug in the CLR or in the unsafe
or non-verifiable portions of user code. Common sources of this
bug include user marshaling errors for COM-interop or PInvoke,
which may corrupt the stack.
Run Code Online (Sandbox Code Playgroud)

MTEConnect 是这样导入的:

    [DllImport("mtesrl.dll", CharSet = CharSet.Ansi)]
    private static extern int MTEConnect(String pars, …
Run Code Online (Sandbox Code Playgroud)

.net c#

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

xsl:如何在"匹配"中使用参数?

我的xsl有一个参数

<xsl:param name="halfPath" select="'halfPath'"/>
Run Code Online (Sandbox Code Playgroud)

我想在比赛中使用它

<xsl:template match="Element[@at1='value1' and not(@at2='{$halfPath}/another/half/of/the/path')]"/>
Run Code Online (Sandbox Code Playgroud)

但这不起作用.我想一个不能在''里面使用参数.如何修复/解决这个问题?

xslt

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

如何添加调试代码?(应该去Debug,不应该去发布)

我需要在我的软件中记录大量信息以进行调试.但是我只在开发期间需要这个选项,我宁愿在Release中排除所有这些代码.

当然我可以用"if"包围我想调试的地方:

if (isDebugMode()) {
  Logger.log(blahblah);
}
Run Code Online (Sandbox Code Playgroud)

但是因为我的软件对时间要求很高,所以我想避免大量的unnesseray"if"测试.

即我认为我需要模拟c"#define #ifdef #ifndef".c#或.net中是否有任何技术可以轻松解决我的任务?

.net c#

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

如何在jtable中灰​​显不可编辑的单元格?

我想在JTable中灰​​化不可编辑的单元格.我正在使用这样的TableCellRenderer:

TableColumn column = table.getColumnModel().getColumn(0);
column.setCellRenderer(new GrayableCheckboxCellRenderer());

public class GrayableCheckboxCellRenderer extends JCheckBox implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int vRowIndex, int vColIndex) {           
            boolean editable = isEditable(vRowIndex, vColIndex);
        setBackground(editable ? UIManager.getColor("Label.background") : Color.LIGHT_GRAY);
        setSelected((Boolean) value);
                if (isSelected) {
                    // TODO: cell (and perhaps other cells) are selected, need to highlight it
                }
        return this;
    }
    // perfomance
    protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {}
    public void firePropertyChange(String propertyName, boolean oldValue, boolean …
Run Code Online (Sandbox Code Playgroud)

java swing jtable

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

我的第一个WCF服务器 - 为什么OperationContext.Current为null?

我想实现我的第一个WCF回叫服务器.这是我的代码:

[ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(ILogCallback))]
public interface ILog
{
}

public interface ILogCallback
{
    [OperationContract(IsOneWay = true)]
    void Push(string callbackValue);
}

public class MyLog : ILog
{

}

class Log
{


    public static void initialize()
    {
        using (ServiceHost host = new ServiceHost(
            typeof (MyLog),
            new Uri[]
                {
                    new Uri("net.pipe://localhost")
                }))
        {

            host.AddServiceEndpoint(typeof (ILog),
                                    new NetNamedPipeBinding(),
                                    "PipeReverse");

            host.Open();
            // TODO: host.Close();
        }
    }

    public static void Push(string s)
    {
        ILogCallback callbacks = OperationContext.Current.GetCallbackChannel<ILogCallback>();
        callbacks.Push(s);
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我尝试使用此代码使用我的服务器:

        Log.initialize();

        while …
Run Code Online (Sandbox Code Playgroud)

c# wcf

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

WPF DataGrid双击命令+ INotifyPropertyChanged?

我希望在单击DataGrid项时在我的ViewModel中执行一个命令.作为参数,我希望有相应的行.

我在互联网上找到了一种方法,但它使用了 DependencyProperty

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/632ea875-a5b8-4d47-85b3-b30f28e0b827

我没有DependencyProperty在我的项目中使用,而是我正在使用INotifyPropertyChanged.如何实现"双击数据网格"commaind而不使用DependencyProperty

c# wpf mvvm

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

Math.Round vs String.Format

我需要将double值四舍五入为2位数.什么是可取的?

String.Format("{0:0.00}", 123.4567);      // "123.46"
Math.Round(123.4567, 2)                   // "123.46"
Run Code Online (Sandbox Code Playgroud)

c#

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

如何计算msms中两个DateTime之间的差异?

根据msdn DateTime,精度为10毫秒.因此t2-t1,下面示例中的精度也是10 ms.但是返回的值是"双倍",令人困惑.

DateTime t1 = DateTime.Now; // precision is 10 ms
....
DateTime t2 = DateTime.Now; // precision is 10 ms
... (t2-t1).TotalMilliseconds; // double (so precision is less than 1 ms???)
Run Code Online (Sandbox Code Playgroud)

我期望int值,因为当精度为10 ms时,double值没有意义.我需要在Thread.Sleep()中使用结果值.我应该转换为int吗?

c#

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

为什么要使用queue.Peek()而不是queue.First()/ Last()

队列中含有特殊的方法queue.Peek(),我为什么要使用它时,我可以使用一般的queue.First()queue.Last()

c#

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

提升deadline_timer最小例子:我应该替换"睡眠"吗?

我有一个线程,我需要每隔10毫秒做一些事情.所以我有非常简单的代码,像那样:

while (work) {
    // do something
    Sleep(10000); // boost sleep can be also used
}
Run Code Online (Sandbox Code Playgroud)

我听说Sleep一般不推荐这样做,如果我用deadline_timer整体应用程序性能替代它会更好,特别是我会避免昂贵的"上下文切换".

我应该改变sleep,以deadline_timer若然有人可以举个例子?

c++ boost

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

标签 统计

c# ×7

.net ×2

boost ×1

c++ ×1

java ×1

jtable ×1

mvvm ×1

swing ×1

wcf ×1

wpf ×1

xslt ×1