小编adv*_*api的帖子

Visual Studio 2015项目缺少所有参考

从今天开始,属于具有20个项目的解决方案的WPF项目将我的所有引用设置为缺失

在此输入图像描述

我刚刚检查了MS建议和Stackoverflow上的其他答案,但都没有用......我试图从SVN重新获得解决方案,没有运气,其他同事没有遇到这个问题.我也尝试删除并重新添加引用(例如System.Xml).但没办法让它发挥作用......

有什么建议吗?谢谢

更新#1

这是csproj

 <ItemGroup>
<Reference Include="Catel.Core, Version=4.2.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\Catel.Core.4.2.0\lib\net40\Catel.Core.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Catel.Extensions.Controls, Version=4.2.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\Catel.Extensions.Controls.4.2.0\lib\net40\Catel.Extensions.Controls.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Catel.Extensions.FluentValidation, Version=4.2.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\Catel.Extensions.FluentValidation.4.2.0\lib\net40\Catel.Extensions.FluentValidation.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Catel.Fody.Attributes, Version=2.8.0.0, Culture=neutral, PublicKeyToken=1c8163524cbe02e6, processorArchitecture=MSIL">
  <HintPath>..\packages\Catel.Fody.2.8.0\lib\portable-net4+sl4+wp7+win8+wpa81+MonoAndroid14+MonoTouch40\Catel.Fody.Attributes.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Catel.MVVM, Version=4.2.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\Catel.MVVM.4.2.0\lib\net40\Catel.MVVM.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="MethodTimer, Version=1.15.7.0, Culture=neutral, PublicKeyToken=cb1364609f40a1dc, processorArchitecture=MSIL">
  <HintPath>..\packages\MethodTimer.Fody.1.15.7.0\Lib\portable-net4+sl5+wp8+win8+wpa81+MonoAndroid16+MonoTouch40\MethodTimer.dll</HintPath>
  <Private>False</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> …
Run Code Online (Sandbox Code Playgroud)

visual-studio visual-studio-2015

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

从Azure功能读取设置

我是Azure的新功能...我已经创建了一个新的计时器功能(将每30分钟触发一次),它必须对网址执行查询,然后在缓冲区上推送数据.

我弄完了

public static void Run(TimerInfo myTimer, TraceWriter log)
{


 var s = CloudConfigurationManager.GetSetting("url");

 log.Info(s);

}
Run Code Online (Sandbox Code Playgroud)

在我的功能设置中,我已经

在此输入图像描述

我究竟做错了什么?谢谢

azure azure-functions

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

如何使用Simple Injector注册命名实例

我正在开发一个WinForm应用程序,我正在使用Repository Pattern,我使用Servicestack OrmLite进行数据访问,使用Simple Injector进行IoC.

在我的program.cs我有2个注册2不同,OrmLiteConnectionFactory但目前我无法,因为我无法注册命名...与FunQ我可以这样做

container.Register<IDbConnectionFactory>("db1", _ => new OrmLiteConnectionFactory(
    ConfigurationManager.ConnectionStrings["db1"].ConnectionString, 
    SqlServerDialect.Provider));
container.Register<IDbConnectionFactory>("db2", _ => new OrmLiteConnectionFactory(
    ConfigurationManager.ConnectionStrings["db2"].ConnectionString, 
    SqlServerDialect.Provider));
Run Code Online (Sandbox Code Playgroud)

这是我的program.cs Bootstrap方法

private static void Bootstrap()
{
    // Create the container as usual.
    Container = new Container();

    string conn1 = ConfigurationManager.ConnectionStrings["dbconn1"].ConnectionString;
    string conn2 = ConfigurationManager.ConnectionStrings["dbconn2"].ConnectionString;

    OrmLiteConnectionFactory connectionFactory = new OrmLiteConnectionFactory(conn1,
        ServiceStack.OrmLite.SqlServer.SqlServerOrmLiteDialectProvider.Instance); 
    Container.RegisterSingle<OrmLiteConnectionFactory>(connectionFactory1);

    OrmLiteConnectionFactory connectionFactory2 = new OrmLiteConnectionFactory(conn2,
        ServiceStack.OrmLite.SqlServer.SqlServerOrmLiteDialectProvider.Instance); 

    // how do I register this one without a name?
    Container.RegisterSingle<OrmLiteConnectionFactory>(connectionFactory2);

    Container.Register<MainForm>();
}
Run Code Online (Sandbox Code Playgroud)

提前致谢

c# dependency-injection simple-injector

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

无法从控制台应用程序中的 appsettings.json 读取连接字符串

我正在使用控制台应用程序尝试 .NET core,但我一直坚持从 .NET Core 读取内容appsettings.json。这是我的代码:

{
    "ConnectionStrings": {
        "DataBaseConnectionString": "Server=xxxxxx"
        }
}
Run Code Online (Sandbox Code Playgroud)

...

var builder = new ConfigurationBuilder()
    //  .SetBasePath("")
    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
    .AddEnvironmentVariables();
configuration = builder.Build();

var xx = configuration.GetConnectionString("DataBaseConnectionString");
Run Code Online (Sandbox Code Playgroud)

我的值为 null xx,我做错了什么?谢谢

c# .net-core

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

尝试在 buildspec.yml 中添加 CloudFront 失效命令会引发 254 错误

我试图在构建完成后使 Cloudfront 缓存失效,并且在 Codebuild 中得到以下错误:[Container] 2022/05/16 15:46:11 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: aws cloudfront create-invalidation --distribution-id myid --paths '/*'. Reason: exit status 254

这是我的 BuildSpec 定义

version: 0.2
env:
  variables:
    APP_NAME: "managerui"
phases:
  install:
    runtime-versions:
      nodejs: 14.x
    commands:
      - echo install process started
      - cd src/UI/managerui/
      - ls 
      - npm install && npm install -g @angular/cli
  build:
    commands:
      - echo build process started now
      - ls 
      - ng build --configuration=production
  post_build:
    commands:
      - echo …
Run Code Online (Sandbox Code Playgroud)

amazon-cloudfront aws-codebuild

6
推荐指数
0
解决办法
2563
查看次数

在ASP.NET MVC中使用IISLocal(可在IISExpression上使用)时出现奇怪的异常

我正在开发使用KendoUI的ASP.NET MVC 5应用程序。如果我在IIS Express下运行项目,则一切正常...如果使用IIS Local,则在尝试加载视图时出现以下异常

System.Web.dll中发生类型为'System.Web.HttpException'的第一次机会异常

Additional information: Invalid file name for file monitoring: 'C:\svn\Projects\xxx\trunk\xxx\Views\Shared\EditorTemplates'. Common reasons      for failure include:

- The filename is not a valid Win32 file name.

- The filename is not an absolute path.

- The filename contains wildcard characters.

- The file specified is a directory.

- Access denied.
Run Code Online (Sandbox Code Playgroud)

我刚刚在Google上搜索过,有人建议在Debug-> Exception抛出异常复选框下禁用它,但是如果这样做,我将无法显示视图,因为输出只是JavaScript ...

有人找到解决此问题的方法了吗?谢谢

asp.net-mvc iis-7.5

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

设置简单注射器的记录器

我已经将我的应用程序设置Simple Injector为DI容器,我已经注册了所有存储库/服务,我正在寻找最新的步骤:Injector在自己的业务中记录Simple 写入的输出.

现在我不是在谈论如何注册Logger(在我使用的特定情况下log4net,但这适用于所有日志框架,但我如何告诉Simple Injector使用日志log4net?我没有看到任何.Log例如Unity

.net simple-injector

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

作为服务运行时,带有 Topshelf 的控制台应用程序抛出异常

我开发了一个控制台应用程序,它连接到 RabbitMQ 然后处理一些消息。我使用 Topshelf 允许作为服务执行而不会出现(在纸上)问题,但是当我将其作为服务运行时,出现以下异常

应用程序:XXX.exe 框架版本:v4.0.30319 描述:由于未处理的异常,进程被终止。异常信息: Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean) 处的 System.IO.FileNotFoundException 在 Microsoft.Extensions.Configuration.FileConfigurationProvider.Load() 处的 Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(System.Collections.Generic) .IList`1) 在 Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() 在 XXX.Program.Main(System.String[])

现在我认为它在某种程度上丢失了配置文件或某些 dll,但我将所有文件都放在 c:\services\myservice 上的文件夹中。如果我从命令提示符运行 exe,它可以完美运行。

我还尝试将身份设置为网络服务/管理员用户和类似的......但没有运气。我正在使用 TopShelf 4.0.4

有什么建议吗?谢谢

解决方案

这是我的错...

我不得不使用

var builder = new ConfigurationBuilder()
            .SetBasePath(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location))
            .AddJsonFile("appsettings.json")
            .AddJsonFile("appsettings.{environmentName}.json",true,true);
Run Code Online (Sandbox Code Playgroud)

代替

 var builder = new ConfigurationBuilder() 
 .SetBasePath(Directory.GetCurrentDirectory()) //(which is the default code present on MS site)
 .AddJsonFile("appsettings.json")
 .AddJsonFile("appsettings.{environmentName}.json",true,true);
Run Code Online (Sandbox Code Playgroud)

topshelf

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

使用 FluentValidation 检查字符串是否为大于零的数字

我已经开始FluentValidation在 WPF 项目中使用它,直到现在我以一种简单的方式使用它来检查字段是否已填充或少于 n 个字符。

现在我必须检查插入的值(这是一个字符串......该死的旧代码)是否大于 0。有没有一种简单的方法可以使用

RuleFor(x=>x.MyStringField).Somehow().GreaterThen(0) ?
Run Code Online (Sandbox Code Playgroud)

提前致谢

fluentvalidation

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

使用.NET Core应用程序进行Log4Net配置

我需要在新的.NET Core应用程序上使用log4net,该应用程序引用一些刚刚使用log4net编写的程序集。我进行了搜索,但是所有示例都将传递FileInfo给,log4net.Config.XmlConfigurator.Configure 但是使用最新版本要求输入第一个类型的参数ILoggerRepository repository

我应该通过什么?

我的代码是

   public static void Main(string[] args)
    {
        var builder = new ConfigurationBuilder()
            .SetBasePath(Directory.GetCurrentDirectory())
            .AddJsonFile("appsettings.json");

        var configuration = builder.Build();

        ContainerConfig.RegisterDependencies(configuration);
        MappingConfig.RegisterMapping();


        var fileInfo = new FileInfo(@"\config.log4net");

        log4net.Config.XmlConfigurator.Configure(null, fileInfo);



        var core = ContainerWrapper.Container.GetInstance<ICore>();

        core.StartAsync().Wait();

        Console.Write("Press a key to exit");
        Console.ReadLine();
    }
Run Code Online (Sandbox Code Playgroud)

但是null崩溃了

有什么建议么?

log4net log4net-configuration

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