小编Mas*_*aus的帖子

将.NET Framework版本的应用程序池更改为3.5?

我在Web服务器(Server 2008 Enterprise)上安装了.NET Framework 3.5 SP1,因此运行IIS 7.0.

我想更改现有站点使用的.NET Framework版本.因此,我右键单击相应的应用程序池并选择"编辑应用程序池"..NET Framework下拉列表不包含框架3.5的显式条目,但仅包括2.0.50727.

这只是因为3.5版核心RTL的版本仍然是2.0?或者我是否需要做一些额外的事情才能让IIS看到版本3.5?(尝试重启IIS).

iis-7 application-pool .net-3.5

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

使用StaticResources测试WPF窗口

我有一个简单的Window,它引用了App.xaml中的StaticResource.

App.xaml资源定义:

<!-- Standard Text Box Style -->
<Style x:Key="textBoxStyleStd" TargetType="{x:Type TextBox}">
    <Setter Property="FontSize" Value="14" />
</Style>
Run Code Online (Sandbox Code Playgroud)

使用资源的窗口组件:

<TextBlock Grid.Column="1" Grid.Row="0" Name="stationIdTitle"
           Style="{StaticResource textBlockStyleStd}"
           VerticalAlignment="Center" HorizontalAlignment="Center"
           Text="{LocText Key=Title, Dict={StaticResource Dictionary},
               Assembly={StaticResource Assembly}}"/>
Run Code Online (Sandbox Code Playgroud)

在尝试对此窗口进行单元测试时,我收到错误:

System.Windows.Markup.XamlParseException:找不到名为"{textBlockStyleStd}"的资源.资源名称区分大小写.标记文件'Zpg; component/guicomponenets/screens/enteredindidscreen.xaml'中对象'stationIdTitle'出错'第23行位置71.

有没有办法解决?我的单元测试代码是:

[Test]
public void TestEnterKeyPressedNoText()
{
    IPickingBusinessObject pickingBusinessObject = mock.StrictMock<IPickingBusinessObject>();

    EnterStationIdScreen objectUnderTest = new EnterStationIdScreen(pickingBusinessObject);

    Assert.AreEqual(Visibility.Visible, objectUnderTest.stationIdError.Visibility);

    Assert.AreEqual("werwe", "oksdf");

    Replay();

    objectUnderTest.EnterKeyPressed();

    Verify();
}
Run Code Online (Sandbox Code Playgroud)

wpf unit-testing

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

无法将事件处理程序附加到Style中的上下文菜单项

我试图修改默认ContextMenuXamNumericEditorXamDataGrid可编辑单元.

这是我的XAML代码:

<igDP:XamDataGrid.Resources>
  <Style TargetType="{x:Type editors:XamNumericEditor}">
    <Setter Property="ContextMenu">
      <Setter.Value>
        <ContextMenu>
          <ContextMenu.Items>
            <MenuItem Header="Select All"
                      Command="SelectAll">
              <MenuItem.Icon>
                <Image Source="..\icons\table_select_all.png"/>
              </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="Accept for column"
                      Click="MenuItem_Click">
            </MenuItem>
          </ContextMenu.Items>
        </ContextMenu>
      </Setter.Value>
    </Setter>
  </Style>
</igDP:XamDataGrid.Resources>
Run Code Online (Sandbox Code Playgroud)

代码隐藏文件包含此MenuItem的事件hadler:

private void MenuItem_Click(object sender, RoutedEventArgs e)
{
//...
}
Run Code Online (Sandbox Code Playgroud)

但是当我启动它时,我捕获一个带有消息的异常: 无法将类型为'System.Windows.Controls.MenuItem'的对象强制转换为'System.Windows.Controls.ContextMenu'.

你能帮帮我吗?谢谢.

wpf xaml infragistics styles event-handling

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

"使用/ main编译以指定包含入口点的类型."

根据下面的代码,我收到以下消息.我很确定"为什么"我得到它,我只是不知道如何重新排列代码来移动/删除/替换其中一个错误导致语句.

"使用/ main编译以指定包含入口点的类型."

"static void Main(string [] args)"下面有一堆代码,我从 http://support.microsoft.com/kb/816112 得到的目的是为了从自动增量获取ID,所以当其余代码填充Access数据库时,我可以自动增加它.任何帮助表示赞赏.我们也欢迎使用更简单的代码获得结果的建议!

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        OleDbConnection vcon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;data source=C:\Hazardous Materials\KinneyDatabase.accdb");

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            vcon.Open();

            try
            {
                StreamReader sr = new StreamReader(@"C:\Hazardous Materials\cities.txt");
                string line = sr.ReadLine();

                StreamReader sr2 = new StreamReader(@"C:\Hazardous Materials\drugs.txt");
                string line2 = sr2.ReadLine();

                StreamReader sr3 = new StreamReader(@"C:\Hazardous Materials\strengths.txt");
                string line3 = sr3.ReadLine();

                while (line != null)
                {
                    comboBox1.Items.Add(line); …
Run Code Online (Sandbox Code Playgroud)

c# ms-access auto-increment

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

为什么我的WPF单选按钮与中心垂直对齐?

我有一个WPF项目,我正在尝试使用单选按钮来确定TextBox要使用的输入.但是,当我运行它时,单选按钮本身与容器的顶部对齐,我找不到任何影响它的对齐属性.这种行为有望吗?我一直在寻找答案,但似乎一切都在询问如何垂直对齐单选按钮.我的假设是它与我如何嵌套在其他控件中有关,但我如何才能使其工作而不会改变太多?

这是与单选按钮相关的xaml:

<DockPanel Grid.Column="1" Margin="5,0,0,0">
  <RadioButton HorizontalContentAlignment="Stretch" DockPanel.Dock="Top" IsChecked="True">
    <xctk:TimePicker Name="TimePickerBox" Margin="0" Format="LongTime"
                     VerticalAlignment="Center"/>
  </RadioButton>
  <RadioButton Margin="0,5,0,0" DockPanel.Dock="Top">
    <StackPanel Orientation="Horizontal">
      <TextBox Name="Hours" Width="30" VerticalAlignment="Center">0</TextBox>
      <Label>Hours</Label>
      <TextBox Name="Minutes" Width="30" VerticalAlignment="Center">0</TextBox>
      <Label>Minutes</Label>
      <TextBox Name="Seconds" Width="30" VerticalAlignment="Center">0</TextBox>
      <Label>Seconds</Label>
    </StackPanel>
  </RadioButton>
// ...
Run Code Online (Sandbox Code Playgroud)

这就是它的样子:

单选按钮对齐

如何让单选按钮垂直居中?

c# wpf

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

获取事务在不同的线程异常中回滚

因此,我在 Wildfly 10 应用程序服务器中配置了 2 个 xa-datsources,并且我使用的是 Hibernate ORM 5.2.9。数据库是 Postgres 9.6

在我的应用程序中,我有一个 EJB,它有 2 个嵌套的 for 循环,我必须在嵌套循环的每次迭代中从表中读取数据。但过了一段时间我得到这个例外

javax.ejb.EJBTransactionRolledbackException:org.hibernate.HibernateException:事务在不同的线程中回滚!

我不明白为什么会这样。我有一个小的概念验证应用程序,它使用 JDBC 连接到数据库,一切正常。

编辑 这是我提到的异常被抛出后的堆栈跟踪:

12:39:07,319 WARN [com.arjuna.ats.arjuna](默认任务 7)ARJUNA012077:中止调用已中止的原子操作 0:ffffac280184:2edc54df:598adfb2:27f 12:320s7ERROR as.ejb3.invocation](默认任务 7)WFLYEJB0034:EJB 调用在组件 ejb/calculationResource 上失败,方法 public void com.actuariado.smartsolve.services.api.calculation.CalculationResource.calculateFinancial(org.jboss.resteasy.plugins. provider.multipart.MultipartFormDataInput) 抛出 com.actuariado.smartsolve.exceptions.AppException: javax.ejb.EJBTransactionRolledbackException: Transaction 在 org.jboss.as.ejb3.tx.CMTTxInterceptor.handleEndTransactionException(CMTTxInterceptor.java:137) 回滚jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:117) 在 org。jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:279) at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:327) at org.jboss.btxe.as. CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocation:javaContext4Interceptor)在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47) 在 org.jboss.invocation.Interceptor.Context (InterceptorContext.java:340) 在 org。jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptInterceptor processInvocation(StartupAwaitInterceptor.java:22) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67) 在 org.jboss.invocation.InterceptorContext。在 org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) …

java postgresql hibernate wildfly-10

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

如何使用setuptools安装在自定义目录中?

我有一个Python包,我需要安装在/usr/lib/python2.7/dist-packages或任何其他特定目录中.

每当我运行setup.py脚本时,它都会提供以下输出:

root@abc44:~/som_dir/plugins/abc$python setup.py install
running install
running bdist_egg
running egg_info
writing abcNewPlugin.egg-info/PKG-INFO
writing top-level names to abcNewPlugin.egg-info/top_level.txt
writing dependency_links to abcNewPlugin.egg-info/dependency_links.txt
writing entry points to abcNewPlugin.egg-info/entry_points.txt
reading manifest file 'abcNewPlugin.egg-info/SOURCES.txt'
writing manifest file 'abcNewPlugin.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
warning: install_lib: 'build/lib.linux-x86_64-2.7' does not exist -- no Python modules to install

creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/EGG-INFO
installing scripts to build/bdist.linux-x86_64/egg/EGG-INFO/scripts
running install_scripts
running build_scripts
creating build/bdist.linux-x86_64/egg/EGG-INFO/scripts
copying build/scripts-2.7/abc_plugin.py -> build/bdist.linux-x86_64/egg/EGG-INFO/scripts
changing mode of build/bdist.linux-x86_64/egg/EGG-INFO/scripts/abc_plugin.py …
Run Code Online (Sandbox Code Playgroud)

python setuptools

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

使用附加属性在XAML中动画化WPF元素?

我的动画由我的ViewModel中的属性触发.如果我设置TargetPropertyWidth,下面的代码实际上可以用于增长图像.

接下来,我想实际上下移动图像.为此,我Canvas在图像周围添加了一个组件,以便能够根据Canvas.Top属性进行动画处理.Canvas.Top图像上的设置将其移动到我想要的位置.

但是,如果我设置StoryBoard.TargetPropertyCanvas.Top,我会收到一个错误:

无法解析属性路径Canvas.Top中的所有属性引用.

<Style x:Key="LoadingImageAnimation" TargetType="{x:Type Image}">
  <Style.Triggers>
    <DataTrigger Binding="{Binding IsLoading}" Value="True">
      <DataTrigger.EnterActions>
        <BeginStoryboard>
          <Storyboard>
            <DoubleAnimation From="10" To="250" AutoReverse="True" Duration="0:0:30"
                             Storyboard.TargetProperty="Canvas.Top"/>
          </Storyboard>
        </BeginStoryboard>
      </DataTrigger.EnterActions>
    </DataTrigger>
  </Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud)

我的方法是完全关闭,还是只是找到附属物?

c# wpf animation xaml

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

PHP数学计算真的很慢

所以我写了一个脚本,你可以在其中输入一个数字,程序将找到该范围内的最高素数.问题是在PHP中,与我的JavaScript版本相比,这个计算速度非常慢,与我的JavaScript版本相比,这是完全相同但速度更快.

//Here Is the PHP code:
<form>
    <input type="text" name="input">
</form>

<?php
    $input = $_GET['input'];

    function Prime($num) 
    {
        if($num < 2)
            return false;

        for ($i = 2; $i < $num; $i++)
        {
            if($num % $i == 0)
                return false;
        }
        return true;
    } 

    for($i = $input; $i > 0; $i--)
    {
        if(Prime($i))
            echo $i;

        if(Prime($i))
            exit();
    }
} 
Run Code Online (Sandbox Code Playgroud)

这是JavaScript变体:

<html>
    <script>
        var input = prompt("Enter The Number");

        function Prime(num) {
            for (var i = 2; i < num; i++) { …
Run Code Online (Sandbox Code Playgroud)

php math

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

单元测试Parallel.Foreach C#

我一直在使用JustMock进行C#中的单元测试.我面临的问题是我无法断言内部调用的函数Parallel.Foreach.但是,可以断言内部完成的分配.

Parallel.ForEach(aList, entity =>
{
    //Can be asserted using  Assert(5,parameter.value) in the test
    parameter.value = 5;

    //Cannot be asserted, assertion fails Mock.Assert(parameter) in the test
    //is arranged using MustBeCalled
    parameter.call();   
})
Run Code Online (Sandbox Code Playgroud)

我在其他测试用例中也发现了同样的问题.这是JustMock的一些错误行为吗?

c# unit-testing justmock

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