草庐IT

cannot-find-symbol

全部标签

c# - 等待和异步属性中的方法错误 'Cannot await ' System.Threading.Tasks.Task'

我已经为.NETFramework4、Silverlight4和5以及WindowsPhone7.5和8安装了NuGetPackageAsync。Version1.0.16我使用的是Microsoft.NET4.0,但由于虚拟主机包限制,我无法升级。(可悲!)我的测试代码:(我正在执行LinqtoSQL查询代替Thread.Sleep)publicclassSearch{publicasyncTask>GetResults(stringSearchString){awaitSystem.Threading.Tasks.Task.Factory.StartNew(()=>Thread.S

c# - 错误 APPX3212 : SDK root folder for 'Portable 7.0' cannot be located

我正在尝试使用TeamCity/MSBuild构建我的解决方案。这是一个WebAPI项目,它与移动客户端共享PCL中的一些实体。我看到关于在构建服务器上安装PCL引用库有一些注意事项,我想我已经整理好了(BuildingPortableClassLibraryProjectinbuildserverfails)但是,我在构建可移植类库的过程中遇到如下错误:[11:20:49][Doctrina.Pcl.Entities\Doctrina.Pcl.Entities.csproj]_GetSdkToolPaths[11:20:49][_GetSdkToolPaths]GetSdkPrope

C# 编译器错误 : "cannot have instance field initializers in structs"

我需要有关结构的建议。我有两段代码。第一部分如下:namespaceProject.GlobalVariables{classIOCard{structInputCard{publicstringCardNo;publicintBaseAddress;publicintLowerAddress;publicintUpperAddress;publicint[]WriteBitNo=newint[16];publicint[]ReadBitNo=newint[16];}staticInputCard[]InputCards=newInputCard[5];publicstaticstri

c# - 使用 Json.Net 反序列化时出现错误 "Cannot deserialize the current JSON array"

我有一个字符串:[{"key":"key1","value":"{'Time':'15:18:42','Data':'15:18:42'}","duration":5},{"key":"key1","value":"{'Time':'15:18:42','Data':'15:18:42'}","duration":5}]我的模型类:publicclassCPacket{publicstringkey{get;set;}publicstringvalue{get;set;}publicintduration{get;set;}}我使用Json.Net,我想将下面的字符串转换为Json对象

c# - 当 T 是结构时,List<T>.Find 如何工作?

我有一个List>.我需要按照以下方式做一些事情list.Find(x=>x.Key=="foobar")但是,如果列表中不存在,行为会是什么?通常它会返回null,但结构不能为null。 最佳答案 我的建议是对不可为null的类型使用FindIndexintindex=list.FindIndex(x=>x.Key=="foobar");if(index>=0){//found!UseResult(list[index]);}如果Find()不成功,返回默认值default(T)。对于不可空类型,此结果无法与具有默认值的常规条目区

c# - 无法加载文件或程序集 ':This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded

我在我的解决方案中有3个项目:BL、DL和UI。这三个项目的目标框架都是>NET4;我通过查看每个项目的属性页仔细检查了这一点。当我尝试在托管环境中运行网站时收到以下错误消息,但在本地运行时却没有。Couldnotloadfileorassembly'BL'oroneofitsdependencies.Thisassemblyisbuiltbyaruntimenewerthanthecurrentlyloadedruntimeandcannotbeloaded.提前致谢! 最佳答案 -转到IIS。-DefaultWebSite->Y

c# - 尝试将我的 Web 应用程序从 VS Community 2015 发布到 Azure 时出错。错误 : Can't find existing loaded project:http://localhost:55809

昨天一切正常。我根据软件的建议对我的系统(来自VSCommunity15的更新)和AzureSDK更新等进行了一些更改。今天,当我右键单击Web应用并选择发布(使用相同或手动输入的公共(public)信息)时,我在Azure应用服务事件选项卡上看到以下错误:找不到已加载的项目:http://localhost:55809此后我尝试了其他发布配置文件,但似乎都不起作用。我可以在本地主机上成功构建和运行网络应用程序。 最佳答案 在VisualStudio中,转到“查看”->“其他窗口”->“Web发布事件”,您将看到“Azure应用服务

c# - 什么可能导致 WCF 中出现 "Cannot access a disposed object"错误?

我正在使用以下代码:privateWSHttpBindingws;privateEndpointAddressSrv_Login_EndPoint;privateChannelFactorySrv_LoginChannelFactory;privateSrv_Login.Srv_ILoginLoginService;Login是我的构造函数:publicLogin(){InitializeComponent();ws=newWSHttpBinding();Srv_Login_EndPoint=newEndpointAddress("http://localhost:2687/Srv_L

c# - 带有 Attach() 的 LINQ To SQL 异常 : Cannot add an entity with a key that is already in use

考虑这个典型的断开连接的场景:使用LINQToSQL从SQLServer加载客户对象用户编辑实体,表示层发回修改后的实体。数据层,使用L2S,必须将更改发送到SQLServer考虑这个LINQToSQL查询,其目的是获取客户实体。CustcustOrig=db.Custs.SingleOrDefault(o=>o.ID==c.ID);//gettheoriginaldb.Custs.Attach(c,custOrig);//wedon'thaveaTimeStamp=Truepropertydb.SubmitChanges();DuplicateKeyException:Cannota

c# - 通用扩展方法 : Type argument cannot be inferred from the usage

我正在尝试创建一个适用于类型化数据表的通用扩展方法:publicstaticclassExtensions{publicstaticTableTypeDoSomething(thisTableTypetable,paramExpression>[]predicates)whereTableType:TypedTableBasewhereRowType:DataRow{//dosomethingtoeachrowofthetablewheretherowmatchesthepredicatesreturntable;}[STAThread]publicstaticvoidmain(){M