小编Fil*_* DO的帖子

确保HttpConfiguration.EnsureInitialized()

我安装了Visual Studio 2013,当我运行我的应用程序时,我收到以下错误.

我不知道我要在哪里初始化这个对象.

该怎么办?

    Server Error in '/' Application.

The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized() is called in the application's startup code after all other initialization code.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized() is called in the …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net-mvc-routing

139
推荐指数
8
解决办法
7万
查看次数

如何反序列化时从json中删除k__BackingField

在将xml文件序列化为.net c#对象后,我在返回的json中获取k_BackingField.

我已经将DataContract和DataMember属性添加到.net c#对象中,但是在json,客户端没有得到任何结果.

[XmlRoot("person")]
[Serializable]
public class LinkedIn
{
    [XmlElement("id")]
    public string ID { get; set; }

    [XmlElement("industry")]
    public string Industry { get; set; }

    [XmlElement("first-name")]
    public string FirstName { get; set; }

    [XmlElement("last-name")]
    public string LastName { get; set; }
    [XmlElement("headline")]
}
Run Code Online (Sandbox Code Playgroud)

返回的json示例:

home: Object
<FirstName>k__BackingField: "Storefront"
<LastName>k__BackingField: "Doors"
Run Code Online (Sandbox Code Playgroud)

.net serialization json deserialization

94
推荐指数
6
解决办法
6万
查看次数

如何使用Razor使用MVC4设置javascript变量

有人可以格式化下面的代码,以便我可以使用razor使用c#代码设置srcript变量吗?

以下不起作用,我有这样的方式使人很容易帮助.

@{int proID = 123; int nonProID = 456;}

<script type="text/javascript">
    @{

     <text>  

    var nonID =@nonProID;
    var proID= @proID;
    window.nonID = @nonProID;
    window.proID=@proID;

    </text>
}
</script>
Run Code Online (Sandbox Code Playgroud)

我遇到了设计时错误

在此输入图像描述

javascript c# asp.net-mvc razor

42
推荐指数
6
解决办法
12万
查看次数

无法加载资源:403禁止使用.js优化

我正在尝试缩小我的.js和.css文件.

我安装了包装 Install-Package Microsoft.AspNet.Web.Optimization

当我激活优化时 BundleTable.EnableOptimizations = true;

我在客户端收到此错误:

无法加载资源:服务器响应状态为403(禁止) http://localhost:22773/Content/themes/elevation/v=gnDLBbf1VVRuQDXtIYn1q0P3ICZG7oiwwgxPRbaLvqI1

任何人都知道我做错了什么?

--- BundleConfig info -------------------------------

 public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        BundleTable.EnableOptimizations = true;

        bundles.Add(new ScriptBundle("~/bundles/myJquery").Include(

           "~/Scripts/jquery-1.9.1.js",
          "~/Scripts/jquery-ui-1.10.1.custom.js",
            "~/Scripts/jquery.signalR-1.0.1.js",
            "~/Scripts/signalr-hubs.js",
            "~/Scripts/Controls/Select/Simple/jquery.ui.selectmenu.js"
        ));


        bundles.Add(new ScriptBundle("~/bundles/shared").Include(
            "~/Scripts/global/prototypes.js",
            "~/Scripts/global/mathutil.js",
            "~/Scripts/global/elevationevents.js"
            ));


        bundles.Add(new ScriptBundle("~/bundles/core").Include(
            "~/Scripts/elevation/core/sys.config.js",
            "~/Scripts/elevation/core/bays.js",
            "~/Scripts/elevation/core/door.js",
            "~/Scripts/elevation/core/horiziontal.js",
            "~/Scripts/elevation/core/vertical.js"));


        bundles.Add(new StyleBundle("~/Content/themes/elevation").Include(
            "~/Content/themes/dialogs/dialogs.css",
            "~/Content/themes/social/ac/acSocial.css",
            "~/Content/themes/elevation/elevation.css"
      ));
    }
}
Run Code Online (Sandbox Code Playgroud)

-----------------------------我还没弄明白------------- --------

我在windows7操作系统上使用2013 .net和iis8

这是我最新的错误,我无法将我的解决方案从调试模式中解脱出来,因​​为如果我这样做,我会在下面得到该错误.

    HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this …
Run Code Online (Sandbox Code Playgroud)

.net c# optimization minify

23
推荐指数
1
解决办法
2万
查看次数

如何使用异步方法正确编写Parallel.For

我将如何构造下面的代码,以便调用异步方法?

Parallel.For(0, elevations.Count(), delegate(int i)
{
   allSheets.AddRange(await BuildSheetsAsync(userID, elevations[i], includeLabels));
});
Run Code Online (Sandbox Code Playgroud)

.net c# task-parallel-library async-await

19
推荐指数
2
解决办法
2万
查看次数

数据读取器与指定的实体框架不兼容

我有一个方法,将从sproc返回裸min结果以填充选择菜单.当我想要裸min结果时,我将bool getMin = true传递给sproc,当我想要完整记录时,我传递bool getMin = false.

这导致Entity FrameWork错误" 数据读取器与指定的不兼容 "

错误最相关的部分

{"Message":"发生错误.","ExceptionMessage":"数据读取器与指定的'CatalogModel.proc_GetFramingSystems_Result'不兼容.类型的成员'FrameType'在其中没有相应的列具有相同名称的数据读取器.","ExceptionType":"System.Data.EntityCommandExecutionException",

显然,错误告诉我,当数据读取器尝试设置不在查询结果中的属性"FrameType"时.

现在我理解了这个错误,我想知道的是,我正在为了将这个sql sproc拆分成两个sprocs而进行goning,还是有解决方法?

我的功能如下

public static IEnumerable<IFramingSystem> GetFramingSystems(int brandID, string frameType, string glazeMethod, bool getMin)
{
    using (CatalogEntities db = new CatalogEntities())
    {
        return db.proc_GetFramingSystems(brandID, frameType, glazeMethod, getMin).ToList<IFramingSystem>();
    };
}
Run Code Online (Sandbox Code Playgroud)

我的TSQL如下

ALTER proc [Catelog].[proc_GetFramingSystems]
@BrandID   INT,
@FrameType VARCHAR(26),
@GlazeMethod VARCHAR(7) ='Inside',
@getMin    BIT = 0
as
BEGIN
SET NOCOUNT ON;
IF @getMin =0
BEGIN
SELECT c.ID,c.Name,c.Descr,c.FrameType,c.isSubFrame,
       c.GlassThickness,c.GlassPosition,c.GlazingMethod,c.SillProfile
        from Catelog.Component c
WHERE c.MyType ='Frame' 
AND c.FrameType = @FrameType …
Run Code Online (Sandbox Code Playgroud)

.net c# t-sql entity-framework-4

15
推荐指数
2
解决办法
6万
查看次数

如何获取和设置图像的属性

我正在尝试理解Bitmap或Image的这两种方法.一个存在.SetPropertyItem(),另一个存在.GetPropertyItem().

我完全混淆了文档说我要设置属性项的方式.

Microsoft文档中,它声明我们应该通过图像中已存在的属性项的id选择属性项,为该属性项提供新ID,设置属性,然后使用该检索到的属性设置image属性项项目.

这太奇怪了,但真正让我感到的是我们不能只将属性项的id设置为我们必须将属性项id设置为属性项id列表中已存在的id的任何ID.

令人困惑的是,我正在使用已经通过其他方式设置的属性并覆盖它的属性,然后使用属性id列表中的其他现有ID将其添加回图像.

我在这里错过了什么?有没有办法简单地创建一个新的PropertyItem,然后将具有任何给定ID的属性项添加到图像或位图?

这是我正在谈论的一个例子.20752的ID是图像已有的属性,当我设置PropertyItem的ID时,20753是Image所具有的ID.

这将成功设置属性项.

  private void Form1_Load(object sender, EventArgs e)
    {

        string path = Environment.CurrentDirectory + @"\sample.png";
        Image image = Image.FromFile(path);

        PropertyItem pi = image.GetPropertyItem(20752);

        pi.Id = 20753;

        pi.Type = 1;
        pi.Value = Encoding.UTF8.GetBytes("MyImageInfo");
        pi.Len = pi.Value.Length;
        image.SetPropertyItem(pi);

        image.Save(Environment.CurrentDirectory + @"\sample2.png");
    }
Run Code Online (Sandbox Code Playgroud)

这将成功检索PropertyItem.

  private void Form1_Load(object sender, EventArgs e)
        {

            string path = Environment.CurrentDirectory + @"\sample.png";
            Image image = Image.FromFile(path);

            PropertyItem propItem = image.GetPropertyItem(20753);
        }
Run Code Online (Sandbox Code Playgroud)

有一种方法,我可以用自己的ID创建一个新的PropertyItem,而不必做所有那些奇怪的东西?或者我在这里遗漏了什么?

或者,是为图像或位图设置其他类型属性的更好方法吗?我正在寻找一种基本的方法来保存信息并在以后检索它.

我在这做错了什么?

c# graphics image bitmap graph-drawing

12
推荐指数
1
解决办法
2万
查看次数

找不到模块'eslint-config-defaults/configurations/eslint'

我是新手使用Visual Studio Code的简易版本,对于我的生活,我无法弄清楚如何解决这个错误.

我试图拉入任何类型的文件甚至非常类似于条款.eslint但我总是得到这个错误.我确定这是一个配置错误,但我还不知道如何使用配置.

有什么建议?

我正在学习Node.js课程并且他们正在使用这个轻量级版本,我也想使用它,因为它更快地上课等等.

错误

Cannot find module 'eslint-config-defaults/configurations/eslint'
Run Code Online (Sandbox Code Playgroud)

eslint错误 - 看看环境的最顶层

c# node.js eslint visual-studio-code

12
推荐指数
1
解决办法
5229
查看次数

SignalR导致升级时出现重大问题

两天后我终于安装了新的SignalR;但是,我遇到了另一个问题.

我要么删除了特定的Owin Assembly,要么就失去了对它的引用.

我已经检查了我的bin,包和引用文件夹,所有原始的Owin命名约定都是可见的.

任何人救我脱离这场悲剧并告诉我如何解决这个问题?

这是从iis返回的服务器错误.

    Server Error in '/' Application.

The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- No assembly found containing a Startup or [AssemblyName].Startup class.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.
To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your …
Run Code Online (Sandbox Code Playgroud)

.net c# signalr owin

8
推荐指数
2
解决办法
1万
查看次数

错误:此操作将创建结构不正确的文档

我一直在尝试安装实体框架6,它总是回滚错误

error: This operation would create an incorrectly structured document.
Run Code Online (Sandbox Code Playgroud)

我已经卸载了对这个位置提到的每个dll的所有引用.http://entityframework.codeplex.com/wikipage?title=Updating%20Applications%20to%20use%20EF6

疯狂的是,我可以创建一个新项目,创建一个webAPI程序,并尝试添加实体框架6,我得到相同的错误,即使删除所有对System.Data.Entity.dll的引用后我已经是一些这几天,需要认真的帮助.

我该怎么做才能安装Entity Framework 6?

注意:它只会安装到类库而不是WebApi或MVC应用程序.


如果它有帮助,这里有一些更详细的错误信息.

PM> Install-Package EntityFramework -Version 6.0.0
Installing 'EntityFramework 6.0.0'.
Successfully installed 'EntityFramework 6.0.0'.
Adding 'EntityFramework 6.0.0' to AC.
Successfully added 'EntityFramework 6.0.0' to AC.
System.InvalidOperationException: This operation would create an incorrectly structured document.
   at System.Xml.Linq.XDocument.ValidateDocument(XNode previous, XmlNodeType allowBefore, XmlNodeType allowAfter)
   at System.Xml.Linq.XDocument.ValidateNode(XNode node, XNode previous)
   at System.Xml.Linq.XContainer.AddNodeSkipNotify(XNode n)
   at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content)
   at System.Xml.Linq.XContainer.Add(Object content)
   at System.Data.Entity.Migrations.Extensions.XContainerExtensions.GetOrCreateElement(XContainer container, String elementName, XAttribute[] attributes) …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-web-api entity-framework-6

8
推荐指数
3
解决办法
3399
查看次数