小编Wil*_*ler的帖子

C++:在混合使用C++/CLI和C++时获取c3859错误代码

按照C++中 Hans Passant的建议完成后 :在使用pstsdk时获取"错误C2065:'pst':未声明的标识符"?(工作),我的代码现在看起来像这样:

private:
    System::Void readPstFileButton_Click(System::Object^  sender, System::EventArgs^  e) {
         pstsdk::pst myfile(marshal_as<std::wstring>(fileNameTextBox->Text));
    }
Run Code Online (Sandbox Code Playgroud)

我现在得到以下错误:

错误C3859:超出PCH的虚拟内存范围; 请使用'-Zm111'或更高版本的命令行选项重新编译

错误C1076:编译器限制:达到内部堆限制; 使用/ Zm指定更高的限制

我绝对不希望这些发生,我也不知道如何解决它们.

c++ unmanaged c++-cli marshalling

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

代码合同或if声明?

我只是尝试使用代码契约,而且我发现if语句没有真正的优势.

考虑以下.

private static void BindClassesToInterfacesByConvention(string classesEndingWith
    , string interfacesEndingwith) {
    Contract.Requires<ArgumentNullexception>(
        string.IsNullOrWhiteSpace(classesEndingWith)
        , "classesEndingWith");

    Contract.Requires<ArgumentNullException>(
        string.IsNullOrWhitespace(interfacesEndingWith)
        , "interfacesendingWith");

    ...
}
Run Code Online (Sandbox Code Playgroud)

我发现它比简单地使用一个更令人困惑 if statement

private static void BindClassesToInterfacesByConvention(string classesEndingWith
    , string interfacesEndingwith) {
    if (string.IsNullOrWhiteSpace(classesEndingWith)) 
        throw new ArgumentNullException("classesEndingWith");

    if (string.IsNullOrWhitespace(interfacesEndingWith))
        throw new ArgumentNullException("interfacesendingWith");

    ...
}
Run Code Online (Sandbox Code Playgroud)

代码合同应该在编译时警告我合同违反.因此,当我写下以下内容时,我期待得到错误或警告.

BindClassesToInterfacesByConvention(null, null);
Run Code Online (Sandbox Code Playgroud)

没有任何事情发生,一切编译得很好,既没有出现错误也没有出现警告信息.

在这种情况下,我认为最好继续使用it statement.或者也许是不公平的使用Code Contracts

c# if-statement code-contracts

11
推荐指数
1
解决办法
1372
查看次数

C#中的接口继承

我正在尝试在编写应用程序时遇到的问题超出了(对我来说)很大的问题.请看这个(我会尽量缩短代码):

我有root接口叫IRepository<T>.接下来,IBookRepository : IRepository<Book> Next,实现它的具体类:BookRepository : IBookRepository

在我声明的RepositoryManager类中 private IRepository<IRepoItem> currentRepo;

IRepoItem 是一个由Book类实现的接口.

现在,当我尝试做这样的事情时:

currentRepo = new BookRepository();
Run Code Online (Sandbox Code Playgroud)

VisualStudio提供错误消息:

无法将类型'BookRepository'隐式转换为'IRepository'.存在显式转换(您是否错过了演员?)

我尝试显式转换,但抛出运行时异常...

我知道(几乎可以肯定)它是一种叫做协方差的东西,这可能(可能)在.Net 4.0中解决了.不幸的是我正在使用框架版本3.5编写,我无法改变它.请给我一些建议怎么做 - 如何超支这个问题?我想从RepoFactory获得currentRepo,它会产生几种存储库,具体取决于用户的需求.我不知道这里是否允许链接,但我在http://olgatherer.wordpress.com/上写了一些博客,我在其中描述了应用程序的创建.我的英语不好,但我希望能够理解我.提前谢谢你的回答.

最好的问候,skrzeczowas

c# oop interface covariance

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

Visual Studio错误:已添加具有相同键的项目

当我尝试在窗体设计器中更改Windows窗体上的控件的默认图像时(无论在哪个控件上),我收到此错误:

错误消息:已添加具有相同键的项目

我试图删除并重新创建Resources.resx文件..我保证只有1个具有这些密钥的resx文件存在..(实际上这是我唯一的资源文件)但它仍然不起作用.

我有som字符串和一些图像.就这样.

任何的想法?

resources visual-studio winforms

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

SQL错误:ORA-02291:完整性约束

我正在创建一个试图从外键访问值的数据库.我创建了两个下面的表

CREATE TABLE Component(
    ComponentID varchar2(9) PRIMARY KEY
    , TypeID varchar2(9) REFERENCES TypeComponent(TypeComponentID)
)

INSERT INTO Component VALUES(192359823,785404309)
INSERT INTO Component VALUES(192359347,785404574)
INSERT INTO Component VALUES(192359467,785404769)
INSERT INTO Component VALUES(192359845,785404867)
INSERT INTO Component VALUES(192359303,785404201)
INSERT INTO Component VALUES(192359942,785404675)


CREATE TABLE TypeComponent (
    TypeComponentID varchar2(9) PRIMARY KEY
    , Type_Description varchar2(30) CONSTRAINT Type_Description 
        CHECK(Type_Description IN('Strap', 'Buckle', 'Stud')) NOT NULL
)

INSERT INTO TypeComponent VALUES(785404309, 'Strap')
INSERT INTO TypeComponent VALUES(785404574, 'Stud')
INSERT INTO TypeComponent VALUES(785404769, 'Buckle')
INSERT INTO TypeComponent VALUES(785404867, 'Strap')
INSERT INTO …
Run Code Online (Sandbox Code Playgroud)

sql oracle ora-02291

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

当行依赖外键值时如何使用BULK INSERT?

我的问题与我在ServerFault上提出的问题有关.

基于此,我考虑过使用BULK INSERT.我现在明白,我必须为每个要保存到数据库中的实体准备一个文件.无论如何,我仍然想知道这个BULK INSERT是否会避免我的系统上的内存问题,如ServerFault上引用的问题所述.

至于Streets表,它很简单!我只有两个城市和五个部门需要关心作为外键.但那么,地址怎么样?Addresses表的结构如下:

AddressId int not null identity(1,1) primary key
StreetNumber int null
NumberSuffix_Value int not null DEFAULT 0
StreetId int null references Streets (StreetId)
CityId int not null references Cities (CityId)
SectorId int null references Sectors (SectorId)
Run Code Online (Sandbox Code Playgroud)

正如我在ServerFault上所说,我有大约35,000个地址要插入.我要记住所有的ID吗?= P

然后,我现在让公民人员插入与地址有关联的人.

PersonId int not null indentity(1,1) primary key
Surname nvarchar not null
FirstName nvarchar not null
IsActive bit
AddressId int null references Addresses (AddressId)
Run Code Online (Sandbox Code Playgroud)

我唯一能想到的就是强制将ID强制为静态值,但是,我失去了以前使用INSERT..SELECTstategy的方法所带来的灵活性.

那么我的选择是什么?

  1. 我强制ID始终是相同的,然后我必须SET IDENTITY_INSERT ON这样我可以强制将值放入表中,这样我总是对每个行都有相同的ID,就像这里 …

t-sql memory bulkinsert foreign-keys

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

PdfSharp - 在Acrobat中打开文档时,PDF页面设置错误

我编写了一段使用PdfSharp库的代码.PdfSharp.Pdf.PdfDocument的实例已按预期保存到磁盘.显示正确的内容,但显示在错误的页面设置上.

PdfSharp的默认页面设置为:

  1. PdfSharp.PageSizes.A4
  2. PdfSharp.PageOrientation.Portrait

我的问题是这些设置似乎覆盖了所需的设置.

我创建了PdfDocument类的实例,并将一个新的PdfPage类实例添加到其Pages集合属性中.然后,我像这样设置页面:

  1. PdfDocument.Pages [0] .Size = PdfSharp.PageSizes.Letter
  2. PdfDocument.Pages [0] .Orientation = PdfSharp.PageOrientation.Landscape
  3. 我绘制字符串(这很好)
  4. 我将文档保存到磁盘(这很好)
  5. Process.Start(myPdfFilename) - 然后Acrobat Reader打开我的文档.
  6. 页面设置为A4 - 纵向...

我很困惑.我知道Acrobat Reader中有一个选项,允许用户在不改变文本方向的情况下更改页面方向.无论我是否选中此选项,仍然会出现错误的设置.

有人有想法吗?谢谢!

c# pdfsharp

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

将属性限制为类或属性是否可行?

我有两个自定义属性定义如下:

internal class SchemaAttribute : Attribute {
    internal SchemaAttribute(string schema) {
        Schema = schema;
    }

    internal string Schema { get; private set; }
}

internal class AttributeAttribute : Attribute {
    internal AttributeAttribute(string attribute) {
        Attribute = attribute;
    }

    internal string Attribute { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)

我想将SchemaAttribute限制为类,将AttributeAttribute限制为属性.

这可行吗?

c# vb.net attributes custom-attributes .net-2.0

8
推荐指数
1
解决办法
1488
查看次数

SQL更改字段选择中的排序规则

我正在尝试进行以下选择:

select * from urlpath where substring(urlpathpath, 3, len(urlpathpath))
not in (select accessuserpassword from accessuser where accessuserparentid = 257)
Run Code Online (Sandbox Code Playgroud)

我收到错误:

Cannot resolve the collation conflict between 
"SQL_Latin1_General_CP1_CI_AI" and 
"SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
Run Code Online (Sandbox Code Playgroud)

有谁知道我如何作为整理,或允许我匹配这种情况的东西?

感谢名单

sql-server

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

是否可以在ADO.NET Command.CommandText属性中包含多个SQL指令?

摘要

我正在编写一个应用程序,我将SQL指令放在项目的参数中.

在代码中,我得到了我的查询的值,它返回查询本身.比如说我的SQL查询是这样的:

select col1, col2, col3 from my_table
Run Code Online (Sandbox Code Playgroud)

此外,col1,col2col3从不同的表,并迁移为外键MY_TABLE.因此,当涉及到插入时,我必须执行多个INSERT语句以从这些上述列的其他表中获取值.我们说如下:

BEGIN TRANSACTION

insert into first_table (col_x, col_y) values ('col_x', 'col_y')
insert into second_table (col_z, col_a) values ('col_z', 'col_a')
insert into third_table (col_b, col_c) values ('col_b', 'col_c')
Run Code Online (Sandbox Code Playgroud)

最后:

insert into my_table (col1, col2, col3, col_v) values (@col1, @col2, @col3, 'col_v')

COMMIT
Run Code Online (Sandbox Code Playgroud)

认为这些col1,col2,col3列于表自动递增的整数first,secondthird.

问题

  1. 我可以将一个复杂的SQL语句写入IDbCommand.CommandText属性,而每条指令都用分号(;)分隔吗?

  2. 是否可以在BEGIN TRANSACTION...COMMIT/ROLLBACKCommandText属性中包含?

  3. 简而言之,我可以写这样的东西吗? …

sql t-sql ado.net command .net-3.5

8
推荐指数
1
解决办法
9351
查看次数