.NET Programming

133K

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 build a small project in vb.net and create an .exe and .msi to load onto another PC. No error when I compile it. I install it on to another PC ( 3 different) PC's and it never runs.

If I install it on the same PC or on another pc running different versions of VS I can get it to run.

What Am I missing?
0
OWASP: Forgery and Phishing
LVL 12
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Hi,
What is the meaning of Annotate (Blame) in GitHub
I am using visual studio 2017.

Thanks in advance.
0
Need a quick overview of WebAPI.

I am a .NET Full Stack developer and have supported numerous web services, but have difficulty answering interview questions about WebAPI.

Please refresh my memory.

Thanks
0
Quick overview of JSON tokens

please provide me a few sentences to explain JSON tokens. I have worked with JSON on various full stack positions, and wonder how JSON tokens fit in.

Thanks
0
Hi

When I try to run my ASP.net web app in debug mode I get the following message.
I am using Visual Studio 2017 Professional. How do I fix this?

1
0
I am working in a C#  application

I have constituted  a List with the script Below:

StaffNameListBox.DataSource = GlobalConfig.Connection.GetEmployees_All();
StaffNameListBox.DisplayMember = "FullStaffName";

 public string FullStaffName
        {
            get
            {
                return $"{Staff_no}  { Surname } {Firname }";
            }
        }

(See  the Screen of The list below showing a record in the list

On the Click event on this record I want to return a part of the string (ie just the staff_no)

 to a text box on the screen.  The name of the textbox is StaffNoValue


My click event syntax  is as below:

  private void StaffNameListBox_Click(object sender, EventArgs e)
        {
            StaffNoValue.Text = StaffNameListBox.ValueMember;
        }

What I want Returned to the text box on screen is as shown below

StaffNoValue.Text = "N001"

How can I get a portion of a list returned into a field using the actual name with which the list was loaded

and not by searching for a sub string of the selected item

Thanks
Selection-From-List--11-01-2019.PNG
0
I'll explain in steps what happened...

1. My manager moved the production database to a new server. It went from server YYY to XXX, for example
2. He changed the webconfig on the server to point to the new database. All good so far.
3. I wanted to update our production webserver with the new code. I don't publish directly to the server. I publish locally and just copy the Bin folder to prod (along with whatever files like JS, etc)
4. This is the publish settings:
p1.png
5. I published locally in Release mode. Copied the Bin folder. I didn't replace the webconfig on the production webserver. It was pointing to the correct database XXX.
6. I went to the site and the site was down with an error that looked like it was a connection to the database.
7. This is what I did to fix it. I went back to the code and in the Web.Release.Config, I saw the connection string as being the old one; YYY. I changed the connection string to XXX (new one). Compiled, published, copied the Bin folder and this time it worked. Note that I didn't replace the Production webconfig file
p2.png
So, how does this work... I didn't replace the webconfig on the prod server, I only changed it locally, compiled , republished and only copied the Bin folder.
0
Hello,
How to find the index of the item in the listbox.

Dim items = From i In lstbox.Items Where i.ToString().StartsWith("Al")

        If items.Count > 0 Then

        Else

        End If

Open in new window

0
Hi,

I have this scenario I want to achieve:

The user has logged in to his website (an adminstrative site).
Now he wants to open and login to another website that contains reports and it's a typical loginform. Loginform
Instead of needing to login to this second site he wants the administrative site to automatically log him in.

So my question is:
Is it possible to store the credentials in the administrative site and then do some sort of request to the second. report site, without the need for the user to manually login to two sites?
And, if it's possible, how can I achieve it?

Thanks for help!

Peter
0
Greetings:

I created an ASP.NET page with VB.NET page behind. This page display 4 images. There are 3 buttons below each image to rotate the image. When a button is clicked to rotate an image, the code behind loads the image into a bitmap variable; rotates the image; saves the image using the same name. The image is then reloaded to the page.

I'm experiencing intermittent success when rotating the pictures. I am a novice when it comes to the drawing classes within the .NET framework.

The ASP.NET page is:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="GraphicRotate.aspx.vb" Inherits="GraphicRotate" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Graphic Rotate</title>
</head>

<body>

    <form id="form1" runat="server">

		<br />
		<br />
		<asp:Label ID="lblMessage" runat="server" Text="No Error"></asp:Label>
		<br />
		<br />

		<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/IMG_3001.JPG" />
		<br />

		<asp:Button ID="Button1" runat="server" Text="Rotate 90 Clockwise" />
		<asp:Button ID="Button2" runat="server" Text="Rotate 90 Counter Clockwise" />
		<asp:Button ID="Button3" runat="server" Text="Rotate 180" />
		<br />
		<br />
		<br />

		<asp:Image ID="Image2" runat="server" ImageUrl="~/Images/IMG_3002.JPG" />
		<br />

		<asp:Button ID="Button4" runat="server" Text="Rotate 90 Clockwise" />
		<asp:Button ID="Button5" runat="server" Text="Rotate 90 Counter Clockwise" />
		<asp:Button 

Open in new window

0
Starting with Angular 5
LVL 12
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

I had this question after viewing How to Save Database Connection info with Crystal Report Version 11 for Use on Business Objects Server.

I have a Crystal Report v 11.5ish that I want to send to a conversion company but I'd like to delete the Database information for security reasons.  However, when I try to delete it or replace info with junk, it attempts to make the connection and then fails.  How can I remove those details?
0
I have a following class class Result.
 
public static class Result
    {
        public static List<string> fromDifferentClass = new List<string>{ "cat", "dog", "bear" };
    }

Open in new window

And I am accessing this fromDifferentClass list in a different class.

class Program
    {
        static void Main(string[] args)
        {
            List<string> myList = new List<string>();
            myList = Result.fromDifferentClass;
            Console.WriteLine("Result: " + Result.fromDifferentClass.Count); // prints 3
            Console.WriteLine("myList: " + myList.Count); // prints 3
            Result.fromDifferentClass.Clear();
            Console.WriteLine("Result: " + Result.fromDifferentClass.Count); // prints 0
            Console.WriteLine("myList: " + myList.Count); // prints 0

            Console.Read();
        }
    }

Open in new window

in Program class, I made myList to refer fromDifferentClass.
And I cleared fromDifferentClass list.
so I understand myList also is cleared.
However, is there any way I can still keep the content of myList even after fromDifferentClass list is cleared();
So the currently the result is
3
3
0
0
But I want it to be
3
3
0
3
0
Hi this is a follow on from here  and other questions relating to parsing XML with C#

I'm trying to add a new season to the xml

My CheckSeason fails where no season exists eg for "A Discovery Of Witches"  but returns true or false for any MacGyver season

I'm assuming it's because the parent "season" has to exist before you can check for season number?
I don't understand why this causes an "unhandled exception " and not just return null


AddSeason i've tried to amend from previous question  but i'm missing something

Logic
Add season if none exist
Add new season in numerical  SeasonNumber order


       public static XDocument xdoc = XDocument.Load(@"J:\Media\TV\TV.xml");
        // Load the XML Document using Linq to XML


            if (CheckSeason("A Discovery Of Witches", "S01", "77236"))  // fails
            //    if (CheckSeason("MacGyver 2016", "S02", "67133"))        // works
                {
                Console.WriteLine("Exists");
            }
            else
            {
                Console.WriteLine("Does Not Exists");
                Console.WriteLine("Add Season");
                AddSeason("A Discovery Of Witches", "S01", "77236");
            }


        private static void AddSeason(string showname, string season, string TMDBid)
        {
            char[] array1 = { 's', 'S', '0' 

Open in new window

0
I'm using HtmlAgilityPack to Travers some  HTML   VidsTest.html

In the code bellow I cannot get to the second video block with  <div class='post_title'>Title 2 The Wombles
Even though  the ID of "user_post_2712102" is being set Title and other variables remain at Title 1 Doctor Who

    HtmlAgilityPack.HtmlDocument HTMLdoc = new HtmlAgilityPack.HtmlDocument();
            HTMLdoc.Load(@"E:\path\to\VidsTest.html");
            var user_postDiv = HTMLdoc.DocumentNode.SelectNodes("//div[contains(@class,'user_post_')]");
            string id = "";
            string Title = "";
            string VidSrc = "";
            string Poster = "";
            string postDate = "";
            foreach (var divNodes in user_postDiv)
            {
                id = divNodes.GetAttributeValue("item_id", "").ToString();
                if (id != "")
                {
                    Console.WriteLine("id = user_post_" + id);
                
                //    postDate = divNodes.SelectSingleNode("//span[@class='local - time']").InnerHtml;
                // can't find postDate
                Title = divNodes.SelectSingleNode("//div[@class='post_title']").InnerText;

                VidSrc = divNodes.SelectSingleNode("//video/source").Attributes["src"].Value;
                Poster = divNodes.SelectSingleNode("//video").Attributes["poster"].Value;
                    Console.WriteLine("Title end div in divs {0} , {1} , {2} " + Title + Poster + VidSrc);
     

Open in new window

0
Hi

I have a form something like the image bellow

I wish to add buttons to my form representing sub folders  

first I don't how many sub folders buttons there are

How do I position them in a row under the text box up to 5 with adding a new row if required?


FormDesing.JPG
The code  is untested but shows what  I'm trying to do

        private void AddButtons()
        {
            string FolderPath = RootDir + FolderTextBox.Text;
            if (Directory.Exists(FolderPath))
            {
                string[] folders = Directory.GetDirectories(FolderPath, "*", SearchOption.TopDirectoryOnly);


                foreach (string folder in folders)
                {

                    FileInfo FI = new FileInfo(folder);
                    //string folderPath = 
                    string ButtonName = FI.Name + "Btn";
                    Button Button = new Button();  // can't call this ButtonName??
                    Button.Name = ButtonName;
                    Button.Text = FI.Name;
                    Button.Click += LoadListView(folder);
                    // The event 'Control.Click' can only appear on the left hand side of += or -=	


                }
            }
        }

        private EventHandler LoadListView(string folder)
        {
            // add code to populate  listview
            // is this the correct way?
        }

Open in new window

0
Using XML Linq  how do I add a new  TV show to the attached XML TV.xml preferable so the show.names are in alphabetical order?

From MyForm I call Thus

xmlFuncs.AddShowName(ShowName, FolderName, TMDBid, Xdoc);

Open in new window

or

xmlFuncs.AddShowName("Charmed", "Charmed 2018" "79611", Xdoc);

Open in new window


this creates
NewShow = {<Show>
  <Name>Charmed</Name>
  <FolderName>Charmed 2018</FolderName>
  <TMDBid>79611</TMDBid>
</Show>}

Open in new window




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

namespace TVDB
{
    class XMLFuncs
    {
        public XDocument Xdoc;


        public XDocument LoadXML(string XMLpath)
        {
            if (File.Exists(XMLpath))
            {
                Xdoc = XDocument.Load(XMLpath);
                return Xdoc;

            }
            else
            {
                return null;
            }
        }
        public string ChecKShowName(string FolderName, XDocument Xdoc)
        {

            // // Checks for the existence of a Show and return it's TMDB ID
            var results = (from node in Xdoc.Descendants("Show")
                           where node.Element("FolderName").Value == FolderName
                           select node.Element("TMDBid").Value).FirstOrDefault();
            if (results != null)
            {
                return results;
            }
            else
 

Open in new window

0
Hi,

I have this json that I want to convert to vb.net objects:
{

"status": "success",
"result": {
"0": {
"id": 4991,
"sender_id": 2971,
"due_date": "0000-00-00 00:00:00",
"language_id": "sv",
"last_event": "2017-05-17 09:58:38",
"visible_name": "new offer",
"name": "new offer",
"reminder_date": "0000-00-00",
"offer_status": 0,
"offer_type": 1,
"user_details": "{\"first_name\":\"Beta\",\"last_name\":\"\",\"company\":\"Simplesign\",\"email\":\"beta@yopmail.com\",\"reg_no\":\"\",\"address\":\"\",\"telephone\":\"00923453596885\",\"post_code\":\"\",\"city\":\"\"}",
"unique_id": "591c02ae8c442",
"created_date": "2017-05-17 09:58:38",
"signed_date": "0000-00-00 00:00:00",
"last_sent_emailreminder": "0000-00-00 00:00:00",
"last_sent_smsreminder": "0000-00-00 00:00:00",
"unread_notification": 0,
"offer_rejected": 0,
"recieved_by": 0,
"pdf_url": "https://esign.simplesign.io/avtal/downloadpdf/4991/5b8648da173a5",
"details": [
{
"id": 5668,
"offer_sent_id": 4991,
"customer_id": 1556,
"offer_status": 1,
"sent_date": "2017-05-17 09:59:15",
"email_read_date": "0000-00-00 00:00:00",
"document_read_date": "0000-00-00 00:00:00",
"signed_date": "0000-00-00 00:00:00",
"reject_date": "0000-00-00 00:00:00",
"sender_ip": "103.75.244.108",
"read_ip": "",
"signed_ip": "",
"gps_location": "",
"first_name": "John",
"last_name": "Doe",
"company": "",
"is_sender": 0,
"extra_fields": "",
"user_details": 

Open in new window

0
I have an MVC C# web application. I am trying to force a user choose from a drop down; in turn that selection is then used as a parameter to in another dropdown. I have a series of these activities. My first drop down does exactly correct, user chooses a selection, the selection is captured and the controller returns the new list and the user is asked to choose from the second list. My problem is that I cant seem to get the third drop down to get the last selection. I can see the controller is returning the data correctly, but I have something not quite right in the code. Maybe I have a variable or something that is keeping previous values. See my code snips below:

       window.onload = function () {
            document.getElementById("add_Date_Worked").setAttribute("readonly", "readonly");
            document.getElementById("add_Client_ID").onchange = function () {
                if (this.selectedIndex !== 0) {
                    document.getElementById("add_Product_ID").removeAttribute("disabled");

                    /* Client ID Drop Down Parameter Selection Start */
                    $.getJSON("../Home/GetFilteredProducts", { id: jQuery("#add_Client_ID").val() },
                        function (data) {
                            var select = $("#add_Product_ID");
                            select.empty();
                            select.append($('<option/>', {
                                value: 0,
                                text: "Select 

Open in new window

1
How do I use this method providing all the parameters

Public virtual IEnumerable<TEntity> Get(Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, String includeProperties = "")

Open in new window

0
Rowby Goren Makes an Impact on Screen and Online
LVL 12
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Happy new year all...

I am trying to get the system idle time via version 4 of the .NET framework using VB.NET.

Public Class idleTime
    Public Structure LASTINPUTINFO
        Public cbSize As UInteger
        Public dwTime As UInteger
    End Structure

    <DllImport("user32.dll")>
    Private Shared Function GetLastInputInfo(ByRef plii As LASTINPUTINFO) As Boolean
    End Function

    Public Function GetInactiveTime() As String ' Nullable(Of TimeSpan)
        Dim info As LASTINPUTINFO = New LASTINPUTINFO
        info.cbSize = CUInt(Marshal.SizeOf(info))

        If (GetLastInputInfo(info)) Then
            Return TimeSpan.FromMilliseconds(Environment.TickCount - info.dwTime).ToString '  
        Else
            Return "N/A" 'Nothing
        End If
    End Function
End Class

Open in new window

Through testing I see that info.dwTime always returns zero.

Thoughts?
0
Hi
could someone give me a clue why this dotnetfiddle is producing this output

Hello World
poster https://Example.com/path/to/preview.jpg
Run-time exception (line 73): Object reference not set to an instance of an object.

Stack Trace:

[System.NullReferenceException: Object reference not set to an instance of an object.]
   at Program.Main() :line 73

Open in new window


Clearly I've got the xpath wrong but examining it in firefox I get

/html/body/div/div/div/figure/div/div[2]/video/source

Open in new window

0
Hi

Building an application using CefSharp  the browser is within a  toolStripContainer there is also a  toolStripLabel1 to record status and a Go Button

Clicking the Go Button I can set toolStripLabel1.Text

But when I try and set the toolStripLabel1.text else where (eg OnLoadingStateChanged)  I get
I got similar with a form label
System.InvalidOperationException was unhandled
  HResult=-2146233079
  Message=Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on.
  Source=System.Windows.Forms
......

Open in new window


the help points How to: Make Thread-Safe Calls to Windows Forms Controls

Any suggestions how to solve this as the code from above didn't work

        public void SetText(string text)
        {
                toolStripLabel1.Text = text;
        }


        public void InitializeChromium()
        {
            CefSettings settings = new CefSettings();
            // Initialize cef with the provided settings
            Cef.Initialize(settings);
            Text = "CefSharp";
            WindowState = FormWindowState.Maximized;


            chromeBrowser = new ChromiumWebBrowser(@"E:\Path\To\Test.html")
            {
                Dock = DockStyle.Fill,
               
            };
            toolStripContainer.ContentPanel.Controls.Add(chromeBrowser);
            

Open in new window

0
Hi
I've recently been introduced to CefSharp

Given a uri and a local file path  how do I save a file?

It  makes sense to use  CefSharp to  save the file  has  it should handle any user credentials
In the examples there is a DownloadHandler.cs I've not found any tutorials on how to use it

I've been using the code bellow in other applications form here but that requires you to know how big the file is prior to download which isin't often the case

Alternatively how do I amend this so it's not governed  by a random byte size
admittedly I could change

 using (BinaryReader br = new BinaryReader(stream))
            {
                content = br.ReadBytes(5000000);
                br.Close();
            }
           

Open in new window

 

to

            int MaxInt = int.MaxValue;
            using (BinaryReader br = new BinaryReader(stream))
            {
                content = br.ReadBytes(MaxInt);
                br.Close();
            }

Open in new window

but that seems ridicules not knowing if a 100kb jpg is attempting to be saved to a 2GB + file
 
        private static void save_file_from_url(string url, string file_name)
        {
            byte[] 

Open in new window

0
Hi
I'm tryingg to build a winforms app that uses the built in web browser

On loading a JavaScript hungry HTML5  page I get a number of error boxes similar to the image

JSeror.JPG
Google suggested doing this which didn't work   (Even running the "...\debug\AppName.exe" in admin mode allowed the regestry to be set but failed to load the page correctly

More googling suggested using the nuget package Geckofx60.64


I'm struggling to know how to install this as there are several when searching for Geckofx

I'm also unsure how to run even the simple example given

 [STAThread]
       static void Main(string[] args)
       {
           Xpcom.Initialize("Firefox64");
           var geckoWebBrowser = new GeckoWebBrowser {Dock = DockStyle.Fill};
           Form f = new Form();
           f.Controls.Add(geckoWebBrowser);
           geckoWebBrowser.Navigate("www.google.com");
           Application.Run(f);
       }

Open in new window


Could someone start me of?

in my App I need to have real browser with at least 1 button that is used after the page loads to analyse the page using xpath queries
0
Hi,
I am trying to make the button in the winForm using async so that the application can be more responsive.
When the button is clicked, it execute the batch files in a List.

private async void GoBtn_Click(object sender, EventArgs e)
        {
           ...
                foreach (var file in batchFiles)
                {
                    ...

                    await Execute(batchfile, resultFolder);
                }
                // Wait until it's done
                WaitUntilTestDone(folder, resultFolders);
                .....
            }
        }

Open in new window

In here. Execute() method returns string.
But I am getting the following error on await line:
('string' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' accepting a first argument of type 'string' could be found. (are you missing a 'using' directive or an assembly reference?)
What am I doing wrong?
0

.NET Programming

133K

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.