小编Ale*_*eau的帖子

将app.config加载到AppDomain中

我无法将App.Config文件加载到App域中.

我正在使用

[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $config_path)
Run Code Online (Sandbox Code Playgroud)

来自Powershell使用App.config调用.NET程序集,但仍未加载App.Config文件.

我也尝试重置缓存,如使用CurrentDomain.SetData("APP_CONFIG_FILE")中所述,在PowerShell ISE中不起作用.

这是我的测试脚本:

$configFile = "{ActualPhysicalPath}\App.Config"
gc $configFile

Add-Type -AssemblyName System.Configuration
[Configuration.ConfigurationManager].GetField("s_initState", "NonPublic, Static").SetValue($null, 0)
[Configuration.ConfigurationManager].GetField("s_configSystem", "NonPublic, Static").SetValue($null, $null)
([Configuration.ConfigurationManager].Assembly.GetTypes() | where {$_.FullName -eq "System.Configuration.ClientConfigPaths"})[0].GetField("s_current", "NonPublic, Static").SetValue($null, $null)

[Configuration.ConfigurationManager]::ConnectionStrings[0].Name
[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $null)
[Configuration.ConfigurationManager]::ConnectionStrings[0].Name
[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $configFile)
[Configuration.ConfigurationManager]::ConnectionStrings[0].Name
Run Code Online (Sandbox Code Playgroud)

我总是得到存储在machine.config中的连接字符串,而不是App.config中的连接字符串.

如何在应用程序域中加载我的特定App.Config文件?

powershell appdomain

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

Resharper格式化链式方法

在R#中是否有一个设置来格式化链式方法以从实例化的类的相同字符开始.

我想要的是:

var foo = new FooDataBuilder()
              .WithDate(myDate)
              .WithBar(myBar)
              .Build();
Run Code Online (Sandbox Code Playgroud)

R#给我的是什么:

var foo = new FooDataBuilder()
    .WithDate(myDate)
    .WithBar(myBar)
    .Build();
Run Code Online (Sandbox Code Playgroud)

resharper code-formatting

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

不允许多重性.实体框架

我试图第一次使用MVC4,并在尝试创建控制器时收到以下错误?有人可以引导我朝着正确的方向前进吗?


Microsoft Visual Studio

System.Data.Entity.Edm.EdmAssociationEnd :: Multiplicity在关系'PropertyData_DNISData'中的角色'PropertyData_DNISData_Target'中无效.由于"从属角色"属性不是关键属性,因此从属角色的多重性的上限必须为"*".

public class PropertyData
{
    [Key]
    public virtual string PropertyID { get; set; }

    [ForeignKey ("DNISData")]
    public virtual string DNIS { get; set; }

    public virtual string PropertyName { get; set; }
    public virtual string PropertyGreeting { get; set; }
    public virtual string PropertyOperator { get; set; }
    public virtual string InvalidEntryPrompt { get; set; }
    public virtual string NoEntryPrompt { get; set; }
    public virtual string Comment { get; set; }
    public virtual …
Run Code Online (Sandbox Code Playgroud)

entity-framework asp.net-mvc-4

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

XML Unicode安全编码

我正在寻找一种使用#&233编码XML文档的方法; 编码.

使用这个基本代码

var xmlDoc = new XmlDocument();
xmlDoc.Load(@"D:\Temp\XmlDocBase.xml");
xmlDoc.Save(@"D:\Temp\XmlDocBaseCopy.xml");
Run Code Online (Sandbox Code Playgroud)

我的Xml文档来自:

<?xml version="1.0"?>
<Tag1>
  <comment>entit&#233;</comment>
</Tag1>
Run Code Online (Sandbox Code Playgroud)

<?xml version="1.0"?>
<Tag1>
  <comment>entité</comment>
</Tag1>
Run Code Online (Sandbox Code Playgroud)

问候

c# xml unicode encoding

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

从控制台获取用户输入时出现"System.FormatException" - visual c#

我正在尝试制作一个命令行程序,它会询问您是否需要快速和长时间发出哔声.我一直System.FormatException在看下面的代码.我马上就遇到了问题Console.WriteLine("how many times should i beep?");.我已经找到了一个修正,console.read();//pause在这一行之后放右.

我的问题是我做错了什么?或者我想在那条线之后暂停?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("how fast would you like the sounds to play?");
        Console.WriteLine("70 = fast and 300 = slow can pick any number inbetween");
        string choice = Console.ReadLine();
        int speed = Convert.ToInt32(choice);
        Console.Write(speed);
        Console.Read();//pause
        Console.WriteLine("how many times should i beep?");
        string choice2 = Console.ReadLine();
        int j = Convert.ToInt32(choice2);
        Console.Write(j);
        Console.Read();//pause
        for (int …
Run Code Online (Sandbox Code Playgroud)

c# console-application

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

为什么我的C#中的for循环在这种情况下需要分号?

for (int frame <= 10; frame++)
{
}
Run Code Online (Sandbox Code Playgroud)

例如,我有此代码,但无法正常工作。当我放入半冒号时,它可以工作。为什么是这样?

for (; frame <= 10; frame++)
{
}
Run Code Online (Sandbox Code Playgroud)

c# for-loop

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