每次我用ASP.NET Core应用程序构建Dockerfile时,都会从web Nuget商店下载程序集.
基本上我想用所有这些ASP.NET核心库(可能还有一些我经常使用的库)创建docker镜像.
根据我的理解,我试图重塑GAC.
所以,我的问题是可以使用像GAC这样的ASP.NET Core吗?或者,我的第二个想法,将ASP.NET核心库下载到容器,然后以某种方式在本地解析它.
我的目标是减少构建docker容器的时间.
UPDATE
看起来这是不可能的
我正在接受这个命令
Dictionary<UInt64, int> myIntDict = new Dictionary<UInt64, int>(89478458);
Run Code Online (Sandbox Code Playgroud)
这个错误:
System.OutOfMemoryException was unhandled HResult=-2147024882
Message=Array dimensions exceeded supported range.
Source=mscorlib
StackTrace:
at System.Collections.Generic.Dictionary`2.Initialize(Int32 capacity)
at System.Collections.Generic.Dictionary`2..ctor(Int32 capacity, IEqualityComparer`1 comparer)
Run Code Online (Sandbox Code Playgroud)
在89478457上没有错误.以下是Dictionary.cs中Initialize的来源:
private void Initialize(int capacity)
{
int size = HashHelpers.GetPrime(capacity);
...
entries = new Entry[size];
...
}
Run Code Online (Sandbox Code Playgroud)
当我重现它时,错误发生在数组创建上.在这种情况下,条目是一个结构,大小为24.当我们得到max int32(0x80000000-1)并除以24 = 89478485时,这个数字在素数89478457和89478503之间.
这是否意味着,结构数组不能像maxInt32/sizeOfThisStruct那样大?
编辑:
是.我实际上超过2 GB.当字典创建struct Entry的内部数组时,会发生这种情况,其中存储了(键,值)对.在我的例子中,sizeof(Entry)是24个字节,并且值类型是内联分配的.
解决方案是使用gcAllowVeryLargeObjects 标志(谢谢Evk).实际上在.net核心中,标志是环境变量 COMPlus_gcAllowVeryLargeObjects(谢谢svick).
是的,狗仔队是对的.我要思考,怎么不浪费记忆.谢谢你们.
.NET Core上的SigningCredentials与.NET 4.0不同
cryptography claims-based-identity encryption-symmetric .net-core powerbi-embedded
这是我第一次使用LDAP和Active Directory。我必须使用.NetCore制作一个必须通过ActiveDirectory进行身份验证的Web api(WindowsServer 2008 r2),我正在遵循Novell.Directory.Ldap.NETStandard中的示例, 但是我不明白我必须设置参数的方式。这是我在ActiveDirectory Server中创建的用户:
在Novell的样本中
if (args.Length != 5)
{
System.Console.Out.WriteLine("Usage: mono VerifyPassword <host name>" + " <login dn> <password> <object dn>\n" + " <test password>");
System.Console.Out.WriteLine("Example: mono VerifyPassword Acme.com " + "\"cn=Admin,o=Acme\" secret\n" + " \"cn=JSmith,ou=Sales,o=Acme\" testPassword");
System.Environment.Exit(0);
}
int ldapPort = LdapConnection.DEFAULT_PORT;
int ldapVersion = LdapConnection.Ldap_V3;
System.String ldapHost = args[0];
System.String loginDN = args[1];
System.String password = args[2];
System.String objectDN = args[3];
System.String testPassword = args[4];
LdapConnection conn = new LdapConnection();
try
{ …Run Code Online (Sandbox Code Playgroud) 我是DotNet Core的新手.我使用.NEt Core创建了一个WEB API.我需要在此API中实现缓存管理器.我有一组记录会在一天内更新一次,因此我希望这些数据存储在内存中的对象中,并且只有在检测到更改时(或者以一定的间隔,比如3小时)才调用数据库.我已经尝试在我的应用程序中实现逻辑.但是想知道我们是否已经有特定的包装!
请帮我.
提前致谢.
我在Mac OS X上的.NET Core中创建了一个新的.NET类库项目.在项目构建期间,我想将文件复制到调试目录中.如何将其添加到.csproj文件中?
.NET Command Line Tools (1.0.1)
Product Information:
Version: 1.0.1
Commit SHA-1 hash: 005db40cd1
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/1.0.1
Run Code Online (Sandbox Code Playgroud) 使用.net核心,所以我无权访问System.Drawing.我有一个865颜色名称及其十六进制等效的列表(0x格式).我永远不需要修改列表,我只需要能够从Either列快速搜索列表(可以搜索名称或十六进制).名称很简单,按字母顺序排列,但Hex是它们的名称.我想让它快速找到对方搜索的方式吗?什么是创建数据结构的最佳方法,以及您将使用哪些搜索方法?
我正在研究http://cc.davelozinski.com/c-sharp/fastest-collection-for-string-lookups
它显示了一些有趣的数据,但它只搜索单个列,所以不是我正在寻找的.如果我只使用颜色名称作为键值,排序列表似乎是要走的路,但是Hex会让我失望.
示例列表:
Air superiority blue 0x72A0C1
Alabama Crimson 0xA32638
Alice blue 0xF0F8FF
Alizarin crimson 0xE32636
Alloy orange 0xC46210
Almond 0xEFDECD
Amaranth 0xE52B50
Amber 0xFFBF00
Run Code Online (Sandbox Code Playgroud) 我有项目A,其对项目的依赖B,但也从没有提及B到A.我想建立和复制组件bin folder项目B,以bin folder项目A.我怎么能用post build事件做到这一点dotnet msbuild.
我找到了这个链接,但它适用于VS 2015及以下和MS-Build:
msbuild post-build-event visual-studio .net-core visual-studio-2017
我在 C# 项目中使用 Jetbrains rider,并在调试时使用动态程序分析功能,并且我有一段代码在枚举树结构时显示高内存分配问题。
该树需要是线程安全的,因为它可以在枚举时被另一个线程写入。
这是似乎过度分配的违规代码,JetBrains 工具似乎认为问题是由于闭包对象引起的,但我不相信,它位于小对象堆上
public IEnumerator<TreeNode<T>> GetEnumerator()
{
yield return this;
if (this.children == null)
{
yield break;
}
// Copy the children in case the collection gets modified while reading
var childrenCopy = new List<TreeNode<T>>(this.children);
foreach (var child in childrenCopy)
{
foreach (var subChild in child)
{
yield return subChild;
}
}
}
Run Code Online (Sandbox Code Playgroud)
- 更新
我知道子副本将分配,但一旦超出范围,我希望它被释放而不是卡在小对象堆上
任何关于正在发生的事情的想法将不胜感激。
谢谢
我现在才学习 C# 几个月(新工作)。我对一些循环模式进行了粗略的速度测试,有些东西引起了我的注意。
int[] myArr = new int[] { 11, 12, 13, 14, 6, 22, 45, 13 };
IEnumerable<int> myEnum = myArr;
DateTime start = DateTime.Now;
int enumSum = myEnum.Sum();
Console.WriteLine("time using IEnum.Sum(): " + (DateTime.Now - start).TotalSeconds);
Console.WriteLine("using IEnum.Sum(): " + enumSum);
Run Code Online (Sandbox Code Playgroud)
平均而言, while 和 foreach 循环的性能远远优于其对应循环(当我直接操作数组时)。
while (idx < myArr.Length)
{
total += myArr[idx];
idx++;
}
Console.WriteLine("time using while loop: " + (DateTime.Now - start).TotalSeconds);
Console.WriteLine("using while loop: " + total);
Run Code Online (Sandbox Code Playgroud)
然而,由于 IEnumerable 索引不能直接引用,我尝试使用 ElementAt() 方法,差异令人难以置信。
while (idx …Run Code Online (Sandbox Code Playgroud) .net-core ×10
c# ×6
.net ×3
asp.net-core ×2
c#-4.0 ×1
caching ×1
cryptography ×1
csproj ×1
docker ×1
macos ×1
msbuild ×1
novell ×1
performance ×1
structure ×1
types ×1