小编ouf*_*lak的帖子

以下方法之间的调用不明确:Identical.NameSpace.InitializeComponent()和Identical.NameSpace.InitializeComponent()

好吧,我怀疑这可能是Visual Studio的事情,但必须有一些原因.我从默认项目列表中创建了一个ListBox(右键单击项目,或项目中的文件夹 - >添加 - >新项目 - > Xaml ListBox).我立刻得到了一条带有错误的红色波浪线:

"错误2以下方法或属性之间的调用不明确:'Identical.NameSpace.ListBox1.InitializeComponent()'和'Identical.NameSpace.ListBox1.InitializeComponent()'C:\ Documents and Settings\ouflak\My Documents\Visual Studio 2010\Projects\Identical\NameSpace\ListBox1.xaml.cs 27"

所有相关代码都是自动生成的,并且出错的原因是两个自动生成的文件之间存在冲突:ListBox1.g.cs和ListBox1.designer.cs,其中public void两者都声明了InitializeComponent().当然,在这种情况下代码无法编译.只需删除ListBox1.designer.cs就行了,我想继续前进.但我的问题是:为什么此代码会自动生成此错误?我希望自动生成的任何东西都能够构建和编译,而无需触摸项目或任何代码.对于您可以添加的几乎所有其他toobox项目,情况就是如此.那么为什么要使用内置错误生成此代码呢?我们应该找到一些方法来完成这项工作吗?这段代码仅仅是一个建议,由IDE用户/开发人员来决定细节吗?

这是生成的代码:ListBox1.xaml:

< ?xml version="1.0" encoding="utf-8" ? > 
< ListBox
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:xc="http://ns.neurospeech.com/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    x:Class="Identical.NameSpace.ListBox1"
    >
    <sys:String>Item 1</sys:String>
    <sys:String>Item 2</sys:String>
    <sys:String>Item 3</sys:String>
< /ListBox>
Run Code Online (Sandbox Code Playgroud)

ListBox1.g.cs:

namespace Identical.Namespace
{
    /// <summary>
    /// ListBox1
    /// </summary>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
    public partial class ListBox1 : System.Windows.Controls.ListBox, System.Windows.Markup.IComponentConnector {

        private bool _contentLoaded;

        /// <summary>
        /// InitializeComponent
        /// </summary>
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        public void InitializeComponent() { …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml toolbox visual-studio

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

使用C#按创建日期降序获取目录中的文件列表

我希望使用C#获取按创建日期排序的文件夹中的文件列表.

我使用以下代码:

        if(Directory.Exists(folderpath))
        {
            DirectoryInfo dir=new DirectoryInfo (folderpath);
            FileInfo[] files = dir.GetFiles().OrderBy(p=>p.CreationTime).ToArray();
            foreach (FileInfo file in files)
            {
              ......
            }
        }
Run Code Online (Sandbox Code Playgroud)

这将给出创建时间的升序.我实际上想要在我的数组的第一个位置(降序)获取最近创建的文件.

c# file

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

在不增加执行时间的情况下多次调用返回DeferredResults的异步服务

我的应用程序应该有2个核心端点:push,pull for sending和fetching data.

拉操作应该异步工作并产生DeferredResult.当用户通过休息调用pull service时,会创建新的DefferedResult并将其存储到Map<Long, DefferedResult> results = new ConcurrentHashMap<>()等待新数据的位置或直到超时到期.

推送操作也会呼叫用户过度休息,此操作会检查此操作所推送的数据接收者的结果映射.当map包含收件人的结果时,这些数据被设置为他的结果,返回DefferedResult.

这是基本代码:

@Service
public class FooServiceImpl {
    Map<Long, DefferedResult> results = new ConcurrentHashMap<>();

    @Transactional
    @Override
    public DeferredResult<String> pull(Long userId) {
        // here is database call, String data = fooRepository.getNewData(); where I check if there are some new data in database, and if there are, just return it, if not add deferred result into collection to wait for it
        DeferredResult<String> newResult = new DeferredResult<>(5000L);
        results.putIfAbsent(userId, …
Run Code Online (Sandbox Code Playgroud)

java spring spring-transactions spring-boot spring-async

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

无法加载文件或程序集“Microsoft.Extensions.Configuration.Abstractions,版本=7.0.0.0”。该系统找不到指定的文件

我有一个针对.net6.0框架的项目。我想从 ef6.0.0 升级到 ef 7.0.0。在我的解决方案中,我有一个单独的 functionApps 项目。我收到一个错误“ Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.”。

由于我必须升级到 ef 7.0.0,因此所有依赖项都应为 7.0.0。根据此链接,无法在 Azure Functions 中加载文件或程序集“Microsoft.Extensions.Configuration.Abstractions,Version=5.0.0.0”,我无法降级版本。以下是功能应用程序错误屏幕截图。

函数应用错误

c# entity-framework-core azure-functions .net-6.0

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

字符串Equals()方法失败,即使C#中的两个字符串相同?

我想使用字符串类的Equals()方法比较C#中两个字符串是否相等.但即使两个字符串相同,我的条件检查也会失败.

我已经看到两个字符串相同,并在http://text-compare.com/网站上验证了这一点.我不知道这里有什么问题......

我的代码是:

protected string getInnerParaOnly(DocumentFormat.OpenXml.Wordprocessing.Paragraph currPara, string paraText)
        {
            string currInnerText = "";
            bool isChildRun = false;

        XmlDocument xDoc = new XmlDocument();
        xDoc.LoadXml(currPara.OuterXml);
        XmlNode newNode = xDoc.DocumentElement;

        string temp = currPara.OuterXml.ToString().Trim();

        XmlNodeList pNode = xDoc.GetElementsByTagName("w:p");
        for (int i = 0; i < pNode.Count; i++)
        {
            if (i == 0)
            {
                XmlNodeList childList = pNode[i].ChildNodes;
                foreach (XmlNode xNode in childList)
                {
                    if (xNode.Name == "w:r")
                    {
                        XmlNodeList childList1 = xNode.ChildNodes;
                        foreach (XmlNode xNode1 in childList1)
                        {
                            if (xNode1.Name …
Run Code Online (Sandbox Code Playgroud)

c#

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

为什么找不到导入命令?

我正在使用模块中的input函数fileinput来接受脚本pipesinput file这是最小脚本:

finput.py

import fileinput

with fileinput.input() as f:
    for line in f:
        print(line)
Run Code Online (Sandbox Code Playgroud)

使这个脚本可执行后,我运行ls | ./finput.py并获取unexpected error message

./finput.py: line 1: import: command not found
./finput.py: line 3: syntax error near unexpected token `('
./finput.py: line 3: `with fileinput.input() as f:'
Run Code Online (Sandbox Code Playgroud)

我找到的唯一修复是在#!/usr/bin/env/python3import语句之前添加的时候.

但是这个问题似乎只与fileinput模块有关.由于以下脚本运行良好,没有shebang:

fruit.py

import random

fruits = ["mango", "ananas", "apple"]
print(random.choice(fruits))
Run Code Online (Sandbox Code Playgroud)

现在我错过了什么?为什么不能import,因为该命令可以找到shebang不是必需finput.py

python shebang

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

地址或 ENS 名称无效

我不明白问题是什么。当我运行该应用程序时,我收到此错误:

Unhandled Runtime Error
Error: invalid address or ENS name (argument="name", value=5.050201689117535e+47, code=INVALID_ARGUMENT, version=contracts/5.5.0)
Run Code Online (Sandbox Code Playgroud)

我的代码如下:

import {ethers} from 'ethers'
import {useEffect, useState} from 'react'
import axios from 'axios'
import Web3Modal from 'web3modal'

import { nftaddress, nftmarketaddress } from '../config'

import NFT from '../artifacts/contracts/NFT.sol/NFT.json'
import Market from '../artifacts/contracts/Market.sol/Market.json'

export default function Home() {
  const [nfts, setNFts] = useState([])
  const [loadingState, setLoadingState] = useState('not-loaded')

  useEffect(()=> {
    loadNFTs()
  }, [])

  async function loadNFTs() {
    // what we want to load:
    // ***provider, tokenContract, …
Run Code Online (Sandbox Code Playgroud)

ethereum metamask nft ethers.js hardhat

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

错误:找不到模块'@angular/compiler-cli

执行ng s --open命令时出现以下错误:

找不到模块 '@angular/compiler-cli' 错误:在 Function.Module._resolveFilename (internal/modules/cjs/loader.js:655:15) 的 Function.Module 中找不到模块 '@angular/compiler-cli'。 _load (internal/modules/cjs/loader.js:580:25) at Module.require (internal/modules/cjs/loader.js:711:19) at require (internal/modules/cjs/helpers.js:14: 16)在对象。(G:\Front-End\angular\rapydly\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:12:24) at Module._compile (internal/modules/cjs/loader.js:805:30) at Object。 Module._extensions..js (internal/modules/cjs/loader.js:816:10) at Module.load (internal/modules/cjs/loader.js:672:32) at tryModuleLoad (internal/modules/cjs/loader .js:612:12) 在 Function.Module._load (internal/modules/cjs/loader.js:604:3) 在 Module.require (internal/modules/cjs/loader.js:711: 19) 在对象的 require (internal/modules/cjs/helpers.js:14:16)。(G:\Front-End\angular\rapydly\node_modules@ngtools\webpack\src\index.js:13:10) 在 Module._compile (internal/modules/cjs/loader.js:805:30) 在 Object。 Module._extensions..js (internal/modules/cjs/loader.js:816:10) at Module.load (internal/modules/cjs/loader.js:672:32) at tryModuleLoad (internal/modules/cjs/loader .js:612:12) at Function.Module._load (internal/modules/cjs/loader.js:604:3) at Module.require (internal/modules/cjs/loader.js:711:19) at require ( internal/modules/cjs/helpers.js:14:16) 在对象。(G:\Front-End\angular\rapydly\node_modules@angular-devkit\build-angular\src\angular-cli-files\models\webpack-configs\typescript.js:4:19) 在 Module._compile (internal /modules/cjs/loader.js:805:30) \Front-End\angular\rapydly\node_modules@ngtools\webpack\src\index.js:13:10) 在 Module._compile (internal/modules/cjs/loader.js:805:30) …

angular-cli angular

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

如何在Vuetify(版本&gt; = 2.0)中单击时突出显示v-data-table中的行?

我使用 av-data-table来管理电子邮件。用户可以单击一行,然后会出现一个包含电子邮件详细信息的弹出窗口。

我想要什么:
我希望在单击这些行后将行标记为“已读”(因此 css 粗体/非粗体)。

问题:
我已经在这里找到了一些示例(但仅适用于较旧的 Vuetify 版本):Vuetify - How to highlight row on click in v-data-table

这个例子(以及我发现的所有其他例子)使用扩展代码v-data-table- 例如:

<v-data-table :headers="headers" :items="desserts" class="elevation-1">
  <template v-slot:items="props">
    <tr @click="activerow(props.item)" :class="{'primary': props.item.id===selectedId}">
      <td>{{ props.item.name }}</td>
      <td class="text-xs-right">{{ props.item.calories }}</td>
      <td class="text-xs-right">{{ props.item.fat }}</td>
      <td class="text-xs-right">{{ props.item.carbs }}</td>
      <td class="text-xs-right">{{ props.item.protein }}</td>
      <td class="text-xs-right">{{ props.item.iron }}</td>
    </tr>
  </template>
</v-data-table>
Run Code Online (Sandbox Code Playgroud)

所以扩展代码是:

<template v-slot:items="props">
  <tr @click="activerow(props.item)" :class="{'primary': props.item.id===selectedId}">
    <td>{{ props.item.name }}</td>
    <td class="text-xs-right">{{ props.item.calories }}</td>
    <td class="text-xs-right">{{ props.item.fat }}</td> …
Run Code Online (Sandbox Code Playgroud)

javascript css vue.js vuetify.js

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

React Router v5:history.push() 更改地址栏,但不更改页面

如果在我的 React 应用程序中登录成功,我将尝试将用户重定向到新页面。重定向是从不是组件的 auth 服务调用的。为了访问组件外部的历史对象,我按照React Router FAQ中的示例进行操作。但是,当我致电 时history.push('/pageafterlogin'),页面不会更改,并且我仍保留在登录页面上(根据我的Switch预期最终会出现在该页404面上)。地址栏中的 URL 确实更改为/pageafterlogin登录页面,但页面未更改。控制台中没有出现任何错误,也没有任何其他信息表明我的代码不起作用。

我怎样才能history.push()更改用户所在的页面?

// /src/history.js
import { createBrowserHistory } from 'history';
export default createBrowserHistory();

// /src/App.js
...
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import history from './history';

function App() {
    return (
        <Router history={history}>
            <Switch>
                <Route path="/" exact component={HomePage} />
                <Route path="/login" exact render={() => <FormWrapper><LoginForm /></FormWrapper>} />
                <Route render={() => <h1>404: not found</h1>} />
            </Switch> …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

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