小编Mac*_*iek的帖子

有没有办法将OwinRequest转换为HttpRequestBase?

我正在编写一个Owin Middleware,我需要使用一些遗留代码,它使用HttpRequestBase作为方法参数.遗留代码不遵循SOLID所以不可能把它扩大到使用OwinRequest代替HttpRequestBase的

是否有将OwinRequest转换为HttpRequestBase的扩展(或方法)?

c# owin

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

是否可以跨进程使用函数指针?

我知道每个进程都创建了自己的内存地址空间,不过我想知道,

如果进程A具有如下函数:

int DoStuff() { return 1; }
Run Code Online (Sandbox Code Playgroud)

和指针typedef,如:

typedef int(DoStuff_f*)();
Run Code Online (Sandbox Code Playgroud)

和一个getter函数,如:

DoStuff_f * getDoStuff() { return DoStuff; }
Run Code Online (Sandbox Code Playgroud)

和一个通过...进行通信的神奇方式...说boost :: interprocess

是否可以将函数指针传递给进程B并调用

直接从流程B处理A的DoStuff?

c++ boost ipc

7
推荐指数
2
解决办法
4918
查看次数

如何使用boost :: format生成十六进制输出?

考虑以下 :

#include <vector>
#include <string>
#include <iostream>

#include <boost/format.hpp>
#include <boost/assign.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/assign/std/vector.hpp>

using namespace std;

typedef unsigned char byte;
typedef vector<byte> byte_array;

const byte_array bytes = list_of(0x05)(0x04)(0xAA)(0x0F)(0x0D);

int main()
{
    const string formatter = "%1%-%2%-%3%-%4%-%5%";
    const string result = (format(formatter)
                           % bytes[0]
                           % bytes[1]
                           % bytes[2]
                           % bytes[3]
                           % bytes[4]
                                    ).str();
    cout << result << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我希望看到结果打印为:"05-04-AA-0F-0D".我需要做什么才能实现格式化程序字符串?

c++ boost

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

安装程序自定义操作问题 - 无法写入注册密钥

在自定义操作编辑器中,我已将自定义操作添加到安装和卸载过程的各个阶段.在属性窗口中,我将CustomActionData属性标记为:

/TARGETDIR = "[TARGETDIR]"
Run Code Online (Sandbox Code Playgroud)

我希望上面的安装目录信息传递给自定义操作.

自定义操作似乎正在触发,但我收到以下错误消息:

"错误1001.无法写入注册表的密钥"(或类似的东西,我正在用我的本地语言翻译它).

我究竟做错了什么?

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
//using System.Windows.Forms;
using Microsoft.Win32;

namespace CustomActions
{
    [RunInstaller(true)]
    public partial class Installer1 : Installer
    {
        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);

            const string key_path = "SOFTWARE\\VendorName\\MyAppName";
            const string key_value_name = "InstallationDirectory";

            RegistryKey key = Registry.LocalMachine.OpenSubKey(key_path);

            if (key == null)
            {
                key = Registry.LocalMachine.CreateSubKey(key_path);
            }

            string tgt_dir = Context.Parameters["TARGETDIR"];

            key.SetValue(key_value_name, tgt_dir);

        }

        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState); …
Run Code Online (Sandbox Code Playgroud)

c# installer custom-action visual-studio-2008

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

读取std :: string的注册表键值的最简单方法是什么?

读取std :: String的注册表键值的最简单方法是什么?

说我有:

HKEY_LOCAL_MACHINE / SOFTWARE / MyApp / value1 = "some text"
HKEY_LOCAL_MACHINE / SOFTWARE / MyApp / value2 = "some more text"
Run Code Online (Sandbox Code Playgroud)

如何快速将这些值传递给std :: string?

c++ registry

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

RS232串口通信c#win7 .net framework 3.5 sp1

我是新的c#串口.即时编写ac#program running是winXP和win7,用于在机器发送数据时保持从串口接收的数据.

using System.IO;
using System.IO.Ports;
using System.Threading;


namespace RS232RVR
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        SettingRS232();
    }

    public void SettingRS232 ()
    {
        try
        {
            SerialPort mySerialPort = new SerialPort("COM6");

            mySerialPort.BaudRate = 9600;
            mySerialPort.Parity = Parity.None;
            mySerialPort.StopBits = StopBits.One;
            mySerialPort.DataBits = 8;
            mySerialPort.Handshake = Handshake.None; //send to hardware flow control.

            mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceviedHandler);

            mySerialPort.Open();


            richTextBox1.Text = "on";

            mySerialPort.Close();
        }
        catch (Exception ex)
        {
            richTextBox1.Text = ex.Message;    
        }

    }

    private void DataReceviedHandler(
                    object sender, …
Run Code Online (Sandbox Code Playgroud)

c# .net-3.5 windows-7

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

Silverlight 3.0:如何通过x获取网格子项:名称?

让我们假设我有XAML代表一个Grid,里面有一些孩子,每个孩子都是一个不同的控件,用ax:Name.如何从代码中"获取"这些控件?

grid silverlight-3.0

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

套接字ObjectDisposed异常

我正在开发一个专门用于Tcp通信的小型.dll,

在我的项目中,我有一个使用TcpListener接受传入连接的服务器类.传入连接存储在字典中并从那里进行处理.

每个连接的代码如下所示:

 public class Connection : ConnectionBase<Coder.Coder>
    {
        public Connection(TcpClient client, Guid id) : base()
        {
            Id = id;
            Client = client;
        }

        public void Start()
        {
            IsConnected = true;            
            Client.Client.BeginReceive(m_message, 0, m_message.Length, SocketFlags.None, new AsyncCallback(on_data_received), null);            
        }

        public void Stop()
        {
            try
            { 
                Client.Close();
                handle_connection_lost(new ConnectionLostArgs(Id));
            }
            catch
            { }
        }

        public void Send(byte[] data)
        {
            try
            {
                using (NetworkStream s = Client.GetStream())
                {
                    using (BinaryWriter w = new BinaryWriter(s))
                    {
                        var buffer = m_coder.Encode(data);
                        w.Write(buffer);
                        w.Flush();
                    } …
Run Code Online (Sandbox Code Playgroud)

c# sockets

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

自定义.config文件中无法识别的属性"xmlns"

我已经创建了一个自定义System.Configuration.ConfigurationSection,我将其保存在一个单独的配置文件中,并将其包含在我的web.config中'configSource="MyCustomConfigFile.config"'

我还为自定义配置文件创建了一个.xsd架构,以添加一些好处,如架构验证/智能感知 - 这很好用.

尝试启动应用程序(在IIS8,.NET 4.5.1中托管)时,我收到以下错误:

配置错误说明:处理为此请求提供服务所需的配置文件时发生错误.请查看下面的具体错误详细信息并相应地修改配置文件.

分析器错误消息:无法识别的属性"xmlns".请注意,属性名称区分大小写.

来源错误:

第1行:<?xml version ="1.0"encoding ="utf-8"?>

第2行:<identityServer xmlns ="http://myCustomNamespace.xsd">

说实话,我很惊讶 - 有人能告诉我如何解决这个问题而不删除xmlns以便我可以保留架构验证/智能感知吗?

c# xml asp.net asp.net-mvc

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

Python:获取当前目录中的所有exe文件并运行它们?

首先,这不是家庭作业,我迫切需要一个脚本来完成以下工作,我的问题是,我以前从来没有处理过python所以我几乎不知道如何使用它 - 我需要它通过命令行构建运行器在TeamCity中启动单元测试

我需要的是:

一个将运行脚本的*.bat文件

一个python脚本将:

  • 获取当前工作目录中的所有*_test.exe文件
  • 运行搜索结果的所有文件

最好的祝福

python teamcity-5.1

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