草庐IT

complex-data-types

全部标签

c# - "Unable to cast object of type ' System.Net.Http.Formatting.JsonContractResolver ' to type ' Newtonsoft.Json.Serialization.DefaultContractResolver '."

我们有一个最近被转移到新服务器的WEBAPI项目。在对项目的有效负载进行一些添加后,我正在运行我的项目,但它突然抛出以下错误:Unabletocastobjectoftype'System.Net.Http.Formatting.JsonContractResolver'totype'Newtonsoft.Json.Serialization.DefaultContractResolver'.有问题的代码行在global.asax中:protectedvoidApplication_Start(){GlobalConfiguration.Configure(WebApiConfig.R

c# - "Data Source cannot be empty. Use :memory: to open an in-memory database"是什么意思?

我最近将我的SQLServer数据库转换为SQLite数据库。但是当我尝试使用.Open()打开我的SQLite时,它​​抛出了这个错误:DataSourcecannotbeempty.Use:memory:toopenanin-memorydatabase编辑:添加连接字符串:ConnectionString=@"DataSource=D:\XXX.db;Version=3";connection=newSQLiteConnection(connectionString);connection.Open();为什么我会得到这个?我将相同的SQLServer数据库转换为SQLCE和my

c# - 扩展 System.Data.Linq.DataContext

我有一个反射(reflect)我的dbml文件的类,它扩展了DataContext,但由于某些奇怪的原因,它告诉我System.Data.Linq.DataContext'doesnotcontainaconstructorthattakes'0'arguments"我已经按照各种教程进行操作,但没有遇到这个问题,而且VS似乎无法修复它。这是我的实现usingSystem;usingSystem.Collections.Generic;usingSystem.Data;usingSystem.Data.Linq;usingSystem.Data.Linq.Mapping;usingSy

c# - ASP.NET MVC : Views using a model type that is loaded by MEF can't be found by the view engine

我正在尝试创建一个框架,以允许将Controller和View动态导入到MVC应用程序中。到目前为止,它是这样工作的:我正在使用.NET4、ASP.NETMVC3RC和RazorViewEngine每个项目都使用MEF导出和导入Controller-我将给定项目中的一组Controller和View称为“模块”BuildManager使用应用前启动方法和BuildManager.AddReferencedAssembly动态引用使用MEF发现的程序集。使用构建事件将二进制文件(来自导出项目)和View复制到目标项目的文件夹结构中使用自定义Controller工厂选择Controller

c# - LINQ TO 数据集 : Multiple group by on a data table

我正在使用Linqtodataset来查询数据表。如果我想对数据表的“Column1”执行分组,我使用以下查询vargroupQuery=fromtableinMyTable.AsEnumerable()grouptablebytable["Column1"]intogroupedTableselectnew{x=groupedTable.Key,y=groupedTable.Count()}现在我想对两列“Coulmn1”和“Column2”进行分组。谁能告诉我语法或提供一个链接来解释数据表上的多个分组依据??谢谢 最佳答案 您应

c# - 为什么这段代码会提示 "the arity of the generic type definition"?

我有一个通用类型:classDictionaryComparer:IEqualityComparer>还有一个工厂方法,它将(应该)为给定的字典类型创建此类的实例。privatestaticIEqualityComparerCreateDictionaryComparer(){Typedef=typeof(DictionaryComparer);Debug.Assert(typeof(T).IsGenericType);Debug.Assert(typeof(T).GetGenericArguments().Length==2);Typet=def.MakeGenericType(ty

C# 可移植类库 - 如何包含 System.Data.Linq

是否可以在可移植类库项目中引用System.Data.Linq?注意:我只是想在WP8和WinStore8应用程序[DataContext]之间共享代码 最佳答案 不,不是。数据命名空间在PCL中不可用。你可以看出因为http://msdn.microsoft.com/en-us/library/system.data.aspx它的成员都没有PCL图标,并且未在http://msdn.microsoft.com/en-us/library/vstudio/gg597391%28v=vs.100%29.aspx上列出

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# - "The binary operator Add is not defined for the types ' System.String ' and ' System.String '."-- 真的吗?

尝试运行以下代码时:Expression>stringExpression=Expression.Lambda>(Expression.Add(stringParam,Expression.Constant("A")),newList(){stringParam});stringAB=stringExpression.Compile()("B");我收到标题中提到的错误:“二元运算符Add没有为类型‘System.String’和‘System.String’定义。”真的是这样吗?显然在C#中它有效。在C#中执行strings="A"+"B"是表达式编译器无法访问的特殊语法糖吗?

c# - 了解 MVC 中的 [HttpPost]、[HttpGet] 和 Complex Actionmethod 参数

我对MVC设计模式和框架非常陌生。我也不太精通ASP.NETForms的基础知识。但是,我确实了解Web开发以及HTTPPost和GET的基础知识。现在,我学习了一些MVC教程,虽然我已经很好地掌握了MVC模式的工作原理以及“路由引擎”的工作原理。然后突然我遇到了一个看起来像下面的代码:publicclassHomeController:Controller{publicActionResultIndex(){returnView(newMyViewModel());}[HttpPost]publicActionResultIndex(MyViewModelmodel){returnC