jjzjj

Non-Standard

全部标签

c# - 命名空间 'Standard' 是什么?

当我尝试编写新的using子句时,我注意到Intellisense在其列表中有一个名为Standard的命名空间。但是,这似乎没有任何成员仔细检查。这个命名空间是什么? 最佳答案 PresentationFramework程序集中有一个名为“Standard”的命名空间。但是它的所有类型都是内部的,因此您看不到任何类型。但是,您仍然可以使用命名空间。命名空间似乎出现在4.5引用程序集中,它没有出现在4.0中。 关于c#-命名空间'Standard'是什么?,我们在StackOverflo

c# - Lazy<T> 延迟加载错误 : A field initializer cannot reference the non-static field, 方法或属性

我第一次尝试使用延迟加载来初始化我的类中的进度对象。但是,我收到以下错误:Afieldinitializercannotreferencethenon-staticfield,method,orproperty.privateLazym_progress=newLazy(()=>{longtotalBytes=m_transferManager.TotalSize();returnnewProgress(totalBytes);});在.NET2.0中,我可以执行以下操作,但我更愿意使用更新的方法:privateProgressm_progress;privateProgressPro

c# - LINQ to SQL insert-if-non-existent

我想知道是否有更简单的方法来插入表中尚不存在的记录。我仍在努力培养我的LINQtoSQL技能。这是我得到的,但似乎应该有更简单的方法。publicstaticTEntityInsertIfNotExists(DataContextdb,Tabletable,Funcwhere,TEntityrecord)whereTEntity:class{TEntityexisting=table.SingleOrDefault(where);if(existing!=null){returnexisting;}else{table.InsertOnSubmit(record);//Can'tuse

c# - The non-generic method cannot be used with type arguments in this context 是什么意思?

我有以下类和方法:publicclassUserManager:IDisposablewhereTUser:class,global::Microsoft.AspNet.Identity.IUserwhereTKey:global::System.IEquatable{publicvirtualTaskFindByIdAsync(TKeyuserId);和:privateApplicationUserManager_userManager;publicApplicationUserManagerUserManager{get{return_userManager??Request.Ge

c# - Xamarin 和 .NET Standard 2 库问题

我创建了一个跨平台库,它有3个特定于平台的实现:安卓系统苹果手机.NET标准2.0我以与跨平台库项目类似的方式将库与Nuget打包在一起。现在,当我创建一个新的XamarinForms项目并选择.NETStandard作为共享代码的方式时,我引用我的nuget并尝试在android模拟器中运行它,我得到:/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2):Error:Exceptionwhileloadingassemblies:Sy

c# - Entity Framework : Alternate solution to using non primary unique keys in an association

我知道EntityFramework不允许您使用非主唯一键作为外键关联从数据库生成模型。我可以手动修改EDMX吗?如果是这样,有人可以给我一个例子或引用吗?如果不是,还有其他可能吗?最简单的例子:这是表的DDL。您会注意到我有一个从PersonType.TypeCode到Person.TypeCode的外键CREATETABLE[dbo].[PersonType]([PersonTypeId][int]NOTNULL,[TypeCode][varchar](10)NOTNULL,[TypeDesc][varchar](max)NULL,CONSTRAINT[PK_PersonType]

c# - 低级差异 : non-static class with static method vs. 静态类与静态方法

我想知道使用具有静态方法的非静态类与具有相同静态方法的静态类的一般好处(或缺点)是什么,除了我不能使用非静态类中的静态方法作为扩展方法。例如:classNonStaticClass{publicstaticstringGetData(){return"Thiswasinvokedfromanon-staticclass.";}}与此相比:staticclassStaticClass{publicstaticstringGetData(){return"Thiswasinvokedfromastaticclass.";}}使用一种方法优于另一种方法对性能/内存有何影响?注意:假设我不需要

c# - .NET Standard 1.4 的 Environment.MachineName 等效项

我正在创建一个将在WPF项目和.NETCore项目中使用的类库。我正在尝试使用我的应用程序获取机器的名称。在.NETCore和WPF应用程序中,我都可以使用Environment.MachineName值。但是在我的.NETStandard类库中我不能。我收到以下错误:'Environment'doesnotcontainadefinitionfor'MachineName'我尝试按照thisquestion中建议的答案进行操作但是当我尝试添加System.Windows.Networking.Connectivity.NetworkInformation.GetHostNames()

c# - .Net Standard 中 CompileToMethod 的替代方案

我现在正在将一些使用表达式的库移植到.NetCore应用程序并遇到一个问题,我的所有逻辑都基于LambdaExpression.CompileToMethod而它根本就没有in.这是示例代码:publicstaticMethodInfoCompileToInstanceMethod(thisLambdaExpressionexpression,TypeBuildertb,stringmethodName,MethodAttributesattributes){...varmethod=tb.DefineMethod($"__StaticProxy",MethodAttributes.P

c# - 在类库 (.NET Standard) 中找不到位图类

我想制作一个类库(.NET标准)并且我正在使用System.Drawing,但是我得到了错误:CS0246C#Thetypeornamespacename'Bitmap'couldnotbefound(areyoumissingausingdirectiveoranassemblyreference?)我正在使用.NETStandard2.0。 最佳答案 我是CoreCompat.System.Drawing的作者。如果您使用的是.NETCore2.0,我建议您转到System.Drawing.Common相反,这是Microsof