小编Meh*_*ard的帖子

如何在sql server中生成并手动插入uniqueidentifier?

各位大家好,我正在尝试在我的表中手动创建一个新用户,但不能生成"UniqueIdentifier"类型而不会引发异常...

这是我的例子:

DECLARE @id uniqueidentifier
SET @id = NEWID()

INSERT INTO [dbo].[aspnet_Users]
           ([ApplicationId]
           ,[UserId]
           ,[UserName]
           ,[LoweredUserName]
           ,[LastName]
           ,[FirstName]
           ,[IsAnonymous]
           ,[LastActivityDate]
           ,[Culture])
     VALUES
           ('ARMS'
           ,@id
           ,'Admin'
           ,'admin'
           ,'lastname'
           ,'firstname'
           ,0
           ,'2013-01-01 00:00:00'
           ,'en')
GO
Run Code Online (Sandbox Code Playgroud)

Trow exception - > Msg 8169,Level 16,State 2,Line 4无法将字符串转换为uniqueidentifier.

我使用NEWID()方法,但它不起作用......

http://www.dailycoding.com/Posts/generate_new_guid_uniqueidentifier_in_sql_server.aspx

sql t-sql database sql-server uniqueidentifier

25
推荐指数
1
解决办法
11万
查看次数

创建和写入XML文件会引发异常 - >系统内存不足异常?


我已经开发了一段时间在XNA中称为"体素"的小游戏.一个.NET C#像Minecraft游戏.我使用一个简单的概念来保​​存和读取我的游戏中的数据来构建世界地图.一切都存储在xml文件中.

现在我正在尝试加载更大的地图,并且在生成地图期间会出现'paf'异常:

[ 系统内存不足异常 ]

我不明白为什么,因为在异常被提出后我的文件不是很重,它大约是70 MB.在生成高达70 mbXML文件期间看到异常引发是否正常?

使用的开发环境

  • Microsoft Windows 7(x64)位
  • Visual Studio 2012专业版更新3
  • 8192拉姆
  • 英特尔i5 CPU 2.5 Ghz(4 cpus)

我确实用CLR分析器进行了测试,以检查垃圾收集器的工作原理:

在此输入图像描述 在此输入图像描述

我初始化我的XmlWritter的代码:

    private XmlTextWriter myXmlTextWriter ;


    #region prepareNewWorldXmlFIle
    private void PreparedNewWorldXmlFile()
    {
        Stream fs = new FileStream(currentPath + "World\\world.xml", FileMode.Create);

        myXmlTextWriter = new XmlTextWriter(fs,Encoding.ASCII);
        myXmlTextWriter.Formatting = Formatting.Indented;
        myXmlTextWriter.WriteStartDocument(false);
        myXmlTextWriter.WriteComment("World Map ID:");
        //World and his attribute
        myXmlTextWriter.WriteStartElement("World");
        myXmlTextWriter.WriteStartElement("Matrix", null);
        myXmlTextWriter.WriteStartElement("Regions");
    }
    #endregion
Run Code Online (Sandbox Code Playgroud)

我用来生成我的世界地图并编写一个xml文件的代码:

    //Octree calcul and generate map to xml file
    foreach (Region …
Run Code Online (Sandbox Code Playgroud)

.net c# xna garbage-collection

14
推荐指数
1
解决办法
2186
查看次数

反序列化为double时,JsonConvert会抛出一个"非有效整数"异常

当我尝试从JSON字符串反序列化为对象时,我得到一个异常.

Input string '46.605' is not a valid integer. Path 'LatitudeCenter'

这真的很奇怪,因为JsonConvert尝试将属性反序列化为整数但它实际上是一个double而不是整数.

我已经检查了我的Web API项目.我的类中的属性是web项目中的double和same.

我在web asp项目中使用的代码:

using (var client = new HttpClient())
{
    client.BaseAddress = new Uri("myWebApiHostedUrl");
    client.DefaultRequestHeaders.Accept.Clear();
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

    // Get the response
    HttpResponseMessage response = await client.GetAsync("api/NewMap/?SouthLatitude=46.600&WestLongitude=7.085&NorthLatitude=46.610&EastLongitude=7.095&Width=900&Height=900&isVoxelMap=true");
    string jsonData = response.Content.ReadAsStringAsync().Result;

    //Exception here
    NewMap dataMewMap = JsonConvert.DeserializeObject<NewMap>(jsonData, new JsonSerializerSettings() { Culture = CultureInfo.InvariantCulture,FloatParseHandling= FloatParseHandling.Double });
}
Run Code Online (Sandbox Code Playgroud)

这是我的班级:

public class NewMap
{
    // ...
    public double LatitudeCenter { get; set; }
    public double …
Run Code Online (Sandbox Code Playgroud)

c# double json deserialization asp.net-web-api

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

大型多维数组(Jagged Array)C#的解决方法?

我正在尝试初始化三维数组以加载体素世界.

地图的总大小应为(2048/1024/2048).我试图初始化一个"int" 的锯齿状数组,但是我抛出了一个内存异常.尺寸限制是多少?我桌子的大小:2048*1024*2048 = 4'191'893'824

有人知道解决这个问题吗?

// System.OutOfMemoryException here !
int[][][] matrice = CreateJaggedArray<int[][][]>(2048,1024,2048);
// if i try normal Initialization I also throws the exception
int[, ,] matrice = new int[2048,1024,2048];

    static T CreateJaggedArray<T>(params int[] lengths)
    {
        return (T)InitializeJaggedArray(typeof(T).GetElementType(), 0, lengths);
    }

    static object InitializeJaggedArray(Type type, int index, int[] lengths)
    {
        Array array = Array.CreateInstance(type, lengths[index]);
        Type elementType = type.GetElementType();

        if (elementType != null)
        {
            for (int i = 0; i < lengths[index]; i++)
            {
                array.SetValue( …
Run Code Online (Sandbox Code Playgroud)

c# memory arrays jagged-arrays multidimensional-array

7
推荐指数
1
解决办法
3364
查看次数

如何使用客户端函数"OnClientClicking"传递bind或eval参数

我遇到了将参数传递给客户端事件的问题OnClientClicking.

我试图使用该String.Format ()功能,但它不起作用.

您是否有一个解决方法来发送与之链接的参数OnClientClicking

代码asp:

<telerik:RadButton ID="bnt_meetingDelete" runat="server" OnClientClicking="<%# string.Format("confirmCallBackFn('{0}');",Eval("MeetingID")) %>" Image-ImageUrl="~/image/icone/delete-icon.png" Image-IsBackgroundImage="true" Width="21" Height="21" telerik:RadButton>
Run Code Online (Sandbox Code Playgroud)

错误IIS:

Parser Error 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: The server tag is not well formed.
Run Code Online (Sandbox Code Playgroud)

我试过控制器[asp:ImageButton].并且是同样的错误

asp.net bind eval onclientclick

5
推荐指数
1
解决办法
3万
查看次数

如何使用visual studio中的堆栈跟踪进行调试?

当我们调试器返回如下错误页面时,我想知道是否有可能知道visual studio中的确切函数或代码行构成问题:

在此输入图像描述

因为如果我读取堆栈跟踪,我在现有代码中找不到函数名称.....不幸的是,调试相当奇怪且很难.非常感谢你

c# debugging visual-studio-2010 asp-classic

4
推荐指数
1
解决办法
6434
查看次数

使用基本身份验证调用web api始终从IIS中获取401未授权

今晚我来搜索一些关于如何调用IIS中托管的web api的帮助.

从视觉工作室到iis express,一切都在当地运作良好.但奇怪的是,在我的IIS服务器上发布之后.我总是得到401未经授权:'(

这是我使用的代码和我的IIS服务器的设置.如果有人可以帮助我,我将非常感激.谢谢

**

控制器和我尝试调用的函数(具有基本认证属性)

**

    [HttpGet]
    [ActionName("Get_UserID")]
    [IdentityBasicAuthentication]
    [Authorize]
    public HttpResponseMessage Get_UserID(string userName)
    {
        HttpResponseMessage res = new HttpResponseMessage(HttpStatusCode.Created);
        try
        {
            var user = Membership.GetUser(userName, false);
            if (user != null)
            {
                res = Request.CreateResponse(HttpStatusCode.OK, (Guid)user.ProviderUserKey);
            }
            else
            {
                res = Request.CreateResponse(HttpStatusCode.ExpectationFailed);
                res.Content = new StringContent("Error");
                res.ReasonPhrase = "UserName not find in the database";
            }
        }
        catch (Exception exc)
        {
            //Set the response message as an exception
            res = Request.CreateResponse(HttpStatusCode.InternalServerError);
            res.Content = new StringContent("Exception"); …
Run Code Online (Sandbox Code Playgroud)

c# basic-authentication asp.net-web-api asp.net-web-api2

4
推荐指数
1
解决办法
5545
查看次数

使用顶点缓冲区绘制大量相同的模型?

我面临着许多开发人员可能找到解决方案的问题.我有一个小项目,地板设计有小立方体(100X100).如果我超过这个限制,我的游戏遭遇重大减速和联赛!

这是我如何画地板的:

//Function to draw my ground ( 100 X 100 X 1)
    public void DrawGround(GameTime gameTime)
    {
        // Copy any parent transforms.
        Matrix[] transforms = new Matrix[this.model.Bones.Count];
        this.model.CopyAbsoluteBoneTransformsTo(transforms);

        //loop 1 cube high
        for (int a = 0; a < 1; a++)
        {
            //loop 100 along cube
            for (int b = 0; b < 100; b++)
            {
                //loop 100 cubic wide
                for (int c = 0; c < 100; c++)
                {
                    // Draw the model. A model can have multiple …
Run Code Online (Sandbox Code Playgroud)

performance xna vertex-buffer

3
推荐指数
1
解决办法
1935
查看次数

如何 - 在SQL Server中创建后直接创建和使用数据库?

我创建了一个sql脚本来检查数据库是否已经存在,如果它已经存在则会删除并重新创建.之后我想创建表后直接连接它来创建表..

这是我的代码,但它不起作用.他宣布了一条错误消息

消息911,级别16,状态1,行10数据库'Arms2'不存在.确保正确输入名称.

我的剧本

IF EXISTS (select * from sys.databases where name = 'Arms2')
BEGIN 
    DROP DATABASE Arms2
    PRINT 'DROP DATABASE Arms2'
END
    CREATE DATABASE Arms2;
    PRINT 'CREATE DATABASE Arms2'

USE Arms2

CREATE TABLE .....
Run Code Online (Sandbox Code Playgroud)

sql t-sql database sql-server bdd

3
推荐指数
1
解决办法
3043
查看次数

如何在中心XNA处旋转3D立方体?

我尝试从中心而不是边缘旋转3D立方体.这是我使用的代码.

public rotatemyCube()
{
    ...
    Matrix newTransform = Matrix.CreateScale(scale) * Matrix.CreateRotationY(rotationLoot) * Matrix.CreateTranslation(translation);
    my3Dcube.Transform = newTransform;
    ....


public void updateRotateCube()
{
    rotationLoot += 0.01f;
}
Run Code Online (Sandbox Code Playgroud)

我的立方体旋转很好,但不是从中心旋转.这是一个解释我的问题的示意图. 在此输入图像描述

我需要这个: 在此输入图像描述

我的完整代码

private void updateMatriceCubeToRotate()
    {
        foreach (List<instancedModel> ListInstance in listStructureInstance)
        {
            foreach (instancedModel instanceLoot in ListInstance)
            {
                if (my3Dcube.IsAloot)
                {

                    Vector3 scale;
                    Quaternion rotation;
                    Vector3 translation;
                    //I get the position, rotation, scale of my cube
                    my3Dcube.Transform.Decompose(out scale,out rotation,out translation);


                    var rotationCenter = new Vector3(0.1f, 0.1f, 0.1f);

                    //Create new transformation with new rotation
                    Matrix …
Run Code Online (Sandbox Code Playgroud)

c# xna transform rotation matrix

3
推荐指数
1
解决办法
3308
查看次数