.NET Programming

134K

Solutions

39K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

Share tech news, updates, or what's on your mind.

Sign up to Post

Does double data type overflow in C# language?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            double max = double.MaxValue;
            double min = double.MinValue;
            Console.WriteLine($"The range of double is {min} to {max}");

            double what = max + 3000;
            Console.WriteLine(what);

            // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app! 
        }
    }
}

Open in new window


output is attached.   Why there is no overflow?
0
Python 3 Fundamentals
LVL 13
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

CRM 2011 upgrade

We are trying to upgrade a CRM 2011 system however the IT group will not allow us to use production data in dev to test the upgrade.  Does anyone have experience working with very confidental data that cant be shown to most users?  

I have worked on some projects where we wrote an encrypt/decrypt program to make the data anonymous during the upgrade and then it was decrypted afterwards when in the new system.

Any suggestions would be helpful.
0
Hi

I have an ASP.net website that I built in Visual Studio 2017. Can I control which .net framework it is published in?
My hosting company only supports up to 4.5

Thanks
0
Hi

I have an Excel VB.net Add-in project that interacts with an Azure SQL database using a connection string.
I want to control which tables a user can see and edit.
What is the best way to do this. Should it be set up inside the Azure  SQL database per user name
and then a different connection string given to various people?

Thanks
0
Hello ,
 I TEST it with WEB API using POSTMAN it give DATA as empty : Please suggest.

API URL:
http://localhost/school/Student/getStudentList

Result
{
    "Message": "Data Received successfully",
    "Status": true,
    "Data": [ ]
}

Open in new window



Below is the code pattern i am trying :

Models
public class Student
{
    public int StudentId { get; set; }
    public string ClassName { get; set; }
    public int LocationId { get; set; }
}

public class ResponseModel
{
    public string Message { set; get; }
    public bool Status { set; get; }
    public object Data { set; get; }
}

Open in new window


Service Method
public ResponseModel LoadStudents (SqlCommand comm)
{
    ResponseModel _objResponseModel = new ResponseModel ();
    List<Student> students = new List<Student> ();
    Student rls = new Student ();
    comm.CommandText = "Select StudentId,ClassName,LocationId from Students";
    SqlDataReader dr = comm.ExecuteReader ();

    while (dr.Read ())
    {
        rls.StudentId = dr.GetInt32 (0);
        rls.ClassName = dr.GetString (1);
        rls.LocationId = dr.GetInt32 (2);

        students.Add (rls);
    }

    dr.Close ();

    _objResponseModel.Data = students;
    _objResponseModel.Status = true;
    _objResponseModel.Message = "Data Received successfully";

    return _objResponseModel;
}

Open in new window


Action
[Route ("school/Student/getStudentList")]
[HttpGet]
public HttpResponseMessage GetStudentList ()
{
    UserRectification rtg = new UserRectification ();
    ResponseModel _objResponseModel = new ResponseModel ();
    HttpResponseMessage msg;

    try
    {
        _objResponseModel = LoadStudents (comm);
        msg = Request.CreateResponse (HttpStatusCode.OK, _objResponseModel);
    }
    catch (InvalidOperationException ioe)
    {
        msg = Request.CreateResponse (HttpStatusCode.BadRequest, ioe.Message);
    }
    catch (Exception ex)
    {
        msg = Request.CreateResponse (HttpStatusCode.InternalServerError, ex.Message);
    }
    finally
    {

    }

    return msg;
}

Open in new window

0
I'm very new to MVC5 using razor. I've been able to stumble through some problems but I'm stuck now. Here's what I need to do:

  • Move items from one listbox control to another listbox control
  • Access/get the items from both list boxes at some point in time for processing

my model contains the following:

        public IEnumerable<SelectListItem> AllAvailableServices { get; set; }

        public IEnumerable<string> AllAvailableSelectedServices { get; set; }

		public IEnumerable<SelectListItem> AddedServices { get; set; }

		public IEnumerable<string> AddedSelectedServices { get; set; }

Open in new window


my view contains the following. I would like to access the items in the AddedServices list when the user clicks the "Submit" button

@using (Html.BeginForm("Category", "Manager", FormMethod.Post))
{
    <table class="contain">
        <tr>
            <td>
                <table class="nav">
                    <tr class="nav">
                        <td class="navLeft">
                            <input type="submit" value="Submit" name="btnSaveCategory" class="button" onclick="location.href = '@Url.Action("UpdateCategoryAndServices")'"/>
                            <input type="button" value="Back" name="btnBack" class="button" onclick="location.href = '@Url.Action("Back")'"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
.
.
.
            

Open in new window

0
Where can I find a list of known weaknesses and workarounds of the CLR?  I've seen examples below through googling, but was wondering if there is one repository listing these things.


One thing I've come across is that no single object can be more than 2GB.  A new workaround is in .NET 4.5 called gcGetVeryLargeObjects.


Memory Leaks Due to Unused Objects that are Still Referenced.  If a program never refers to an object again, but there is some path leading to that object then the Garbage Collector does not release its memory.
Another very well known limitation of .NET is its large object heap. If an object becomes part of this heap, the runtime does not move it. This can lead to a program running out of memory prematurely. When Garbage Collector collects a large object from this large object heap, it can also leave behind holes in the heap, thereby causing the free space to become fragmented.
There are also garbage collection pauses.
0
This line of code should bring back 1 but I don't know why it's bringing back 2

frm.MultiValue.ActiveButtonCount = Convert.ToInt32(rd["ActiveButtonCount"] ?? 2);

Open in new window


I see the value is 1.
ee1.png
but it comes out as 2

ee2.png
0
I used open source Packet Capture(Pcap) and Wireshark to view video sent by USB Device.  The device sends 512 Bytes packet about every 200 us.  It's a composite device class.  It's a virtual port and bulk video.  Each monochrome raw frame is 640 x 480.

There is a GUI tool that runs in windows that extracts video from this USB device and plays video on the PC.  The company who wrote this GUI tool gave us the source code.  I opened this source code into Visual Studio 2017 Professional version without creating a solution or project.  There are Sixteen projects in this codebase.

The code is in C Sharp.  How do I find out if this codebase will build?  I didn't see any makefiles in this codebase.  Do I need to make any changes to build it?  Do I build project at a time?  How to find out if it's complete solution or just libraries?
0
Hello Experts
I have an old application (VB6) running on Windows 10 x64
The program works fine after installation until I restart the PC
Then the program refuses to work until I remove it and re-install it again. And also to reboot the device and so on.
the error message ( Unsupported value type:1001:error)
0
CompTIA Security+
LVL 13
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Architecture advice

So from a full pipeline infrastructure to develop and then deploy a web application what would you all recommend as best practice.

The items I do know at this point is I will be using the latest .net and angular frameworks for the application.  There will be a SQL backend.

My company wants this application to be deployed using CI/CD techniques.

We will have an Azure storage along with utilizing Docker.

I dont know much more but wanted to get an idea of what this architecture should look like as a developer.

I would imagine working locally in visual studio...perhaps there are some item you need to think about upfront for .net and angular apps while developing knowing that you will push to azure via a docker container.

Also at this point should I be thinking about .net versus .net core.

I plan on watching some videos and doing more reading but wanted to start with this as a place to get ideas of how this should be setup at a high level
from the architecture point of view dev through test and prod.
0
Hello,
I am trying to build a microservice with MVC connecting to MySQL . Any suggestions on how to go about.
Thanks
0
I'm getting the following error when I added this line of code within my using statement, I can't use the ref cmd. Trying to find a solutions to it...

                query += query + Environment.NewLine + (xxx.Tools.AdvanceOptionsQueryBuilder.BuildAdvanceOptionsQuery(ref cmd, SearchCriteria.AdvanceOptionsData));

        query += Environment.NewLine + "group by "+ 

                using (var cmd = DatabaseService.CreateCommand())
            {
                var systemCultureInfo = xxx.Parameters.ParameterConfigurationService.GetSystemCultureInfo(cmd);
                cmd.Parameters.Clear();


                cmd.CommandType = CommandType.Text;
                query += query + Environment.NewLine + (xxx.Tools.AdvanceOptionsQueryBuilder.BuildAdvanceOptionsQuery(ref cmd, 
              SearchCriteria.AdvanceOptionsData));

                cmd.CommandText = query;

Open in new window

0
Greetings

I am converting an old VB6 program to VB.NET. I have a lot of it converted and working.. However I occasionally run into situations that elude and I need additional assistance. I am at another one of those junctures.

I am now working on the FTP portion of my code. Admittedly the previous VB6 code only required the 'DownLoad' properties and so it has worked fine for many years. I googled several  solutions but I am still having trouble getting files up to my server.  I can access the server with FileZilla and I can also upload files from a 'Command Window' via FTP as well. The code I currently have fails with the Following error: "System.Net.WebException: 'The remote server returned an error: (553) File name not allowed.'" I am using Visual Studio 2017 Express.

The files I am trying to upload are image .JPG files and the names of the files are all digits except the extension. Maybe someone can spot where I went wrong...

Thanks
-------------------------------

'############################################################################################################################
        Dim ftpRequest As FtpWebRequest = CType(WebRequest.Create("ftp://www.verilynx.com/home/vasylum/www/UPCCodedImages/" + ThisUPC + ".jpg"), FtpWebRequest)

        ftpRequest.Method = WebRequestMethods.Ftp.UploadFile

        ' Confirm the Network credentials based on the user name and password passed in.
        ftpRequest.Credentials = New 

Open in new window

0
Hello Experts,

What is the difference between Tasks vs Threads.
0
Hello Experts,
What is the difference between string and String

Thanks
0
I am trying to use Data Annotations and regex to validate an address field in a .net MVC application (to disallow the word 'suite' in any form).

I have the following definition in my annotations class:
 
    [MetadataType(typeof(LocationMetaData))]
    public partial class Location
    {

    }

    public class LocationMetaData
    {
        [RegularExpression(@"^(?:(?!\bsuite\b).)*$/ig", ErrorMessage = "Invalid Street1 format - Enter suite information in Street2")]
        public String street1 { get; set; }
    }

Open in new window


...which should only match when the string does not contain 'suite'.

I am getting the failed error message no matter what I enter in the field.

I have tried these variations on the Regex:
^((?!suite).)*$/ig
/^((?!suite).)*$/ig
/^((?!\b(\w*suite\w*)\b).)*$/ig

These all work in online regex testers, but fail in my app.

Does anyone have a working solution for this?

Thanks.
0
Hello,

What is the coding difference between c# and vb.net.
I am looking from syntax point of view.
Any suggestion are appreciated.

Thanks
0
Hi,

First of all, I think I understand what an extension method and how it used it.  However, the following code confuses me.
I have "ToDoPerTime.cs" class as below.

public interface PerTime<T>
    {
        T Morning { get; }
        T Lunch { get; }
        T Evening { get; }
    }
    internal struct TestProperties
    {
        public string Eat;
        public string Work;
        public string Sleep;
    }
    public enum TimeName
    {
        Morning,
        Lunch,
        Evening
    }
    [b]public static partial class PerTimeExtensions[/b]
    {
        public static T GetSettings<T>(this PerTime<T> perTime, TimeName time)
        {
            switch (time)
            {
                case TimeName.Morning: return perTime.Morning;
                case TimeName.Lunch: return perTime.Lunch;
                case TimeName.Evening: return perTime.Evening;
                default: throw new NotImplementedException();
            }
        }
    }
    class ToDoPerTime : PerTime<TestProperties>
    {
        public static ToDoPerTime Instance = new ToDoPerTime();
        public ToDoPerTime() { }
        public TestProperties Morning => new TestProperties
        {
            Eat = "Eggs",
            Work = "123",
            Sleep = "on the bed"
        };

        public TestProperties Lunch => throw new NotImplementedException();

        public TestProperties Evening => throw new NotImplementedException();
    }

Open in new window


And in UnitTest1.cs class, I use the extension method as below.

[TestClass]
    public class UnitTest1
    {
       [b] private readonly static TestProperties myProperties = ToDoPerTime.Instance.GetSettings(TimeName.Morning);[/b]
        [TestMethod]
        public void TestMethod1()
        {
            Console.WriteLine(myProperties.Eat);
        }
    }

Open in new window


These are my questions:
1. Why do we use partial class here to create an extension method?
2. I don't understand this part.
ToDoPerTime.Instance.GetSettings(TimeName.Morning);

Open in new window

The extension method GetSettings is inside "PerTimeExtensions" class. But it's using "ToDoPerTime" class.
ToDoPerTime.Instance instantiate ToDoPerTime class, right? But it then can access to the extension class in a different class?
I've seen the  partial classes using the same class name with different file names, but not like this.

Can anybody explain what's going on with this code?
0
Microsoft Azure 2017
LVL 13
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Reallocating space on my MacBook's 500 GB drive to make room for Azure, Linux and Windows 10

I have a 500 GB drive that's almost filled, but I have allocated 100 GB to my Windows 7 / Parallels (10.4) partition. This "partition" is represented in the form of a file:

Windows 7 (1).pvm

I expect I would upgrade to Parallel's version 14. I NEED to replace Windows 7 with Windows 10. And MAY install Linux, if I need to, to fully use Azure and Containers.

So, how do I create a partition for Linux? Is that something I do also with Parallel's. How much space shall I leave for that?

Any suggestions would be appreciated.

Thanks
0
I have a bunch of html files in a directory
I need to locate a number of divs within these html files based on the div id
I don't know which html file contains a given div id

So rather then searching every file multiple times I thought about creating a regular expression for all wanted   div id open each file once then  do a patten match
Once I've located which file contains  a given div id  I can then pass the html string into a HtmlAgilityPack.HtmlDocument

My regEx isn't working  (Manuel search shows the fist div in the list is  in the first html file opened)
Pids.jpg
from the pic
The Regex PidsReg = {post_message_1234|post_message_5678| etc

Sample of code I nether get to match success

..........
                string[] folders = Directory.GetDirectories(RootDir, "*", SearchOption.TopDirectoryOnly);
                String Pids="";
                foreach (string folder in folders)
                {

                    FileInfo FI = new FileInfo(folder);
                    string DirectoryName = FI.Name;
                    Match DirNameMatch = DirNameReg.Match(DirectoryName);
                    if (DirectoryName.Contains(DirTextBox.Text) && DirNameMatch.Success)
                    {
                        string PID = "post_message_" + DirNameMatch.Groups[0];
                        Pids += PID + "|";
                    }
                }
                if (Pids != "")
                {
                    Pids = 

Open in new window

0
I am starting to use vbconversions software to translate some of my vs2008 vb.net projects over to c#.  These vb.net projects have been running for years on Symbol/Zebra scanners, and vs2008 is as high as I can go while developing apps for these devices.

vbconversions software is a paid subscription, and so far seems to do a very good job.  In the most recent conversion, I'm getting two errors that I need help with.

The vb.net code I've been using to play .wav files is:

    'This is the setup to make the PlaySiren sub work, to play a .wav on the scanner for errors...
    Public Class win32
        Public Declare Function PlaySoundW Lib "coredll.dll" Alias "PlaySoundW" (ByVal lpszName As String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer
        Public Const SND_FILENAME = &H20000
        Public Const SND_ASYNC = &H1
        Public Const SND_SYNC = &H0
    End Class

...and there is a line at the top of the module that says "Imports System.Runtime.InteropServices".

Someone gave me this code years ago to play .wav files on the scanners, but I must admit I don't understand what all is being done here or how this works.  I may have come from an e-e contributor long ago.

Then when vbconversions did the translation to c#, it created this code:

            //This is the setup to make the PlaySiren sub work, to play a .wav on the scanner for errors...
            public class win32
            {
                  [DllImport("coredll.dll",EntryPoint="PlaySoundW", …
0
Anybody installed Visual Studio 2019 yet?

I plan to instal it in prep for a code camp, and wonder who else has it running.

Let me know.

Thanks
0
Hello,

I am using .net, 4.6.1 MVC web application to have the user login into external authentication (Office 365 for now). I am able to sign-in but unable to set the claims and my Request.IsAuthenticated is always false.

Unable to hit this code.
Provider = new MicrosoftAccountAuthenticationProvider
                {
                    OnAuthenticated = async context =>
                    {
..
..
}

Open in new window


Please advice.

Thanks.
AccountController.txt
Startup.txt
Login.txt
0
How uninstall old version of .net framework and install new version with logging into user devices
0

.NET Programming

134K

Solutions

39K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.