.NET Programming





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

C# project needing to disable TLS1.0 and 1.1.

I have a c# project running under an application pool of .net 2. I am under the assumption that in order to upgrade to TLS 1.2, we should be using .net 4 as the app pool as well as installing the most recent SQL driver. Is this true?

We are under a deadline from our payment gateway to disable TLS1.0 and 1.1. However when I disabled TLS 1 and 1.1, we got the following error. We are currently working on a new upgraded version of the app, but I don't think it will be ready in time for the deadline of our payment gateway, so I need a stop gap until we can finish the new app that uses .Net 4.5.

Is there a way to use TLS 1.2 for the payment gateway communication only? Or is this a server wide setting?

[HttpException (0x80004005): Unable to validate data.]
   System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo, Boolean signData) +4359547
   System.Web.UI.Page.EncryptStringWithIV(String s, IVType ivType) +155
   System.Web.Handlers.AssemblyResourceLoader.FormatWebResourceUrl(String assemblyName, String resourceName, Int64 assemblyDate, Boolean htmlEncoded) +68
   System.Web.Handlers.AssemblyResourceLoader.GetWebResourceUrlInternal(Assembly assembly, String …
Hello Experts,
Below is my line of code in web.config file.  I have been asked to send the Cookies in SSL.  What should I do?  

Many thanks in advance.

    <sessionState mode="InProc"
                              sqlConnectionString="data source=xxx.x.0.1;
                              user id=sa;password="
                              cookieless="false" timeout="300" />
Hello. I have a page where I have images floated to the right.  But the image that comes before the bullet list pushes the text up or down on the page and leaves a bunch of white space.  Can someone tell me how to fix it? My code is below.  The problem is with the image named campusPic.jpg:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="heels2.aspx.vb" Inherits="heels2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="/igc.ms.styles.css?ver=1" rel="stylesheet" type="text/css" /> 
    <link href="/core.css?ver=1" rel="stylesheet" type="text/css" /> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous" />
    <link rel="stylesheet" href="css/styles.css" media="screen" />
    <link href="https://fonts.googleapis.com/css?family=Shrikhand" rel="stylesheet" />
    <script type="text/javascript" src="/js.js?ver=1"></script>
    <form id="form2" runat="server">

<%--<div style="width: 100%; height: 169px; background-image: url('http://localhost:51150/images/headerBg.gif');">--%>
<div style="width: 100%; height: 169px; background-image: url('/images/headerBg.gif');">
   <table cellpadding="0" cellspacing="0" border="0" width="960" align="center" runat="server" id="Table2" style="">

Open in new window

Dear Experts,
 I'm using .NET C# with Oracle Database, When start my application I got the following Server Error

Unable to load DLL 'OraOps12.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Exception Details: System.DllNotFoundException: Unable to load DLL 'OraOps12.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I am writing an network application.  I create many threads to go off and do stuff.  I need them to store data in a datatable that is bound to a datagridview.  

I am worried about being threadsafe.  

I've done a lot of googling for ideas and examples.  What I have come up with is the Producer-Consumer model with a threadsafe queue.  

Each Producer thread will store data into a threadsafe queue.  

A single consumer thread will pick records out of the queue (when available) and put them into the datatable that is bound to the datagridview.  

I in am a bit over my head here.  I am finding threading tough enough to learn (and just scraping by)

I've seen examples that are very different to each other, often over complicated and I am finding it tough to understand them and work out which way to do things.  Some are dependent upon .net features that are in newer versions of .net than I am targeting.  

Could someone please help me with a sample (with explanation) of how to do this.  

I have some ideas about how to write the producer (they could be wrong), but I don't know where to start with the consumer.  

There will be many producers, but a single consumer.  I am targeting .net 4.0 and using visual studio 2010 so that I can still work with some Windows XP machines.  

(yes I know that the XP machines should be retired, but they are separated from the internet and locked down a lot)

Thanks in advance
I am a .net C#/VB.net developer. I have done windows and web (mainly asp.net) application. Should I start learning MVC or asp.net core? Do I need to learn MVC first before .net core? Your help is greatly appreciated.
We're deploying an upgrade to our current system, upon launching the installer, the program/launcher gives us a message: "The application requires .Net Framework 4.5. Please install the .Net Framework 4.5 then run the installer again."

Is there any other way to install/upgrade our current .Net Framework installed?  Is there any alternative updates to consider.

We need your great minds here.

Thank you!

Server status:
Windows 2003 SP2
.Net Framework 4 Client Profile
.Net Framework 4 Extended
List AD User's group memberships in a listbox in Vb.net 2017.
Public Sub GroupprUser()
        Dim GroupDE As New DirectoryEntry("LDAP://CN=" & txtADBox.Text & ",OU=NAZ,OU=User Accounts,DC=one,DC=xxx,DC=xxx,DC=org")

        Dim Members As Object = GroupDE.Invoke("Members", Nothing) '<<< Get members

        For Each Member As Object In CType(Members, IEnumerable)  '<<< loop through members

            Dim CurrentMember As New DirectoryEntry(txtADBox.Text) '<<< Get directoryentry for user

            MessageBox.Show(CurrentMember.Name.Remove(0, 3))  '<<< Show each user's name in a messagebox
[embed=file 1266291]
Please help EE Thanks Guys

    End Sub

Open in new window

I am working with a REST data source.  Single row returns aren't a problem as I can deserialize them using something like:
 JsonConvert.DeserializeObject(Of myInstantiatedClass)(httpResponseContent)

Retrieving a data list isn't a problem either.  But I am unable to deserialize it (using Newtonsoft.Json) into a .NET LIST collection.   A view of the simplified data looks like:

Open in new window

I am using vb.net in this project but please feel free to send hints in c#!  I've tried various things including IEnumerate.  Simplifed snippet of the original code looks like this:
Public Class myClass
        Public Property id As String
End Class


 Dim myInstantiatedClass As New List(Of myClass)
        Dim response = Await client.GetAsync(Uri)
        If response.IsSuccessStatusCode Then
            Dim httpResponseContent = Await response.Content.ReadAsStringAsync()
                myInstantiatedClass = JsonConvert.DeserializeObject(Of List(Of InstantiatedClass ))(httpResponseContent)
            Catch jsonException As Newtonsoft.Json.JsonSerializationException
                Dim s As String = jsonException.Message
            End Try
        End If

Open in new window

The error code (using original variable and class names) reads:
"Cannot deserialize the current JSON object (e.g. {""name"":""value""}) into type 'System.Collections.Generic.List`1[BbRestApiExplorer.CourseGradeColumn]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly." 
"To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object." 
"Path 'results', line 1, position 11."

Open in new window

Any thoughts?   Thank you for your time.
I am cycling through a datgridview row to check for duplicates on Badge Numbers, "Clocked  IN" as well as datetime.
I would like to remove the rows once it finds duplicates, but for now, I add the row.index to a string and have a string "1, 3, 5"
Then recycle through the rows and remove the index after I break up the string.
Is there a more efficient way in this approach?

 Dim RowCount As String = ""
        For i = 0 To Me.DataGridView2.RowCount - 1
            If DataGridView2.Rows(i).Cells(8).Value = "Clocked IN" Then

                Dim LID As String = DataGridView2.Rows(i).Cells(0).Value
                Dim jb As String = DataGridView2.Rows(i).Cells(1).Value
                Dim BDG As String = DataGridView2.Rows(i).Cells(3).Value
                Dim CStat As String = DataGridView2.Rows(i).Cells(8).Value
                Dim Date1 As Date = DataGridView2.Rows(i).Cells(7).Value
                Dim d2 As String = Date1.ToString("MM/dd/yy")
                Dim j1 As Integer = Me.DataGridView2.RowCount - 1
                For Each row As DataGridViewRow In DataGridView2.Rows

                    If ((row.Cells(3).Value)) = BDG Then  ' Badge Numbers Agree

                        If (row.Cells(8).Value) = "Clocked OUT" Then ' Status is Clocked Out
                            Dim date2 As Date = row.Cells(7).Value ' Set Date2 to convert
                            If (date2.ToString("MM/dd/yy")) = d2 Then   ' Date Values equal out
I need a combination of best practices and a description of how the underlying exploitations of cross site scripting attacks work.

say I am making a web request from my controller to another third party site to get some data.
sample below, example contrived for this question.

The third party site may be down and not return data. in such case, I would like to make couple of more tries and error out if it doesn't succeed at all.

Question - what's the best way to do this. so that if there is no response data in the first call , I try it say , two more times and
then error out.

     var webClient = new WebClient(); 
     var response = webClient.DownloadString("http://xyz.com/content); 

      if(response != null){
            //do something 
      else {
             //error couldn't retrieve data

Open in new window

Hi All,

I'm interfacing with a bank API that requires a client certificate (signed by a third party CA) to be attached for certain requests (EG: initiating an ACH transaction).  My code will be deployed in the form of a DLL to multiple desktops within our office which can then be used by another windows application.  

So a few questions based around this:

Is it possible to configure all the clients to use the same hostname or does that present issues?  (We're natted, but we also have redundant internet connections so I'm worried about the source IP).

if it's just an X509 Certificate, is that the same thing as the coding certificate or is there some other kind of cert used for clients?

Best vendor for the kind of certificate needed?

Thanks in advanced.
I do not thing .NET Framework 3.5 was install by Visual Studio 2017, so I need to check which version are installed. Where do I look for that?

And how do I explicitly install .NET 3.5?

The following command and arguments run without any errors if they are run in a batch file.

"C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe" -e "C:\test_3\People_1.rpt" "Export_Format:Adobe Acrobat (pdf)" "Export_File:C:\test_3\People_1.pdf"

Open in new window

However, Visual Cut returns an error when the code shown below is run. The code runs in Visual Studio without any errors.

Batch File:
"C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe" -e "C:\test_3\People_1.rpt” "Export_Format:Adobe Acrobat (pdf)" "Export_File:C:\test_3\People_1.pdf"

Open in new window

VB App:
        Dim retval As String
        Dim ls_temp As String
        ls_temp = "C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe " & _
"-e ""C:\test_3\People_1.rpt "" ""Export_Format:Adobe Acrobat (pdf) "" ""Export_File:C:\test_3\People_1.pdf"""
        retval = Shell(ls_temp)

Open in new window

Visual Cut Error:
[C:\test_3\People_1.rpt ]: Requested Export Format (Not recognized) is not Supported.: 1/24/2018 3:04:17 PM

The batch, Visual Cut and VS are on the same machine. I've checked the paths several times. I am the admin user.

Please help me find the error.
I want to change printer setting by programically in VB.net how I can make this. I search google I find one code this code appear the printer in combo box but not open the settings.
Pls help......
Hello. I have a simple .net site with just a few pages and links.  The problem is that the page shows up fine in Chrome and Firefox but in IE 11 it isn't showing my CSS styles.  Seems like it isn't reading my CSS files.  

Here is my head where I link to bootstrap and my stylesheets.
<head runat="server">
    <link href="/igc.ms.styles.css?ver=1" rel="stylesheet" type="text/css" />
    <link href="/core.css?ver=1" rel="stylesheet" type="text/css" media="all" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous" />
    <link rel="stylesheet" href="css/styles.css" media="screen" />
    <link href="https://fonts.googleapis.com/css?family=Shrikhand" rel="stylesheet" />
    <script type="text/javascript" src="/js.js?ver=1"></script>

This is my header and nav bar that are on every page.  None of these styles will display in IE 11
<div style="width: 100%; height: 169px; background-image: url('http://localhost:51150/images/headerBg.gif');">
   <table cellpadding="0" cellspacing="0" border="0" width="960" align="center" runat="server" id="Table2" style="">
         <td style="height: 131px;" valign="top">
            <a href="/" class="noBorder"><img src="/images/logo.gif" height="112" width="340" alt="The Carolina Institute for Developmental Disabilities at…
I have an older ASP.NET Core Web API developed in Visual Studio 2017, targeting .NET Framework 4.5.2 and utilizing Microsoft.AspNetCore 1.1.2 and Microsoft.AspNetCore.Mvc 1.1.3.

In that project, I have a controller method that returns an IActionResult with lines like this, which work fine:

return Unauthorized();

return NotFound();

return Ok();

Open in new window

Similar to the discussion here:


I am currently creating a new web API in VS 2017 targeting .NET Framework 4.6.1 and ASP.NET Core 2.0, using Microsoft.AspNetCore 2.0.1 and Microsoft.AspNetCore.Mvc 2.0.2.  In this new project, the same lines have a compilation error.

CS0103      The name 'Unauthorized' does not exist in the current context

VS provides recommendations to change these to:



Was this a breaking change made in Core 2.x?  Or am I missing a package or dependency in my new project?  If I use UnauthorizedResult(), I get an error that it cannot be used like a method.

If this is a change, I can't seem to find any documentation about it.
Is it possible to be on a live page and "debug" the script below?

    function SaveValidation() {
        var surveydata = "";
        $('.rblsurvey').each(function () {
            var checked_radio = $("[id*=" + $(this).context.id + "] input:checked");
            var value = checked_radio.val();
            var question = $(this).context.className.replace("rblsurvey rblMultiList_", "");
            surveydata = surveydata + question + "," + value + "|";

        $(".chks").each(function (index) {
            var questionid = $(this).attr("class").replace("chks chkquestions_", "");
            var answerid = "";

            $(this).find(":checked").each(function (index) {
                answerid = questionid + "," + $(this).val() + "|" + answerid;


Open in new window

Hi ,
Thanks !
Am using linqtosql and C#.

Have attached the screen shot of the datasource .
I need to order the list by name,  (Screen shot is attached ) but name is alphanumeric string. Each record under name starts with section ??:  i.e. Section 12 : test
                          Section 11: test
                          Section 00: test

I need to order by name by sort through numbers which you see  within the string

Expected output:
{Folderkey=27, Name="Section1:Underwriting"}
{Folderkey=25, Name="Section2:Third-Parth Reports"}
{Folderkey=4, Name="Section3:Borrower"}

public ActionResult FolderRearrangePopupLoad(Guid taskInstanceId, string Model)
            var nums = "0123456789".ToCharArray();//skumar:20180104 for task#
            var reordermodel = new FileReorderModel { TaskInstanceId = taskInstanceId };

            var FileList = (from filelist in taskManager.GetAllTaskFileByTaskInstanceId(taskInstanceId)
                            select new
                                Name = filelist.FileName


            ViewBag.FileList = FileList;

            var folderlist = (from folders in appProcessManager.GetFolderbyViewId(1)
                              orderby folders.FolderName.LastIndexOfAny(nums)
                              orderby folders.FolderName

Open in new window


We are currently in the first stages of extensive application rewrites from Access VBA & Access Databases to C#.Net & SQL Server databases, and I have a general question regarding the use of structured error/exception handling.

I am used to the unstructured handling that is part of VBA, and can see that the offerings of C#.Net are far more powerful. I have done a lot of reading, but am struggling to find any examples with enough meat on them to clearly demonstrate what the authors are talking about. They are fast and free with what to do and not do, but there are rarely any solid examples to back up the text.

It is clear that I should be shot without question if I catch a general Exception, and that a routine should catch & handle errors that it's own code causes, but errors caused by external factors should just be passed back (bubbled up I think the phrase is), but my question is this:

If your routine uses a function such as opening a file the name of which is passed as a parameter, should it trap every possible exception that is returned by the File.Open in a specific catch block, or is this overkill?? Should it only handle the IOException and then bubble up exceptions that are to do with invalid filename or directory as it was not responsible with generating the filename/path??

I know this is a basic question, but I want to be sure to get the exception handling right at the start of this long path rather than set off along the wrong route and have to …
My understanding of static class or member is that , we have only one copy.
consider following class with static members, say I have multiple instances of class Foo and I try to call static methods or access static member.  doesn't it run into race condition?
or in other words , do we have to worry about race conditions, when we create static class or static members?

var one = new Foo();
var two = new Foo();
var three = new Foo();

public class Foo{
    private static string = "foo";
    public int GetCount() {
       //return count;
I have a program which shuffles messages from a source to a queue.

Then it has another background thread running an endless loop which waits for a message to be added to the queue, then pulls that message from the queue and moves it to somewhere else.

Should that background thread be started using Task.Run() or Thread.Start()?

I don't really know how busy that background thread will be. It might be waiting most of the time for a new message to come; or messages might be coming so fast it doesn't have much time to wait.

This background thread will be running for quite a long time, as long as the user has that window open.

(Perhaps there's a third option I haven't thought of?)
Using following codes, I cannot detect problem to Email address. Why?
                <asp:TextBox ID="tb_email"
                    runat="server" />
        bool IsValidEmail(string email)
                var addr = new System.Net.Mail.MailAddress(email);
                return addr.Address == email;
                return false;
        protected void email_post_change(object sender, EventArgs e)
            string email0 = tb_email.Text;
            if (!IsValidEmail(email0))
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowMessage('电子邮件地址格式有问题。')", true);

Open in new window

I have a form that creates checkboxlists dynamically

Can I add a click even on each "node" so that it updates a hidden control with...
hdnFld.Value =s hdnFld.Value + id + ","

I want to do this on each check or uncheck
Either with the  rblMultiList or  rblMultiList.Item is fine

And I want to do this server side if at all possible

I cannot get my client side loop to work and am frustrated in the extreme

  Dim rblMultiList As New CheckBoxList
                            'dropdownlist.Width = 200		
                            rblMultiList.Style.Add("Width", "70%")
                            rblMultiList.RepeatDirection = RepeatDirection.Horizontal
                            ' rblMultiList.CellPadding = 2		
                            'rblMultiList.CellSpacing = 2		
                            rblMultiList.AutoPostBack = False
                            rblMultiList.ID = "rblMultiList" & dS.Tables(0).Rows(j)("PromotionSurveyQuestionID")
                            rblMultiList.CssClass = "chks chkquestions_" & dS.Tables(0).Rows(j)("PromotionSurveyQuestionID")
                            Dim selected As String = ""
                            Dim sss As String = ""
                            Dim dtview As New DataView(dS.Tables(1))
                            dtview.RowFilter = "PromotionSurveyQuestionID=" & dS.Tables(0).Rows(j)("PromotionSurveyQuestionID").ToString()
                            If dtview.Count > 3 Then

Open in new window


.NET Programming





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.