[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


.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

How do I install .Net 4.6 / 4.7 on to SBS 2008r2 so I can upgrade Sage Account v23 to v24
OWASP: Threats Fundamentals
LVL 12
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.


I have found the following code to render an SSRS via a SSIS script. This script works as it is intended, e.g. saves the rendered report to disk.

But I would like to send the rendered report as an email attachment, without saving it to disk. Please could someone help? I have tried to render it to a memory stream but I can't quite get it to work.

Thanks, Greg

 Protected Sub SaveFile(ByVal url As String, ByVal localpath As String)
        Dim loRequest As System.Net.HttpWebRequest
        Dim loResponse As System.Net.HttpWebResponse
        Dim loResponseStream As System.IO.Stream
        Dim loFileStream As New System.IO.FileStream(localpath, System.IO.FileMode.Create, System.IO.FileAccess.Write)
        Dim laBytes(256) As Byte
        Dim liCount As Integer = 1
            loRequest = CType(System.Net.WebRequest.Create(url), System.Net.HttpWebRequest)
            loRequest.Credentials = System.Net.CredentialCache.DefaultCredentials
            loRequest.Timeout = 600000
            loRequest.Method = "GET"
            loResponse = CType(loRequest.GetResponse, System.Net.HttpWebResponse)
            loResponseStream = loResponse.GetResponseStream
            Do While liCount > 0
                liCount = loResponseStream.Read(laBytes, 0, 256)
                loFileStream.Write(laBytes, 0, liCount)
        Catch ex As Exception
        End Try
    End Sub

Open in new window

I have an <asp:label id="brandName" runat="server"/> in my aspx page in an asp.net website.

in the cs page, i populate the text of this label , depending on certain value .

   if( somecondition) {
       brandName.Text = "somebrandname" ;
   else {
           brandName.Text = "someOtherName" ;

I want to add trademark (TM) at the end of the brandname text .

how can i do this?

Using the XML file bellow as a log I'm gathering information about TV shows using TMDB api (Not part of question just background)

How do I access each show name and its childs episodes details?

Ultimately I want to be able to access a  Episode path and if doesn't exist in the xml create a new entry or parent show

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

namespace XmlReader
    class Program
        static void Main(string[] args)
            XmlDocument xmlDoc = new XmlDocument();
            XmlNodeList Nodes = xmlDoc.SelectNodes("TV/Show");
            for(int I =0; I <= Nodes.Count; I++)
                Console.WriteLine(Nodes[I].Name); // This throws an error 


Open in new window


<?xml version="1.0"?>
      <Name>MacGyver 2016</Name>
      <FolderName>MacGyver 2016</FolderName>
      <FullPath>J:\Media\TV\MacGyver (2016)\S03\Macgyver.2016.S03E01.Improvise.mp4</FullPath>

Open in new window

I'm assuming I would create a new episode by appending to it's parent show (something like bellow) but how do I find the correct show / season
Similarly How do create  a new show?

XmlNode EP = xmlDoc.CreateElement("Episode");
            XmlNode EpNum = xmlDoc.CreateElement("EpisodeNumber");
            EpNum.Value = "2";
            // repeate for each element

Open in new window

1. I want to add the compare checkbox under the item. When user checks the checkbox, the image will be added to the bottom  of the comparing area. The following code does not work. Please advise!
2. How to add the Compare link to the comparing area, which will be linked to the page with the four compared products. Click each product and then linked to the product page.  

Thank you!
<%@ Page Language="VB" %>

<script language="vb" runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
Dim strSQL

.empty-border {
  padding-bottom: 100%;
  border: 1px dashed #9c9c9c;

#compare-box-products {
  box-shadow: 0 1px 2px 2px rgba(0, 0, 0, .2);
  background-color: #fff;
  position: fixed;
  right: 0;
  bottom: 0;
  width: 558px;
  padding: 10px;
  pointer-events: all;
  display: none;

.empty-border {
  width: 110px;
  height: 110px;

.compare-image-container img {
  width: 108px !important;
  height: 108px !important;
  border: 1px dashed #9c9c9c;


<body >

<div class ="grid-top-spa"><asp:Label runat="server" ID="lblMessage" /> </div>

 <asp:DataList ID="compare"
									           borderstyle= "none"

Open in new window

When starting to type in keyword e.g. FUR in the search box,  you will see dropdown list from the textbox  with furniture or fur or something related with fur even with pictures.
How to accomplish it? Thank you!
The folder name is labeled by ID. If the idProduct is 3, the folder is 3. In folder 3  there are three images, and in folder 4, there are 2 images, but in folder 6 there are 7 images.  

In the coding as below, the images for idproduct 3 and idproduct 4  will be displayed as X (no images) starting from image 4 and image 3 separately. How to modify the coding?  Thank you!

<ul id="carousel" class="jcarousel jcarousel-skin-tango">
<li><a href="#" rel="p1"><img src="images/small/<%=idProduct%>/1.jpg" /></a></li>
<li><a href="#" rel="p2"><img src="images/small/<%=idProduct%>/2.jpg" ></a></li>
<li><a href="#" rel="p3"><img src="images/small/<%=idProduct%>/3.jpg" ></a></li>
<li><a href="#" rel="p3"><img src="images/small/<%=idProduct%>/4.jpg" ></a></li>
<li><a href="#" rel="p3"><img src="images/small/<%=idProduct%>/5.jpg" ></a></li>
<li><a href="#" rel="p3"><img src="images/small/<%=idProduct%>/6.jpg" ></a></li>
<li><a href="#" rel="p3"><img src="images/small/<%=idProduct%>/7.jpg" ></a></li>


Open in new window

Thanks for the expert Zakaria's prompt advice!
I followed his example, but still have some issues.
 It works perfectly if the image is listed individually. When the checkbox is checked, the image is added to the comparing area
 <div class="col-sm-4 col-md-3">
          <div class="thumbnail">
 <div class="thumbnail-img">
              <img src="images/1.jpg" width="150" height="150" class="img-p1">
              <h3>Product 1</h3>
              <p>10 $</p>
              <p><input type="checkbox" class="p1"> Compare Product

Open in new window

But if add to the datalist area, it does not work. When checking the checkbox, it does not do anything.  
<asp:DataList ID="compare"
									           borderstyle= "none"
									           runat="server" HeaderText="" HeaderStyle-BackColor="#fff" HeaderStyle-ForeColor="#FFFFFF" HeaderStyle-Font-Bold="true">


		<td> <a href="products.aspx?id=<%# DataBinder.Eval(Container.DataItem, "idProduct") %>">
        <div class="thumbnail"> <div class="thumbnail-img"><img src="images/<%# DataBinder.Eval(Container.DataItem, "idProduct") %>.jpg" class="img-p1"> </div></a>


 <tr><td><input type="checkbox" class="p1"> Compare Product</td></tr>

Open in new window

Lastly how to add the Compare link to the comparing area, which will be linked to the page with the four compared products. Click each product and then linked to the product page.  Per the attached image.
I have a .Net developer creating a DLL that we are going to Reference in an Access VBA application.  However, whilst we can see the DLL methods (once referenced), he is struggling with a couple of aspects such as passing variables through and how best the code the .DLL so that Intellisense works as expected.

Whenever I have worked with external references in the past, I usually access them like this (rough example):

Dim obj1 As New TSDialler.Dialer
obj1.SignalKey = "ABC123456"
obj1.TelephoneDestination = "0123456789"
obj1.InternalID = "ZYX987"
If obj1.MakeCall = 1 Then
    MsgBox "Call made"
    MsgBox "Call not made.  Error: " & obj1.ReturnMessage
End If

Open in new window

However, he has never worked in VBA and is struggling with the various aspects.  His list of questions is below, but I was wondering if anyone had any links/suggestions for him to look at (more than just answering his questions).

Which kind of methods works?
Do properties work?
Constructors work, what about parameters?
How to do event pattern for a custom class and not UI control?
What pieces (that we use regularly) in C# that does not work with VBA when referenced?
Any article/doc that can be referred that has details for questions like above?

Any help would be greatly appreciated - sorry it's so vague.
I have a request form.  I want to let the user attach the file and send it out with the request. Please advise! Thank you!
Exploring ASP.NET Core: Fundamentals
LVL 12
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Hi experts,  I have a page, where I want to display the images of the products. I do not want to restore the images in the database, but in the folder.
Currently I have a problem. Since some of the products have one or two images, and some of the products have more than 2. Per the code below,  if the products have less than 5 images, the image folder which do not have 5 image will be displayed as X (no image).  How to fix it? Thank you!

<ul id="carousel" class="jcarousel jcarousel-skin-tango">
				<li><a href="#" rel="p1"><img src="images/<%=idProduct%>/1.jpg"></a></li>
				<li><a href="#" rel="p2"><img src="images/<%=idProduct%>/2.jpg"></a></li>
				<li><a href="#" rel="p3"><img src="images/<%=idProduct%>/3.jpg"></a></li>
                          <li><a href="#" rel="p3"><img src="images/<%=idProduct%>/4.jpg"></a></li>
  <li><a href="#" rel="p3"><img src="images/<%=idProduct%>/5.jpg"></a></li>


Open in new window

I have come across this page per the following link.  A button "Add to List" is at the right side of the image. When the user clicks Add to the list button, it will be added to the My List.

The button turns to Remove from the list once Add to List has been clicked.  How to accomplish it? Thank you!

I have a winforms application that is utilizing click once to create the install which is pushed to a server.  When clicking on the launch the xxxxx.application downloads.  When running xxxxxx.application I get the following error:

System.Deployment.Application.DeploymentDownloadException (Unknown subtype)

It only occurs on 1 of the 3 computers I tested the install.

Any idea what is causing this?
BarCodes in Crystal reports:
I am trying to make my barcodes wider when using Crystal to print them.   I tried messing with the Character Spacing Exactly but anything other than 0 makes them smaller.  
My Font is an IDAutomationC128M

I am not a Crystal person and have been looking around on how to make them wider?
Any ideas would be appreciated.

I am posting data using webclient to the URL in C#.
Below is my code.

 if (!string.IsNullOrEmpty(postdata))
                    WebClient requestClient = new WebClient();
                    string DEURL = DynConfig.Item("DESettings/DEUrl");
                    string proxyenable = DynConfig.Item("DESettings/IsProxyEnable");

                    if (proxyenable.ToUpper() == "TRUE")
                        string proxyuser = DynConfig.Item("DESettings/ProxyUserId");
                        string proxypwd = DynConfig.Item("DESettings/ProxyPwd");
                        string domain = DynConfig.Item("DESettings/Domain");

                        var proxy = new System.Net.WebProxy(DynConfig.Item("DESettings/ProxyAddress"), false);
                        proxy.Credentials = new System.Net.NetworkCredential(proxyuser, proxypwd, domain);
                        requestClient.Proxy = proxy;

                    NameValueCollection nmsDE = HttpUtility.ParseQueryString(postdata);
                    byte[] responseBytes = requestClient.UploadValues(DEURL, "POST", nmsDE);
                    string responsefromserver = Encoding.UTF8.GetString(responseBytes);

Open in new window

I am getting error at line
byte[] responseBytes = requestClient.UploadValues(DEURL, "POST", nmsDE);

When url is on http the error is
string DEURL =
The remote server returned an error: (503) Server Unavailable.

and when URL is on https then I am getting below error:
string DEURL = https://xyz.com/Manager.aspx
The underlying connection was closed: An unexpected error occurred on a send.

Please advise.

OK so we have an in house marketing database that used to connect to a remote MySQL database on a Linux server. I decided to migrate to a MySQL server on our in house computer that also serves as the domain controller. everything is working fine except when I try to export a CVS. This was all operational when it was connecting to the Linux server prior. Please give me a hand guys!

The error that I am getting is below:
MySql.Data.MySqlClient.MySqlException (0x80004005): Fatal error encountered during command execution. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Fatal error encountered attempting to read the resultset. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Reading from the stream has failed. ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at …
I used clickonce in .NET to create an install and pushed it to the server.  When clicking on the link I receive the below error.

Downloading https://xxxxxcom/xxxxx/xxxxx.application did not succeed.
+ The request was aborted: Could not create SSL/TLS secure channel.

Any ideas?
I have tried various combinations for the WHERE that I found on the net but didn’t fix the problem
Here is a code snipit

'PcbNumber is Key field

oConn = New OleDbConnection(strSQLpath)
            'Open the connection

            oQuery = "UPDATE PcbBom SET pq1= 222222 WHERE  PcbNumber = 2990"

            'oQuery = "INSERT INTO PcbBom (PcbNumber, pq1) VALUES (2875a, 555555)"

            oComm = New OleDbCommand(oQuery, oConn)



The insert command works, I can add a new row,  I can update all pq1 columns if I don’t use the WHERE statement,
but when I try to update the field “pq1” using the WHERE I get this error message:

System.Data.OleDb.OleDbException (0x80040E07): Data type mismatch in criteria expression.
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
I am trying to install a .NET 2008 application with click once and I am receiving the below error.  Any ideas?

The following properties have been set:
Property: [AdminUser] = true {boolean}
Property: [ProcessorArchitecture] = AMD64 {string}
Property: [VersionNT] = 6.1.1 {version}
Running checks for package 'Windows Installer 3.1', phase BuildList
The following properties have been set for package 'Windows Installer 3.1':
Running checks for command 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe'
Result of running operator 'VersionGreaterThanOrEqualTo' on property 'VersionMsi' and value '3.1': true
Result of checks for command 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe' is 'Bypass'
'Windows Installer 3.1' RunCheck result: No Install Needed
Running checks for package '.NET Framework 3.5', phase BuildList
Reading value 'Install' of registry key 'HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\1033'
Read integer value 1
Setting value '1 {int}' for property 'DotNet35InstallSuccess'
The following properties have been set for package '.NET Framework 3.5':
Property: [DotNet35InstallSuccess] = 1 {int}
Running checks for command 'DotNetFX35\dotNetFx35setup.exe'
Result of running operator 'ValueEqualTo' on property 'DotNet35InstallSuccess' and value '1': true
Result of checks for command 'DotNetFX35\dotNetFx35setup.exe' is 'Bypass'
'.NET Framework 3.5' RunCheck result: No Install Needed
Running checks for package 'Crystal Reports …
OWASP: Avoiding Hacker Tricks
LVL 12
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.


I have a folder with a bunch of files that come in a set of 2 files (e.g., Name.pdf, NameMD.pdf).  I need to loop through this source folder (call it FOLDER1) and move only each set of files to another folder (call it FOLDER2).   (NOTE: Then, I have another process that compares the contents of each set of PDF files.)

I need to search for a file that has a *MD at the end of the filename, then search for the 2nd file that does NOT have 'MD' at the end of the filename, then move both files to FOLDER2.  Then I have another process that processes files in FOLDER2.  Then repeat the loop in FOLDER1.

What is the code to do this as a vb script, a standalone console C#.Net or C#.Net inside of SSIS?




I have created a simple "LightSwitch Desktop Application" using "View Details Screen" as the default screen. When I run the app, all the fields on the screen are grayed out. It's not showing me the existing data and I can not insert a new data. Please help me.
Here is my splash screen Activity

[Activity(Label = "MyActivity", Icon = "@drawable/AppLogo", Theme = "@style/SplashTheme",
           MainLauncher = false,ScreenOrientation =ScreenOrientation.Portrait, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class splashScreen : Activity
        protected override void OnCreate(Bundle saveInstanceState)
            var mainActivityIntent = new Intent(this, typeof(MainActivity));


Open in new window

Hockey app unable to send the crash report for this issue Here is the code for hockey app crash report,inside the MainActivity.

protected override void OnResume()
            CrashManager.Register(this, "bfb3fc329eghsd21151d475886dd25058ef3f");

Open in new window

This happens on few devices including Redmi Note 5 Pro.  How to solve this issue?
Any suggestions on Project example for Asp.net MVC .

i have developed an app for android which stores a serialized domain model in a json file to the local storage. Now the thing is, sometimes i make changes to the domain model (new features) and want to have the option to **easily** load a previous structure of the json file from the local storage. How can i do this?

I thought of deserializing the object anonymously and use auto-mapper, but i want to hear other's opinions first before going this path.

If a code example of the domain model is needed (before and after), i'll provide. Thanks everyone.
I have the coding below:

var popUpObj;
function showModalPopUp() {
  popUpObj = window.open("product.aspx?id=<%# DataBinder.Eval(Container.DataItem, "idProduct") %>",
    "toolbar=no," +
    "scrollbars=no," +
    "location=no," +
    "statusbar=no," +
    "menubar=no," +
    "resizable=0," +
    "width=500," +
    "height=500," +
    "left = 490," +

function LoadModalDiv() {
  var bcgDiv = document.getElementById("divBackground");
  bcgDiv.style.display = "block";
function HideModalDiv() {
  var bcgDiv = document.getElementById("divBackground");
  bcgDiv.style.display = "none";

function OnUnload() {
  if (false == popUpObj.closed) {

window.onunload = OnUnload;

<a href="javascript:showModalPopUp()">Open My Window</a>

Open in new window

1. Error:

'DataItem' is not a member of 'System.Web.UI.Page'.

How to fix popUpObj = window.open("product.aspx?id=<%# DataBinder.Eval(Container.DataItem, "idProduct") %>"

2. How to change the background color to gray

Thank you!

.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.