.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

I'm using MailKit and MimeKit in my VB.NET application to send out emails. In order to do this, the end user must configure settings like SMTP Server, Port, etc.

All of the end users have email clients installed, like Outlook or Thunderbird. Is there some way for my program to use the same credentials as those installed clients without the user having to enter them again? I'm assuming the answer is no, but wanted to ask those more experienced in this sort of thing.
0
CompTIA Cloud+
LVL 13
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

ASP.net Web Work In Visual Studio How To Create an Efficient and FAST Setup To Develop...

Open to Any and All Tips that will help me develop DotNet websites faster and easier in Visual Studio...

So FAR... I do the following to be fast/efficient using VStudio .net coding  (not saying this is best or right way --  just providing a starting point)

I have THREE monitors...

Left Monitor has my CSS page and a minimized SQL Server Studio Management Software With my databases and tables to create update etc.

Middle Monitor has Visual Studio 2015 with HTML & ASP.net objects & Code Behind Page + HTML objects and Bookmark folder on my browser with links to
              StackOverflow, Microsoft Docs, and a lot of other DotNet resources... etc.

Right Monitor has Webpage(s) i am working on to see updates made in CSS or Code or HTML or where ever... and interactive web page cheat sheets minimized.

I have a notebook with Cheat Sheet for HTML and CSS printed out from helpful websites... mostly memorized but at my hand if needed

I have chrome developer tools ready to use to help see my or others CSS / HTM code development and to debug... Looking into to Firebug for JS debugging...

I use the Visual Studio block commenter buttons - for comment out comment in actions - to speed up  large comment in or out efforts

I use the Find button inside Visual Studio to see if CSS styles are being used or not in my HTML by searching ALL open …
0
I have a c#  application and need to return 2 items from a class  library

when i had 1 item i was able to return it but some how i am having error returning 2 items

The 2  items i want returned are   RegisteredStatus  and RegisteredLevel

Both variables  were defined as  strings  ie

string RegisteredStatus = "";
string RegisteredLevel ="";

After  some processing  in the script ,  I have values in both variables which i want returned.

1. Part of my code in the Library

  MyActiveLock.KeyStoreType = ActiveLock3_6NET.IActiveLock.LicStoreType.alsFile;


            MyActiveLock.Acquire(ref strMsg, ref strRemainingTrialDays, ref strRemainingTrialRuns, ref strTrialLength,
                   ref strUsedDays, ref strExpirationDate, ref strRegisteredUser, ref strRegisteredLevel, ref strLicenseClass,
                   ref strMaxCount, ref strLicenseFileType, ref strLicenseType, ref strUsedLockType);

            if (strMsg != null && strMsg.Length > 0) //There's a trial
            {
                RegisteredStatus = "Trial Mode";
                RegisteredLevel = strRegisteredLevel;
            }
            else
            {

                //cmdKillTrial.Visible = false;
                //cmdResetTrial.Visible = false;
                RegisteredStatus = "Registered";
                RegisteredLevel = strRegisteredLevel;        
            }
            return (RegisteredStatus, RegisteredLevel);

Open in new window


Return RegisteredStatus   worked  fine,  while Return (RegisteredStatus, RegisteredLevel) gave a syntax error

I  introduced  the Tuple below into library hoping it would help me return the 2 values

But i think i might not be calling/using the tuple properly  (see Below the tuple in the library)

2. A Tuple also defined in the Library

 
public static Tuple<string, string> Location(string RegisteredStatus, string RegisteredLevel)
        {
            return new Tuple<string, string>(RegisteredStatus, RegisteredLevel);
        }

Open in new window



3. Eventually in my application i need to get the 2 returned variables in to

some text field on the screen .

For the 1 variable   which worked  my script was

 ActiveLockProcessor processor = new ActiveLockProcessor();
 txtRegStatus.Text = processor.GenerateActiveLockStatus();

What would be the correct syntax now for getting the 2 variables to my Text fields on screen

Please NOTE that i do not have to use Tuples if there is a simpler and more straight way to achieve this.

Thanks

Olukay
0
How to generate Click Once Deployment file .exe without depending on .application file?


I have created Click Once Deployment file. It works great.

However, .exe file was created along with .application file and Application Files - Folder which has necessary files.

.exe file works only if it is available along with .application file in the folder. If i share the .exe file without .application file to another user, it throws an error as follows ..

How to make the .exe file independent without depending on .application file?

+ Downloading file:///C:/Users/MyAccName/Downloads/MyProject.application did not succeed.
        + Could not find file 'C:\Users\MyAccName\Downloads\MyProject.application'

Open in new window

0
Hi there.

I started working on a new VB.NET project. It's my first real attempt to make a .NET project. I used classic asp in the past, and all those files is tricking me. This is the case:
At my hosting company I have some old projects stored. In the www-folder (the root of my webserver) I have subfolders with projects, and this new .NET has got a folder too.
Now when I try to publish my very first page, I get an error message with compiling.
When I publish my project, the web.config ends up in the project-folder. Not in the www.root. So I moved it manually to the root on the server, but I have the feeling that it's not the right thing to do.
Can anyone please guide me how to do the publishing correct? Let me know if you need more info.

Best regards

Ulrich
0
Hi,

I have a database column which is the arrival time of the patient to the clinic as TIME(7) data type.

I am struggling in viewing it to the data grid view column.

public string ArrivalTimeFormatted { get { return ArrivalTime?.ToString("hh\\:mm\\:ss"); }}

Open in new window


How can I add PM, AM to the ArrivalTimeFormatted property?

Thanks,
0
Hi All,

I'm trying to expand programmatically an accordion menu based on saved values in local-storage.
The problem is that it saves the values, i get back the values, but it's not expanding the active ones.
I use the following accordion library:
(function(jQuery){
     jQuery.fn.extend({  
         accordion: function() {       
            return this.each(function() {
            	
            	var $ul = $(this);
            	
				if($ul.data('accordiated'))
					return false;
													
				$.each($ul.find('ul, li>div'), function(){
					$(this).data('accordiated', true);
					$(this).hide();
				});
				
				$.each($ul.find('a'), function(){
					$(this).click(function(e){
						activate(this);
						return void(0);
					});
				});
				
				var active = (location.hash)?$(this).find('a[href=' + location.hash + ']')[0]:'';

				if(active){
					activate(active, 'toggle');
					$(active).parents().show();
				}
				
				function activate(el,effect){
					$(el).parent('li').toggleClass('active').siblings().removeClass('active').children('ul, div').slideUp('fast');
					$(el).siblings('ul, div')[(effect || 'slideToggle')]((!effect)?'fast':null);
				}
				
            });
        } 
    }); 
})(jQuery);

Open in new window


My HTML (i generate the menu from C#) + JS: Init that gets the menus/submenus that i clicked earlier (but not expanding them :o(   ):
<!--MENU-->
<div id="pageWrap" class="pageWrap">
	<div class="pageContent">
		<ul class="accordion">
			<div

Open in new window

1
I have a .resx file in my resource folder. I'm trying to use ResXResourceWriter but it requires a path to the file. When I'm debugging I can just put a path to the file in my projects resource folder, but when it comes time to release the application it won't work since the application should only be one .exe file without any folders or additional files. I'm trying to do
ResXResourceWriter resx = new ResXResourceWriter(Properties.Resources.[File Name])

Open in new window

but it only seems to give me an error "Illegal characters in path."
0
I am a C# programmer. I'd like to start learning ASP.NET, but before that I'd have a couple of questions:

1. Should I learn ASP,NET Core or ASP.NET MVC? (What I need is to dynamically reformat pages on an existing web, at request, and also to provide user feedback forms that should access a database.)

2. I have on location an old Windows Server 2003 and another 2008, which I thought of using for testing samples. Can the framework required by ASP.NET Core be installed on such older servers? Would older IIS handle the job?

3. This book "ASP.NET Core in Action" is recent but some readers complain it's too verbose. Would you recommend another book/tutorial?
0
Hello,

I have a solution with 2 projects. I want to build/compile one project from another. To be more exact I want a user that will be using ProjectNR1 to enter the information then the information should be passed to ProjectNR2 and then the project(ProjectNR2) builds/compiles. So the question I have is: How to compile a VisualStudio 2019 project programmatically using C# (It's a windows forms application). I have been trying to figure out this all day with no luck.
0
Become a Certified Penetration Testing Engineer
LVL 13
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

I am looking for the best DB giving the following considerations.

1)  I will be deploying a .net /angular application into Azure via Docker / Kubernetes.

2)  I would want on prem and cloud capabilities..natively

3)  Finally we will be moving to AWS in the next year..so migration is important as well.


I will want to use relational database.  High availability, on prem and off prem  capabilities, as well as other great scaling capabilities.

Also having a hard time with the cost model here...so any knowledge there would be helpful.

I will be doing this in a CI/CD ...I am guessing I would have docker in my local enviornment (free)  then move to a dev / stage/ prod enviornment.
0
Hi
in the code bellow I'm trying to remove 1080p | HD either in or out of ()
I butl the using regexq101
this appears to work except for last witespace
however I'm not getting the expacted reults


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

namespace Remove1080p
{
    class Program
    {
        static void Main(string[] args)
        {
            string Root = "";
            Console.WriteLine(@"Drag folder");
            string Ans = Console.ReadLine();
            if (Ans == "")
            {
                Console.WriteLine("Need a folder");

                Console.WriteLine(@"Drag folder");
                Ans = Console.ReadLine();
            }
            if (Ans != "")
            {
                Root = Ans;
                if (Root.EndsWith(@""""))
                {
                    Root = Root.Trim(new char[] { '"' });
                    Console.WriteLine("trimed " + Root);
                }
            }
            Regex regex = new Regex(@"(\s+(\(1080p\s+HD\))|(\(1080p\)|(\(regex\))|1080p|720p|HD)\s+)");

            string[] Files = Directory.GetFiles(Root);
            foreach (string file in Files)
            {
                Console.WriteLine("File " + file);
                FileInfo fi = new FileInfo(file);
                string Ext = fi.Extension;

              

Open in new window

0
Hi,

Hi, I am using this online solution for Grideview Drag and Drop asp.net web forms (https://www.aspsnippets.com/Articles/Reorder-GridView-Rows-Drag-and-Drop-ordering-of-GridView-Rows-using-jQuery-in-ASPNet.aspx).  Everything works fine but now I need help updating the database table with additional fields.  For example:  I need to update the table of who dragged and dropped the row.  I added the "UpdateBy" field to my update statement , it works, but it updates every row with the value not the one row that was dropped.  What am i missing? Please need help asap.

  

  Private Sub BindGrid()
        Dim query As String = "SELECT [id], [DisplayOrder], [STUDY], [PATIENT],[WAIT_TIME],[USER_ID],[UpdateBy] FROM [Radio_queue4] " +
"order by DisplayOrder asc"
        Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
        Using con As New SqlConnection(constr)
            Using cmd As New SqlCommand(query)
                Using sda As New SqlDataAdapter()
                    cmd.CommandType = CommandType.Text
                    cmd.Connection = con
                    sda.SelectCommand = cmd
                    Using dt As New DataTable()
                        sda.Fill(dt)
                        grid.DataSource = dt
                        grid.DataBind()
                    End Using
                End Using
            End Using
        End Using
    End Sub

 Protected Sub UpdatePreference(sender As Object, e As 

Open in new window

0
I am trying to get a range of cells from a sheet to populate my graph on a different sheet inside my excel workbook. When it hits the line "  chartRange = oWB.oSheet("Sheet1").Range("A1", "A136")" It throws an error "System.MissingMemberException: Public member osheet on type Workbook not found

What is wrong with that line of code?

 Dim oXL As Excel.Application
        Dim oWB As Excel.Workbook
        Dim oSheet As Excel.Worksheet
        Dim oRng As Excel.Range
        Dim ValueTemp As String
        Dim oChart As Excel.Chart
        Dim MyCharts As Excel.ChartObjects
        Dim MyCharts1 As Excel.ChartObject

        ' Start Excel and get Application object.
        oXL = CreateObject("Excel.Application")
        oXL.Visible = True

        ' Get a new workbook.
        oWB = oXL.Workbooks.Add
        oSheet = oWB.ActiveSheet

        'Add a new Sheet.
        oSheet = CType(oWB.Sheets.Add(Count:=1), Excel.Worksheet)

        'change page orientation
        oSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape


        oSheet = oWB.Worksheets.Item(2)
        Dim intRowLoc, intcurrentrow, intCurrentCol, intLoop, intOuterLoop, intInnerLoop As Integer
        Dim boolRowFound, boolNextRow As Boolean
        intcurrentrow = 1
        intCurrentCol = 1
        For intInnerLoop = 0 To 135 'Column4.Count - 1
            ValueTemp = (Column4(intInnerLoop)).ToString
            oSheet.Cells(intcurrentrow, intCurrentCol) = ValueTemp
            

Open in new window

0
Is, at least some of, the thought of the .NET framework the ability to create a piece of software that doesn't require installation?

I would like to make a program that just runs. I have VS 2017.

I'm under the impression that I am correct... that is until you get to the point of using references that may need to be registered, etc.

At the end of the day I am familiar with C# and VB and would like to make a program that doesn't need to be installed and just runs. I would need to know the boundaries, or where the point is of "ok... now you have to install".

Thougts?
0
How can I add a series of 256 points to an Excel chart ? I have the code below however I can;t seem to find an add data property to the chart object?

Dim objApp As Excel.Application
        Dim objBook As Excel._Workbook
        Dim objBooks As Excel.Workbooks
        Dim objSheets As Excel.Sheets
        Dim objSheet As Excel._Worksheet
        Dim range As Excel.Range
        Dim chart As Excel.Chart

        ' Create a new instance of Excel and start a new workbook.
        objApp = New Excel.Application()
        objBooks = objApp.Workbooks
        objBook = objBooks.Add
        objSheets = objBook.Worksheets
        objSheet = objSheets(1)
        objApp.Visible = True
        objApp.UserControl = True
        'Add in Header Graph.
        objSheet.Shapes.AddPicture("C:\Header.png",
             Microsoft.Office.Core.MsoTriState.msoFalse,
             Microsoft.Office.Core.MsoTriState.msoCTrue, 50, 50, 0, 45)
        'Add in DataChart

Open in new window

0
Hi

I have a byte array
byte[] newBytes

Open in new window


It contains
[0] 48
[1] 48

Open in new window


I know that this should equal 00
How do i get that into an int?
i've tried
var num = BitConverter.ToInt16(newBytes, 0);

Open in new window


but i get 12336 out of that
0
Hi there.

I have some code suggestion made for C#, that I want to make in VB.NET. Some code is meant to be in the "IdentityConfig.cs". Where is that going in VB.NET?

Best regards

Ulrich
0
Hi there.

I'm finally starting to step up to .NET. I will use a present classic asp project and redo from scratch. I want to implement two factor authentication (e-mail), but I'm unsure if it should be done in C# or VB, AND if it's only possible in one of these?
I'm used to VB from the past with classic asp, so of course I would like to use that, but two factor authentication is a must, so I'll have to deal with C# if necessary.
I look forward to your input. I found this:
https://www.hanselman.com/blog/AddingTwoFactorAuthenticationToAnASPNETApplication.aspx
It appears as C# to me. Am I wrong?
If you know of better guides/help to implement two factor authentication, please let me know. :-)

Best regards

Ulrich
0
C++ 11 Fundamentals
LVL 13
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

What's the best way to parse the following string into an object?
vbCrLf & "+COPS: (2,""O2 - UK"",,""23410"",0),(3,""vodafone UK"",,""23415"",0),(3,""EE"",,""23430"",0),,(0-4),(0,2)" & vbCrLf & vbCrLf & "OK" & vbCrLf
An example would be good!
Thanks
0
Hi
Following on from previous question

I have a TreeView and a ListView showing directory structure
The listView has Directories & files.

When I double click a Folder in the ListView how do I find the node in the TreeView and expand it replacing the contents of the ListView  similar to explorer

treeView1.Nodes  will only give you the Parent Nodes or in this case system drives

This Page suggest iterating through ChildNodes

In the full code bellow the bit  the handles double click is " ListView1_MouseDoubleClick"
When adding items to the ListView item.tag = the FullPath of the item e.g. "E:\\temp\\SubDir" or "E:\\temp\\SubDir\\MyFile.txt" I thought I could use this to find the TreeView.Node

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static DragDrop.NativeMethods;
using static System.Windows.Forms.ImageList;

namespace DragDrop
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            PopulateTreeView();
        }

        private void PopulateTreeView()
        {
            foreach (var drive in Environment.GetLogicalDrives())
     

Open in new window

0
I need to display birthdate value as age.

Examples:
DateTime bd1 = new DateTime(1, 5, 1);

string age1 = bd1.AsAge();

//output: 
// 1 Year, 5 Monthes, and 1 Day.

Open in new window


DateTime bd2 = new DateTime(50, 1, 30);

string age2 = bd2.AsAge();

//output: 
// 50 Years, 1 Month, and 30 Day.

Open in new window


The client asks for rounding the age value but she does not give me the rules.

Is there any ready component to use instead I reinvent the wheel?

Thanks
0
My Custom DGV returns zero for selectedRowCount.

        public int SelectedPatientId()
        {
            int selectedRowCount = dataGridViewEx1.Rows.GetRowCount(DataGridViewElementStates.Selected);

            int id = -1;

            if (selectedRowCount > 0)
            {
                id = int.Parse(dataGridViewEx1.SelectedRows[0].Cells["Id"].Value.ToString());
            }

            return id;
        }

Open in new window


using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using ECMS.Client.Desktop.Helpers;

namespace ECMS.Client.Desktop.Views.UserControls
{
    public class DataGridViewEx : DataGridView
    {
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Color BackColor
        {
            get => base.BackColor;

            private set => base.BackColor = value;
        }

        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Color ForeColor
        {
            get => base.ForeColor;

            private set => base.ForeColor = value;
        }

        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Font Font
        {
            get => base.Font;

            private set => base.Font = 

Open in new window

0
Hi
Following on from previous question

When loading directories in TreeView the  $Recycle.bin and System Volume Information directory  are shown See Picture
Clearly you don't want users to be clicking these

I thought about using a try catch block to handle the exception but then I thought it's probably better not to show them in the first place

The code snip bellow gives
Argument 1: cannot convert from 'System.IO.DirectoryInfo' to 'string' @ (d) 

Open in new window


        private void OnNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeNode newSelected = e.Node;
            listView1.Items.Clear();
            DirectoryInfo nodeDirInfo = (DirectoryInfo)newSelected.Tag;
            ListViewItem.ListViewSubItem[] subItems;
            ListViewItem item = null;


            var Directories = nodeDirInfo.GetDirectories()
                         .Select(d => new { Attr = new DirectoryInfo(d).Attributes, Dir = d })  // error here
                         .Where(x => !x.Attr.HasFlag(FileAttributes.System))
                         .Where(x => !x.Attr.HasFlag(FileAttributes.Hidden))
                         .Select(x => x.Dir)
                         .ToList();
            foreach (DirectoryInfo directory in Directories)
            {
                item = new ListViewItem(directory.Name, 

Open in new window

0
I have a c# application

I am trying to get the unique ID  for the "C" drive of my PC  with the Code  below

private void button1_Click(object sender, EventArgs e)
        {
            //txtID.Text = getUniqueID("C");
            txtID.Text = MachineIdProccesor.GetUniqueID("C");
            
        }

Open in new window


The code that actually gets the ID was initially in the same form (under the Click event)
The code ran perfectly with the now commented line above

I now tried to move the same code to a class library  (DRYDemoLibrary)  to make it accessible from  other  parts of my application
with the uncommented code above.

The code is shown below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Management; //Need to manually add to the References
using System.IO;

namespace DRYDemoLibrary
{
    public class MachineIdProccesor
    {
        public string GetUniqueID(string drive)
        {
            if (drive == string.Empty)
            {
                //Find first drive
                foreach (DriveInfo compDrive in DriveInfo.GetDrives())
                {
                    if (compDrive.IsReady)
                    {
                        drive = compDrive.RootDirectory.ToString();
                        break;
                    }
                }
            }

 

Open in new window

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.