虽然已经设置MaxRequestLength并maxAllowedContentLength在最大可能值web.config部分,ASP.Net核心不允许我才能上传大文件134,217,728 Bytes.来自Web服务器的确切错误是:
处理请求时发生未处理的异常.
InvalidDataException:超出了多部分主体长度限制134217728.
有没有办法解决这个问题?(ASP.Net核心)
我正在使用第三方API .NET 4.我想在我的类库中使用Async/Await功能.我是Microsoft.Bcl.Async从NuGet 安装的.我有一些关于部署的问题:
1)安装后Microsoft.Bcl.Async,我的项目中添加了许多引用(Microsoft.Threading.Tasks,Microsoft.Threading.Tasks.Extensions..).还有一个创建的app.config文件.部署要求是什么?
2)如何为第三方应用程序的安装目录中的类库部署app.config文件.我是否需要将app.config中的xml添加到应用程序的配置中?
3)我是否需要Microsoft.Bcl.Async在引用该项目的所有项目上安装?
环境:
Visual Studio Express 2013 .NET 4
我知道这可能听起来像一个奇怪的问题,但这已经在我脑海中浮现了一段时间.
我知道C#中的System.String类型实际上是一个带有构造函数的类,该构造函数具有字符数组参数.例如,以下代码是合法的,不会导致错误:
System.String s = new System.String("Hello".toCharArray());
Run Code Online (Sandbox Code Playgroud)
我的问题是,System.String类可以通过这种方式接受一个字符数组:
System.String s = "Hello";
Run Code Online (Sandbox Code Playgroud) 我是 RSA 加密的新手,我一直在尝试使用 .Net 的System.Security.Cryptography.
public String Encryption(Byte[] Input, RSAParameters PublicKey)
{
RSAC = new RSACryptoServiceProvider();
RSAC.ImportParameters(PublicKey);
Byte[] Encrypt = RSAC.Encrypt(Input, false);
return Convert.ToBase64String(Encrypt);
}
Run Code Online (Sandbox Code Playgroud)
使用上面的代码,无论何时我重新启动应用程序,我都会为相同的输入获得不同的加密字符串。我想知道这是否是正常行为,如果不是,如何预防。
例如,程序为输入“Hello”返回以下字符串:
NopDAF5FRu....
Run Code Online (Sandbox Code Playgroud)
当我重新启动应用程序时,相同输入的输出将是:
pPPu8x6....
Run Code Online (Sandbox Code Playgroud)
但是,当我为 RSA 加密类创建新对象时,所有对象都返回相同的输出。
我有一个使用以下代码的列表视图:
<ListView x:Name="Display" ItemsSource="{Binding}" Background="#373737" Margin="0,0,350,0" BorderThickness="0" >
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Width="767" Height="88">
<Border Height="64" Width="64" Margin="12,12,0,12">
<Image Source="{Binding Path=album.albumart}" Stretch="UniformToFill"/>
</Border>
<StackPanel Orientation="Vertical" VerticalAlignment="Top" Margin="0,10,0,0">
<TextBlock Text="{Binding Path=name}"
Margin="10,0,0,0" Width="300" Height="40"
TextTrimming="WordEllipsis" TextWrapping="Wrap" FontSize="16" HorizontalAlignment="Left"/>
<TextBlock Text="{Binding Path=album.name}"
Margin="10,-15,0,0" Width="300" Height="20"
TextTrimming="WordEllipsis" HorizontalAlignment="Left"
FontSize="14" Opacity="0.49"/>
<TextBlock Text="{Binding Path=artistname}"
Margin="10,2,0,0" Width="300"
TextTrimming="WordEllipsis" HorizontalAlignment="Left"
FontSize="12" Opacity="0.49"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Run Code Online (Sandbox Code Playgroud)
我有大约 400 个带有图像的对象(这需要相当多的内存)
然后显示在每个列表视图项中。
有什么方法可以让列表视图告诉项目从我拥有的缓存中加载它们的图像,这是基于哪些对象在列表视图中可见,而不是一直加载所有图像,如前所述,这需要相当多的内存.
希望大家明白我的意思,谢谢。
我有个问题
我有一张44839条记录的表格
但是当我尝试使用以下代码通过EF加载我的表时:
dbContext = new MyDbContext("MyContext");
dbContext.SalesRegister.Load();
BindingList<SalesRegister> db =dbContext.SalesRegister.Local.ToBindingList();
gridControl.DataSource = db;
bsiRecordsCount.Caption = "RECORDS : " + db.Count;
Run Code Online (Sandbox Code Playgroud)
我只获得了16311条记录
但是当我使用它时,我得到了所有的记录
dbContext = new MyDbContext("MyContext");
List<SaleRegister> db = dbContext.SalesRegister.SqlQuery("select * from vwSalesRegister").ToList();
gridControl.DataSource = db;
bsiRecordsCount.Caption = "RECORDS : " + db.Count;
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
我一直试图了解实际上是什么接口,理论上我已经很好地理解了定义.但是当涉及到实际使用它们时,我会想到一些问题.
大多数资源以这种方式定义接口
“An interface is a contract between itself and any class that implements it. This contract states that any class that implements the interface will implement the interface's properties, methods and/or events. An interface contains no implementation, only the signatures of the functionality the interface provides. An interface can contain signatures of methods, properties, indexers & events.”
这很容易理解,但我的问题是,如果接口(根据这个定义)在它们自己和类之间的某种蓝图或契约,如果我定义这个接口会发生什么,
interface ITest {
int SomeTestVariable { set; get;}
int SomeTestMethod ();
}
Run Code Online (Sandbox Code Playgroud)
创建一个实现此接口的类及其所有方法
class Test: ITest {
int SomeTestvariable { set; …Run Code Online (Sandbox Code Playgroud) 在C#中,我可以轻松生成word文档或将word文件转换为其他格式Microsoft.Office.Interop.Word,但是如果用户没有在他们的系统中安装MS Office,我认为这种方法不会起作用.我想知道.net框架是否为此提供了任何特定的解决方案.(对第三方库不感兴趣,我已经发现很多,我的问题仅限于.net框架)
我一直在阅读不同的密码算法,我遇到了“Diffie Hellman Cryptography Next Generation”。我对该算法进行了大量搜索,我发现它是一种非对称加密系统,在某些方面可以与 RSA 相媲美。我查看了 .Net System.Security.Cryptography,我发现它也提供了 Diffie-Hellman 密码学。所以我没有去MSDN,在那里我找到了一个关于如何在 C# 中使用它的很好的例子,但是这个例子给我带来了一些问题。让我先复制部分代码:(我不发布完整代码,因为我的问题主要是关于这部分)
public static byte[] alicePublicKey;
public static void Main(string[] args)
{
using (ECDiffieHellmanCng alice = new ECDiffieHellmanCng())
{
alice.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
alice.HashAlgorithm = CngAlgorithm.Sha256;
alicePublicKey = alice.PublicKey.ToByteArray();
Bob bob = new Bob();
CngKey k = CngKey.Import(bob.bobPublicKey, CngKeyBlobFormat.EccPublicBlob);
byte[] aliceKey = alice.DeriveKeyMaterial(CngKey.Import(bob.bobPublicKey, CngKeyBlobFormat.EccPublicBlob));
byte[] encryptedMessage = null;
byte[] iv = null;
Send(aliceKey, "Secret message", out encryptedMessage, out iv);
bob.Receive(encryptedMessage, iv);
}
}
private static void Send(byte[] …Run Code Online (Sandbox Code Playgroud) 在.Net框架中,我们有Func<out TResult>可能会或可能不会采取任何参数但返回一些东西.具体来说,使用它时我们可以这样做:
int funcTest (Func<int> arg){ return arg();}
-->
int i = funcTest(()=>{return 1;})
Run Code Online (Sandbox Code Playgroud)
这是Function在Java中总是需要输入参数(Function<T,R>).有一段时间,有些情况下我们需要类似于我在问题开头解释的.Net示例的表达式.虽然可以通过将null,zero,true/false或任何其他虚拟值作为参数传递给表达式来处理这些情况,但这绝对不是处理此类情况的标准和明智的解决方案.
我搜索了java.util.function库,发现该命名空间中的大多数表达式都需要输入参数,所以我决定发布这个问题,看看java标准库中是否有类似于Func<Result>.Net的表达式.
无论如何都要将每个循环写入Linq表达式:
private List<string> datasetItemset;
Dictionary<string, int> itemsetScanning = new Dictionary<string, int>();
List<string> itemList = new List<string>();
foreach (string transaction in this.datasetItemset)
{
string[] items = transaction.Split(new char[] { ' ' });
foreach (string item in items)
if (!itemList.Contains(item))
{
itemList.Add(item);
itemsetScanning.Add(item, 0);
}
}
Run Code Online (Sandbox Code Playgroud)
我的下一个问题是,使用linq表达式而不是foreach循环加速程序的性能,我对这个linq有点新意.
更新:使用太多的foreach循环会减慢我的程序速度.
我正在使用takewhile以这种方式对一系列值进行分类:
var Range_1 = Dictionary_Name.TakeWhile (x=> x.Value < 50).toList();
Run Code Online (Sandbox Code Playgroud)
字典(String,int)包含如下值:
[Item 1, 10]
[Item 2, 20]
[Item 3, 5]
[Item 4, 3]
[Item 5, 41]
,...
Run Code Online (Sandbox Code Playgroud)
我正在使用的代码然后生成正确的结果但是当我将值更改为like时:
var Range_1 = Dictionary_Name.TakeWhile (x=> x.Value < 10).toList();
Run Code Online (Sandbox Code Playgroud)
它返回一个空集合.
我想知道它为什么不返回任何东西.
有没有办法直接通过颜色代码而不是java提供的预定义颜色来设置标签的前景.
例如 :
instead of:
SomeLabel.setForeground(Color.Red);
We do:
SomeLabel.setForeground("240,240,240");
Run Code Online (Sandbox Code Playgroud)
我问这个问题是因为当用户跳过它们时我将所需字段的标签颜色设置为红色,所以当我想重置它们的颜色时,我找不到我在预定义颜色中定义的颜色java提供.
c# ×10
.net ×2
cryptography ×2
encryption ×2
java ×2
linq ×2
.net-4.5 ×1
asp.net-core ×1
clr ×1
data-binding ×1
interface ×1
lazy-loading ×1
rsa ×1
sql ×1
swing ×1
wpf ×1
xaml ×1