问题列表 - 第15761页

为什么我的ConnectionsStringCollection比app.config中的connection-Strings部分有更多的条目?

在我的C#-WinForms-application(.Net 3.5,VS2008)中,我使用以下方法阅读App.Config:

Configuration myConfig = 
  ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
Run Code Online (Sandbox Code Playgroud)

App.config在connectionStrings-Section中包含两个连接字符串:

<connectionStrings>
    <add name="db1" connectionString="connection1"
     providerName="System.Data.SqlClient"/>
    <add name="db2" connectionString="connection2"
      providerName="System.Data.SqlClient" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)

(为了便于阅读,连接字符串被删除)

但是当我遍历ConnectionStringsCollection时,我发现它有三个条目而不是预期的两个条目.附加入口指向本地SqlExpress-Server上名为"aspnetdb.mdf"的数据库.我不记得在任何地方添加它,我在项目文件中找不到它作为文字值.使用调试器观察集合我发现我的连接字符串将app.config作为源.附加字符串作为源为null,所以我认为.net从某处汇总了它.

我怎样才能摆脱这个条目,或者我怎么能告诉配置管理器只使用app.config中的连接字符串?

c# app-config

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

浮点算法不能产生精确的结果

我需要在Java中进行一些浮点运算,如下面的代码所示:

public class TestMain {
    private static Map<Integer, Double> ccc = new HashMap<Integer, Double>() {
      { put(1, 0.01); put(2, 0.02); put(3, 0.05); put(4, 0.1); put(6, 0.2);
        put(10, 0.5); put(20, 1.0); put(30, 2.0); put(50, 5.0); put(100, 10.0);
      }
    };

    Double increment(Double i, boolean up) {
        Double inc = null;

        while (inc == null) {
            inc = ccc.get(i.intValue());

            if (up)
                --i;
            else
                ++i;
        }
        return inc;
    }

    public static void main(String[] args) {
        TestMain tt = new TestMain();

        for (double i = …
Run Code Online (Sandbox Code Playgroud)

java floating-point

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

禁用boto日志记录而不修改boto文件

我正在使用Boto库与AWS交谈.我想禁用日志记录.(或重定向到/ dev/null或其他文件).我找不到明显的方法来做到这一点.我尝试过这个,但这似乎没有帮助.

import boto
boto.set_file_logger('boto', 'logs/boto.log')
Run Code Online (Sandbox Code Playgroud)

这说明有可能,http://developer.amazonwebservices.com/connect/thread.jspa? messageID = 52727췷 ,但AFAIK的文档并没有说明如何.

python logging boto amazon-web-services

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

可以为多个WCF服务合同添加一个服务引用

我在一个WCF库中定义了多个服务契约,这些托管在Windows服务下托管.这些服务在Windows服务配置文件中公开如下:

<services>
  <service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
    name="ReportingComponentLibrary.TemplateService">
    <endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateService" bindingConfiguration="wsHttp" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateService/" />
      </baseAddresses>
    </host>
  </service>
  <service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
    name="ReportingComponentLibrary.TemplateReportService">
    <endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateReportService" bindingConfiguration="wsHttp" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateReportService/" />
      </baseAddresses>
    </host>
  </service>
</services>
Run Code Online (Sandbox Code Playgroud)

现在,当我在客户端应用程序中添加服务引用时,

是否可以为上述两个服务添加一个服务引用或

我需要为每个服务/服务合同分开参考.

更新:

以下是我的申请详情:

我有三个不同的项目:

  1. WCF服务库
  2. 用于托管WCF服务的Windows服务
  3. 客户端 - 测试控制台应用程序

现在,WCF服务库中的App.Config如下:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>     

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttp" maxReceivedMessageSize="50000000" maxBufferPoolSize="50000000" messageEncoding="Mtom">
          <readerQuotas maxDepth="500" maxStringContentLength="500000000" maxArrayLength="500000000"
          maxBytesPerRead="500000000" maxNameTableCharCount="500000000" />
        </binding> …
Run Code Online (Sandbox Code Playgroud)

wcf wcf-client

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

ASP.NET MVC - 存储库/服务/控制器

控制器是否需要直接调用存储库,还是应该始终通过服务层运行?还是有其他选择吗?

architecture asp.net-mvc

11
推荐指数
2
解决办法
1421
查看次数

数据源不支持服务器端数据分页

我的屏幕上有一个GridView,需要它才能允许分页.

标记:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
  AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
  <Columns>
    <asp:BoundField DataField="appID" HeaderText="appID" SortExpression="appID" />
  </Columns>
</asp:GridView>

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
  SelectMethod="GetBookingId" 
  TypeName="AppointmentRepository">
  <SelectParameters>
    <asp:Parameter Name="maximumRows" Type="Int32" />
    <asp:Parameter Name="startRowIndex" Type="Int32" />
  </SelectParameters>
</asp:ObjectDataSource>
Run Code Online (Sandbox Code Playgroud)

代码隐藏:

ObjectDataSource1.SelectParameters["maximumRows"].DefaultValue = "10";
ObjectDataSource1.SelectParameters["startRowIndex"].DefaultValue = "0";
Run Code Online (Sandbox Code Playgroud)

LINQ查询:

public IQueryable<tblAppointment> GetBookingId(int maximumRows, int startRowIndex)
{
    var result = (FROM a IN dc.tblAppointments
                  SELECT a).Skip(startRowIndex).Take(maximumRows);
}
Run Code Online (Sandbox Code Playgroud)

但是我收到此错误:

数据源不支持服务器端数据分页.

我究竟做错了什么?

c# linq asp.net sorting gridview

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

为什么ListView项目不会增长以包装其内容?

我有一个相当复杂的ListView,具有可变列表项高度.在某些情况下,我需要在列表项中显示一个附加视图,默认情况下隐藏它(View.GONE).通过启用它(View.VISIBLE),列表项的高度增加(或者至少应该增加).

问题:即使我将项目的根布局声明为wrap_content,并且将项目中的每个组件声明为fill_parent,我隐藏/显示应该更改项目高度的视图只是在底部而不是其父级切断(项目布局)在高度上增长以完全显示它.

是否有任何与ListView相关的问题以及我可能错过的项目布局和项目高度?

更多观察:

出于测试目的,我现在已经将列表项布局简化为仅包含根LinearLayout和ImageView.当我将LinearLayout高度设置为例如200dip并将ImageView设置为fill_parent时,我原本期望ImageView增长直到达到其父级设置的200dip限制.

但是,图像将只是与其位图资源一样高(就好像我已将其设置为wrap_content)并且整个列表项将具有相同的高度(即,就好像我已将其设置为wrap_content一样).

但是,如果我将图像高度设置为例如200dip,则列表项的高度将增加,项目布局也将增加.

换句话说,完全忽略列表项布局的layout_height,因此除了硬编码像素值之外,ImageView上的任何高度值也是如此.

android listview

56
推荐指数
4
解决办法
7万
查看次数

与Jython的BeautifulSoup

我只是尝试用Jython(2.5.1)运行BeautifulSoup(3.1.0.1),我惊讶地发现它比CPython慢​​多少.使用CPython 解析页面(http://www.fixprotocol.org/specifications/fields/5000-5999)只需不到一秒钟(确切地说是0.844秒).使用Jython需要564秒 - 几乎是700倍.

谁能证实这个结果?Jython运行速度比CPython慢​​700倍似乎不合理.也许我的设置有问题.

[编辑]这是我用来测试它的代码(当然我下载了上面提到的HTML文件):

import time
from BeautifulSoup import BeautifulSoup
data = open("fix-5000-5999.html").read()
start = time.time()
soup = BeautifulSoup(data)
print time.time() - start
Run Code Online (Sandbox Code Playgroud)

python jython beautifulsoup

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

ScrollViewer高度在内容溢出页面时自动滚动

好吧,这听起来很傻,但我不能让ScrollViewer正常工作.我需要做的是

  1. 让Silverlight页面使用HTML页面的100%宽度/高度

  2. 在Sliverlight页面的顶部有一个高度= 160px的控件,然后其余的(100% - 160px)是一个动态更改内容的ScrollViewer.

所以在HTML页面中我有:

 <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
Run Code Online (Sandbox Code Playgroud)

然后在XAML中:

 <Grid x:Name="LayoutRoot" Height="Auto">
        <StackPanel Orientation="Vertical" Height="Auto">        
            <App:ASilverlightControl  x:Name="Header" Height="160"/>
            <ScrollViewer Name="svw"  HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible"  Height="Auto" >
                <StackPanel Orientation="Vertical" x:Name="DynamicContentHere">
              </StackPanel>                                                
            </ScrollViewer>
       </StackPanel>    
   </Grid>
Run Code Online (Sandbox Code Playgroud)

现在,无论我尝试什么,ScrollViewer总是会扩展/收缩以包含StackPanel中的所有元素,即使这意味着在屏幕下溢出但没有垂直滚动条.

我能让它工作的唯一方法是将高度= 800设置为ScrollViewer.

silverlight xaml

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

打开的文件句柄太多

我正在开发一个庞大的遗留Java应用程序,有很多手写的东西,现在你可以让框架处理.

我现在面临的问题是我们的Solaris服务器上的文件句柄不足.我想知道跟踪打开文件句柄的最佳方法是什么?在哪里查看以及可能导致打开文件句柄用完的原因?

我不能在Solaris下调试应用程序,只能在我的Windows开发环境中调试.是否合理分析Windows下的打开文件句柄?

java io solaris file

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