小编Nor*_*Cat的帖子

使用Facebook ShareLink,标记<provider>属性权限在AndroidManifest.xml中具有无效字符"{"

虽然我删除了"{}"括号但仍然会出现.

<provider
        android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider{facebook_app_id}"
        android:exported="true" />
Run Code Online (Sandbox Code Playgroud)

facebook-android-sdk facebook-share

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

在QMainWindow中添加孩子

如何Widget在相等的部分添加两个子对象QMainWindow.

MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)

{   TreeArea *ta= new TreeArea(this);
    TreeArea *ta1= new TreeArea(this);
.
.
.
  TreeArea::TreeArea(QWidget *parent) :
 QWidget(parent)
{
.
.
.
Run Code Online (Sandbox Code Playgroud)

qt4 qmainwindow

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

安全地停止线程

我写多线程程序.

我想问一下TerminateThread和之间的区别是ExitThread什么?

WM_DESTROY收到时这是我的代码段:

void CleanAll()
{
    DWORD dwExit[MAX_THREAD];
    for(int i = 0; i < MAX_THREAD; i++)
    {
        GetExitCodeThread(hThread[i], &dwExit[i]);
        // I used ExitThread(dwExit[i]); previously
        TerminateThread(hThread[i], dwExit[i]);
        CloseHandle(hThread[i]);
    }
}
Run Code Online (Sandbox Code Playgroud)

ExitThread()之前使用过,但是我的程序在任务管理器中激活,所以我将其更改为,TerminateThread()并且我的程序已从任务管理器中删除.

任何提前解释都非常感谢.

c++ winapi multithreading

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

View-First-MVVM中的UserControls和viewmodels

我被迫在WPF应用程序中使用View First MVVM,我很难看到如何使它优雅地工作.

问题的根源在于嵌套UserControls.在MVVM架构中,每个都UserControl需要将其视图模型分配给它DataContext,这使得绑定表达式保持简单,而且这也是WPF实例化通过a生成的任何视图的方式DataTemplate.

但是,如果子项UserControl具有父项需要绑定到其自己的viewmodel的依赖项属性,则子项UserControl将其DataContext设置为其自己的viewmodel这一事实意味着父XAML文件中的"隐式路径"绑定将解析为子视图模型父母的.

要解决这个UserControl问题,应用程序中每个父项的每个父项都需要默认使用显式命名绑定(这是详细的,丑陋的和错误的),或者必须知道特定控件是否将其DataContext设置为自己的viewmodel是否使用适当的绑定语法(同样是errorprone,并且是对基本封装的重大违反).

经过几天的研究,我没有遇到过这个问题的一半解决方案.我遇到的最接近解决方案的是将UserControl'sviewmodel 设置为UserControl(最顶层Grid或其他)的内部元素,这仍然会让您在尝试将UserControl自身的属性绑定到自己的viewmodel时遇到问题!(ElementName绑定在这种情况下不起作用,因为绑定将在指定元素之前声明,并且viewmodel分配给它DataContext).

我怀疑没有其他人遇到这个问题的原因是他们要么使用viewmodel第一个没有这个问题的MVVM,要么他们使用视图第一个MVVM和一个依赖注入实现来解决这个问题.

有没有人为此提供干净的解决方案?

更新:

请求的示例代码.

<!-- MainWindow.xaml -->
<Window x:Class="UiInteraction.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:UiInteraction"
        Title="MainWindow" Height="350" Width="525"
        x:Name="_this">

    <Window.DataContext>
        <local:MainWindowVm/>
    </Window.DataContext>

    <StackPanel>
        <local:UserControl6 Text="{Binding MainWindowVmString1}"/>  
    </StackPanel>

</Window>
Run Code Online (Sandbox Code Playgroud)
namespace UiInteraction
{
    // MainWindow viewmodel.
    class MainWindowVm
    {
        public string MainWindowVmString1
        {
            get { return "MainWindowVm.String1"; …
Run Code Online (Sandbox Code Playgroud)

wpf xaml binding mvvm

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

动态获取本地化字符串WP8 c#

如何在Windows Phone 8中动态获取本地化文本?我发现,如果我想要一个文本,我可以做到这一点:

AppResources.ERR_VERSION_NOT_SUPPORTED
Run Code Online (Sandbox Code Playgroud)

但我们假设我从服务器获取了我的关键字.我只收回字符串

ERR_VERSION_NOT_SUPPORTED
Run Code Online (Sandbox Code Playgroud)

现在我想从中获取正确的文字AppResources.

我尝试过以下方法:

string methodName = "ERR_VERSION_NOT_SUPPORTED";
AppResources res = new AppResources();
//Get the method information using the method info class
MethodInfo mi = res.GetType().GetMethod(methodName);

//Invoke the method
// (null- no parameter for the method call
// or you can pass the array of parameters...)
string message = (string)mi.Invoke(res, null);
Run Code Online (Sandbox Code Playgroud)

问题是在这个例子中MethodInfomi是null ...

谁有想法?

编辑:

谢谢大家的快速回复.事实上我对c#很新,Properties因为getter和setter语法,我总是混淆.

AppResources看起来像这样:

/// <summary>
///   A strongly-typed resource class, for looking up localized …
Run Code Online (Sandbox Code Playgroud)

c# windows-phone-8

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

urllib模块错误!AttributeError:'module'对象没有属性'request'

我当前正在使用python中的'urllib'模块,并尝试使用它来提取网站的源代码:

import urllib
temp = urllib.request.urlopen('https://www.quora.com/#')
Run Code Online (Sandbox Code Playgroud)

但是,我收到以下错误:

回溯(最近一次调用最后一次):文件"",第1行,在temp = urllib.request.urlopen(' https://www.quora.com/# ')中AttributeError:'module'对象没有属性'request'

顺便说一句,我正在使用Python 2.7.5.

python python-2.7

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

Maven exec插件ClassNotFoundException

我正在使用Maven exec插件从命令行运行java应用程序,命令为mvn exec:java.我已经在pom.xml中指定了主类以及相关的依赖项.

<groupId>com.example.MyApp</groupId>
<artifactId>MyApp</artifactId>
<version>1.0.0</version>
<build>
  <plugins>
     <plugin>
       <groupId>org.codehaus.mojo</groupId>
       <artifactId>exec-maven-plugin</artifactId>
       <version>1.2.1</version>
       <executions>
         <execution>
           <goals>
             <goal>java</goal>
          </goals>
         </execution>
       </executions>
       <configuration>
          <mainClass>com.example.myclass</mainClass>
          <arguments>
            <argument>configFile</argument>
            <argument>properties</argument>
          </arguments>
       </configuration>
     </plugin>
Run Code Online (Sandbox Code Playgroud)

我还指定了一些依赖...

<dependencies>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
    <type>jar</type>
</dependency>
<dependency>
    <groupId>com.example.MyLibrary</groupId>
    <artifactId>MyLibrary</artifactId>
    <version>1.0.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

MyApp程序读取一个配置文件,该文件作为命令行参数传入.配置文件包含位于的类的名称MyLibrary.所以这个类可能com.mypackage.driver.MyClass位于上面列出MyLibraryMyAppjar 的依赖项中.但是,当我尝试运行时,我得到一个ClassNotFoundException......

更新----我正在使用系统类加载器来加载在MyApp程序命令行中传入的类

ClassLoader loader = ClassLoader.getSystemClassLoader();
Run Code Online (Sandbox Code Playgroud)

我认为这是导致问题,因为它正在寻找默认类路径上不包含依赖项的类.

我在这里做错了什么提示?

java maven

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

Sonar Cobertura插件找不到coverage.xml文件

我有一个多模块Maven项目Jenkins1.545.I正在使用Sonarqube的版本4.2.I已安装cobertura插件版本1.6.1,并java在插件版本2.2.1 Sonarqube.我已经成功地生成coverage.xml文件的位置- /target/site/cobertura/coverage.xml使用maven命令-每个模块"cobertura:cobertura -Dcobertura.report.format=xml" 对于声纳,我已经设置了maven构建选项sonar:sonar,如下所示:

sonar.dynamicAnalysis=reuseReports
sonar.junit.reportsPath=target/site
sonar.java.coveragePlugin=cobertura
sonar.cobertura.reportPath=/target/site/cobertura/coverage.xml
Run Code Online (Sandbox Code Playgroud)

我能看到coverage.xml的文件,当我浏览我的项目的工作区中Jenkins,但该插件口口声声说,它无法找到它.我得到的jenkins-控制台输出以下消息

Execute Findbugs 2.0.3 done: 48446 ms
Sensor FindbugsSensor done: 48800 ms
Sensor CoberturaSensor...
Cobertura report not found at /target/site/cobertura/coverage.xml
Sensor CoberturaSensor done: 4 ms
Sensor CpdSensor...
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏.谢谢.

java cobertura maven jenkins

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

如何检查产品有自定义选项?

我正在尝试检查产品是否在代码中有自定义选项(我的代码运行sales_order_place_after事件).我尝试下面的代码,但它没有返回任何东西. $product->hasCustomOptions()$product->hasOptions()

请让我知道我错过了什么.

magento-1.8

7
推荐指数
2
解决办法
6796
查看次数

mqtt例外太多正在发表的文章(32202)

我正在使用paho mqttv3 java客户端通过创建线程来同时发布大约2000个连接的消息.

一段时间后,它开始给MqttException是folows:

reason----- 32202
msg--------Too many publishes in progress
cause------ null
Run Code Online (Sandbox Code Playgroud)

虽然我已经设置了Qos 1.

谁知道为什么我会得到这样的例外?

提前致谢.

java mqtt paho

7
推荐指数
2
解决办法
6122
查看次数