小编Yuv*_*gar的帖子

WCF错误 - 已超出传入邮件的最大邮件大小限额(65536)

我的设置:

  • IIS客户端托管的ASP.NET客户端
  • 控制台应用程序中托管的WCF服务
  • 在管理员模式下运行Visual Studio.NET 2012

我试图从WCF服务返回2个List对象.当我只返回1个List对象时,我的设置工作很精细.但是当我返回2个List对象时,我收到错误:

已超出传入邮件的最大邮件大小限额(65536).要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性.

我知道这个问题在本网站和其他网站上也被多次询问过.我已尝试使用CONFIG FILE的各种组合在互联网上发布的几乎所有内容,但这对我来说仍然没有成功.

客户端配置:

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <httpRuntime maxRequestLength="1572864"/>
    </system.web>

    <system.serviceModel>
        <client>
            <endpoint name="basicHttpBinding"
                address="http://localhost:9502/HCDataService"
                binding="basicHttpBinding"
                bindingConfiguration="basicHttpBinding"                
                contract="HC.APP.Common.ServiceContract.IHCServiceContract"
                behaviorConfiguration="ServiceBehaviour">
            </endpoint>
        </client>

        <bindings>
            <basicHttpBinding>
                <binding name="basicHttpBinding" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
                    <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483646" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                </binding>
            </basicHttpBinding>
        </bindings>

        <behaviors>
            <endpointBehaviors>
                <behavior name="ServiceBehaviour">
                    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
                </behavior>
            </endpointBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

服务器配置:

<configuration>
    <system.serviceModel>
        <services>
            <service name="HC.APP.Server.Service.HCDataService" behaviorConfiguration="ServiceBehaviour">
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:9502/HCDataService"/>
                    </baseAddresses>
                </host>

                <endpoint name="basicHttpBinding"
                    address="http://localhost:9502/HCDataService"
                    binding="basicHttpBinding"
                    bindingConfiguration="basicHttpBinding"
                    contract="HC.APP.Common.ServiceContract.IHCServiceContract">
                </endpoint>
            </service> …
Run Code Online (Sandbox Code Playgroud)

c# wcf configuration-files

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

PDFsharp编辑pdf文件

环境 - PDFsharp Library,Visual Studio 2012和C#作为语言.

我在尝试着:

  1. 阅读Test1.pdf(宽度= 17英寸,高度 - 11英寸),1页
  2. 添加一些文字
  3. 将其另存为另一个文件(Test2.pdf)

我可以做以下所有事情.但是当我打开文件Test2.pdf时,页面的大小会减小到宽度= 11英寸,高度--11英寸.我使用的这些PDF文件是我从互联网上下载的产品规格表.我相信这只发生在某些类型的文件上,我不知道如何区分这些文件.

代码如下:

//File dimentions - Width = 17 inches, Height - 11 inches (Tabloid Format)
PdfDocument pdfDocument = PdfReader.Open(@"D:\Test1.pdf", PdfDocumentOpenMode.Modify);

PdfPage page = pdfDocument.Pages[0];
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
gfx.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center);

//When the file is saved dimentions change to - Width = 11 inches, Height - 11 inches
pdfDocument.Save(@"D:\Test2.pdf");
Run Code Online (Sandbox Code Playgroud)

我在这里上传了文件Test1.pdf

================================================== …

pdf pdfsharp c#-4.0

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

将COMPLEX存储过程转换为C#和ADO.Net

这不是SP是好还是坏的问题.或者在C#中编写SQL语句是好还是坏.

我们很快就开始研究一个典型的库存/计费管理系统的新项目.这将使用.Net和C#作为语言开发.数据库尚未最终确定.

在此应用程序中不允许使用存储过程,它将具有中到复杂的数据库操作.因此,我可以轻松地使用SP编写的逻辑,现在我将不得不使用C#和ADO.Net编写.

现在采取一个非常假的使用案例,客户已经选择了5项并准备好在柜台生成账单.... 这通常会有以下数据库操作:

  • 检查INVENTORY表以查看是否所有5个订单项都可用(数量足够).
  • 如果任何项目不可用 - 从账单中删除该项目并更新BILL表格
  • 将更新INVENTORY表的数量字段,并将使用已售出的项目扣除数量字段.
  • 警报/更新其他表是项目的阈值数量低于某一点.

现在看一下这种情况,可以在SP中轻松完成所有操作.这包含很多查询,IF条件,可能的循环等,看起来像SP的一个很好的竞争者.我想从专家那里得到的是:

  1. 是否有在C#和ADO.Net中编写此类代码的最佳实践.在C#中,我们通常可以使用ADO.Net重新创建相同的代码.但这是唯一的方式还是正确的方式?
  2. 我看过很多人说存储过程很糟糕...... 但是在考虑像这样的复杂场景时......你不觉得存储过程在这种情况下更适合.

c# ado.net stored-procedures

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