小编Car*_*ten的帖子

准确导入的组件中的CoClass接口是什么?

使用该tlbimp.exe工具导入基本类型库会为每个库创建一个接口coclass.例如,这个IDL描述

interface IFoo : IUnknown
{
    HRESULT DoSomething();
}

coclass Bar
{
    [default] interface IFoo;
}
Run Code Online (Sandbox Code Playgroud)

结果是:

  • 一个接口IFoo作为COM接口的表示,
  • 一个类BarClass作为COM coclass和的表示
  • 一个接口Bar,用CoClassAttribute.注释.

GUID BarIFoo等于的GUID .在MSDN上这个话题指出:

此接口与coclass的默认接口具有相同的IID.通过此接口,客户端始终可以注册为事件接收器.

这是我在这个主题上唯一发现的东西.我知道,由于CoClassAttribute,我可以使用该接口来创建实际类的实例.我也知道(实际上)我可以简单地BarClass用来创建一个新的类实例.我不明白的是,为什么导入过程会生成Bar接口,即使coclass没有定义事件源,因此也没有事件接收器可以连接到它.

是否有可能在此示例中删除Bar界面1或是否存在其他风险,我还没有考虑过?

1 例如,通过拆卸互操作组件.

.net c# com com-interop tlbimp

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

将Visual Studio解决方案的构建顺序输出到文本文件

有没有办法通过命令行将Build命令输出到文本文件?

解释:我们使用多个源代码分支,并在每个分支上拥有100多个项目的大型解决方案.我需要编写构建脚本来从命令行构建这些解决方案.然后,我们可以在分支机构上定制解决方案,以便仅为团队正在进行的项目提供项目引用.这应该会大大增加解决方案的加载时间,并减轻开发人员和我的挫败感,我希望:)

我将继续寻找并考虑使用C#和VS提供的API.我们正在使用2012年更新1.

c# msbuild visual-studio

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

Visual Basic中的WithEvents在更改对象的引用时是否保留其EventHandler?

WithEventsEventHandler更改对象的引用时,Visual Basic中是否保留了它?

说我已经宣布一个按钮,发射事件:

Private WithEvents _MyButton
Run Code Online (Sandbox Code Playgroud)

现在我订阅了一个事件处理程序:

Private Sub _MyButton_Click() Handles _MyButton.Click 
  ' Here I DoClick()
End Sub
Run Code Online (Sandbox Code Playgroud)

DoClick()当我更改按钮对象的实例时,是否仍会调用该函数,如下所示?

_MyButton = New Button()
Run Code Online (Sandbox Code Playgroud)

.net vb.net events handles event-handling

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

如何在OpenCV Matcher上访问积分位置?

我正在使用这个FLANN匹配算法来匹配下面显示代码的2张图片中的兴趣点.

有一段时间代码找到匹配点列表:

std::vector<DMatch> good_matches;
Run Code Online (Sandbox Code Playgroud)

我想在两张图片中得到点定位(x,y).创建置换贴图.我怎样才能访问这些点本地化?

干杯,

#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"

using namespace cv;

void readme();

/** @function main */
int main(int argc, char** argv) {
    if (argc != 3) {
        readme();
        return -1;
    }

    // Transform in GrayScale
    Mat img_1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
    Mat img_2 = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);

    // Checks if the image could be loaded
    if (!img_1.data || !img_2.data) {
        std::cout << " --(!) Error reading images " << std::endl;
        return -1; …
Run Code Online (Sandbox Code Playgroud)

c++ opencv matcher match points

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

在 ASP.NET WebService 中接受 UTF-8 编码的字符串

我有一个 ASP.NET WebService,它看起来像这样:

[WebMethod]
public static void DoSomethingWithStrings(string stringA, string stringB)
{
    // and so on
}
Run Code Online (Sandbox Code Playgroud)

第三方应用程序应调用此网络服务。但是,此应用程序将字符串编码为 UTF-8,并且所有变音符号都被替换为“??”。我可以查看呼叫并且特殊字符的格式很好:

<?xml version="1.0" encoding="utf-8" ?>
<!-- ... -->
<SoapCall>
    <DoSomethingWithStrings>
        <stringA>Ä - Ö - Ü</stringA>
        <stringB>This is a test</stringB>
    </DoSomethingWithStrings>
</SoapCall>
Run Code Online (Sandbox Code Playgroud)

当我简单地打印 webservice 方法中的字符串时,这会产生以下输出:

?? - ?? - ??

这是一个测试

如何配置 WebService 以接受 UTF-8 编码的字符串?

更新

Fiddler 还告诉我 http 请求的内容类型字符集是 UTF-8。

更新 2

我尝试添加以下代码以global.asax进行调试:

public void Application_BeginRequest(object sender, EventArgs e)
{
    using (var reader = new System.IO.StreamReader(Request.InputStream))
    {
        string str …
Run Code Online (Sandbox Code Playgroud)

asp.net unicode encoding web-services utf-8

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

排序动态列表是只读的吗?

我有一个动态列表,我尝试排序,然后根据新的排序顺序更改ID:

foreach (Case c in cases)
{
    bool edit = true;

    if (c.IsLocked.HasValue)
        edit = !c.IsLocked.Value;

    eventList.Add(new {
        id = row.ToString(),
        realid = "c" + c.CaseID.ToString(),
        title = c.CaseTitle + "-" + c.Customer.CustomerDescription,
        start = ResolveStartDate(StartDate(c.Schedule.DateFrom.Value.AddSeconds(row))),
        end = ResolveEndDate(StartDate(c.Schedule.DateFrom.Value), c.Schedule.Hours.Value),
        description = c.CaseDescription,
        allDay = false,
        resource = c.Schedule.EmployeID.ToString(),
        editable = edit,
        color = ColorConversion.HexConverter(System.Drawing.Color.FromArgb(c.Color.Value))
    });

    row++;

}

var sortedList = eventList.OrderBy(p => p.title);

for (int i = 0; i < sortedList.Count(); ++i)
{
    sortedList.ElementAt(i).id = i.ToString();
}
Run Code Online (Sandbox Code Playgroud)

但它sortedList.ElementAt(i).id …

c# linq asp.net

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

如何使用C#动态添加Include到ObjectSet <Entity>?

我想Include从输入中动态添加s params[].我怎样才能做到这一点?

这是我的代码

IQueryable<Work> query = this.ObjectContext.Works
    .Include("EmployeeSender.Person")
    .Include("EmployeeReceiver.Person")
    .Include("WorkCode")
    .Include("WorkFlowStep.WorkFlowFormState")
    .Include("WorkFlow")
    .Include("WorkRoot.EmployeeSender.Person")
    .Include("WorkParent");
Run Code Online (Sandbox Code Playgroud)

c# entity-framework

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

当&与两个整数C#结合使用时的奇怪结果

我无法理解发生了什么以及如何从以下几行得出结果:

例1:我得到1作为下面的结果.

int a = 1, b = 9;
int r = a & b;
Console.WriteLine(r);
Run Code Online (Sandbox Code Playgroud)

例2:我得到8作为下面的结果.

int a = 10, b = 9;
int r = a & b;
Console.WriteLine(r);
Run Code Online (Sandbox Code Playgroud)

我不知道在这种情况下的意义&和重要性&.如何操纵上述结果?什么是逻辑?

.net c#

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

如何通过CLSID在C#中实例化COM对象?

如果我的术语已经关闭,请原谅我,因为这对我来说是一个有点未知的领域.

我有一个需要创建的程序FolderShortcut.Microsoft有关于如何使用C++创建它的文档,我正在尝试将方向转换为C#.指令声明CoCreateInstance函数需要CLSID_FolderShortcut作为参数调用,我推断它意味着它实例化一个COM对象.此对象的CLSID是{0AFACED1-E828-11D1-9187-B532F1E9575D}.

我已尝试从COM选项卡添加对Shell32.dll的引用,但该FolderShortcut对象未显示在Intellisense中(可能它不在typelib中?).我也考虑过做一个DLLImport,但是,当然,这只能让我访问函数,而不是对象.

要在.Net中访问此对象,我需要做什么?

c# com pinvoke shell32

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

不能从已加载的输入文档中删除空格。而是将输入文档提供为XmlReader

我想转换一个XML文档,但是有一个问题。

我的XSLT看起来像这样:

<?xml version="1.0" encoding="iso-8859-1" ?> 
<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" /> 
    <xsl:strip-space elements="*" /> 

    <xsl:template match="/">
        <xsl:apply-templates select="address" /> 
    </xsl:template>

    <xsl:template match="address">
        <xsl:value-of select="@street" /> 
        <xsl:value-of select="@housenr" /> 
        <xsl:value-of select="@zipcode" /> 
        <xsl:value-of select="@city" /> 
        <xsl:value-of select="@country" /> 
    </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

我要转换的XML文档如下所示:

<address id="4" type="1" 
    typename="Postadres" 
    street="pak street" 
    housenr="420" 
    zipcode="42000" 
    city="Nill" 
    country="Lahore" 
    kix="" /> 
Run Code Online (Sandbox Code Playgroud)

这是我编写的代码:

public static string Transform(XmlDocument doc, XmlDocument stylesheet)
{
    var transform = new System.Xml.Xsl.XslCompiledTransform();
    XmlDocument domOutput = new XmlDocument();

    stylesheet.PreserveWhitespace = false;
    transform.Load(stylesheet);    // compiled stylesheet

    MemoryStream oStream …
Run Code Online (Sandbox Code Playgroud)

.net c# c#-4.0

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