.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

Hello Experts
I have an old application (VB6) running on Windows 10 x64
The program works fine after installation until I restart the PC
Then the program refuses to work until I remove it and re-install it again. And also to reboot the device and so on.
the error message ( Unsupported value type:1001:error)
0
Architecture advice

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

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

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

We will have an Azure storage along with utilizing Docker.

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

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

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

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

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

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

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


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

                cmd.CommandText = query;

Open in new window

0
Greetings

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

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

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

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

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

        ftpRequest.Method = WebRequestMethods.Ftp.UploadFile

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

Open in new window

0
Hello Experts,

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

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

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

    }

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

Open in new window


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

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

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

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

Does anyone have a working solution for this?

Thanks.
0
Hello,

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

Thanks
0
Hi,

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

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

        public TestProperties Lunch => throw new NotImplementedException();

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

Open in new window


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

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

Open in new window


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

Open in new window

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

Can anybody explain what's going on with this code?
0
Reallocating space on my MacBook's 500 GB drive to make room for Azure, Linux and Windows 10

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

Windows 7 (1).pvm

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

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

Any suggestions would be appreciated.

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

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

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

Sample of code I nether get to match success

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

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

Open in new window

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

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

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

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

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

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

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

            //This is the setup to make the PlaySiren sub work, to play a .wav on the scanner for errors...
            public class win32
            {
                  [DllImport("coredll.dll",EntryPoint="PlaySoundW", …
0
https://developers.google.com/calendar/quickstart/dotnet
I hope to get list of music concert event based on the zip codes
and I used above google api.

can you guide me how to filter just music event and zip?

I use c#
0
Anybody installed Visual Studio 2019 yet?

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

Let me know.

Thanks
0
Hello,

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

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

Open in new window


Please advice.

Thanks.
AccountController.txt
Startup.txt
Login.txt
0
How uninstall old version of .net framework and install new version with logging into user devices
0
Hello,
Any suggestion on how to go about:
Web-scraping and data processing solutions

Thanks
0
Regex is so nuanced sometimes. I need a bit of help creating a regular expression that will capture the contents of a function so the outer function can be replaced while preserving the entire contents of the function.

Perhaps a brief explanation of exactly what I'm trying to accomplish will help any prospective experts understand my needs a little better. I need to do this because I have to do a mass replace on a lot of files containing queries that were originally written for Oracle. I need to make them compatible with Microsoft SQL Server. The specific example here is the Oracle TRIM(...) function. Microsoft SQL Server doesn't have this function but would instead use LTRIM(RTRIM(...)). This actually also works fine in Oracle so it's a bit of a no brainer to replace TRIM(MyColumnName) with LTRIM(RTRIM(MyColumnName)). Unfortunately, sometimes the contents of the TRIM(...) function may contain other functions. For (bad) example, TRIM(Coalesce(Sum(InvoiceTotal), 0)). The simplest Regex Replace would be to look for "TRIM(" and then find the nearest ")" but that won't work in this case because I'll end up with LTRIM(RTRIM(Coalesce(Sum(InvoiceTotal)), 0)) which is wrong. What I need instead is LTRIM(RTRIM(Coalesce(Sum(InvoiceTotal), 0))). As you might be able to see, I need a balancing group to accomplish this and make sure I have the parentheses matched properly.

I've read up on balancing groups here: …
0
Hi


How do I write the FromXml to read an xml file into the given opbject?

Once read in I need to test if a given OldPath exists


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

class MainClass
{
    class Program
    {


        // create two logs to hold each list
        
        public static List<HistoryLog> historyLogs = new List<HistoryLog>();
        static List<DownloadLog> downloadLogs = new List<DownloadLog>();

        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World");
            // Dummy varibles;

            int myID = 123;
            int FileCount = 234;
            string ModName = "Hello World";
            string OldDir = @"D:\Path\To\OldPath";
            string NewDir = @"D:\Path\To\NewPath";

            if(File.Exists("DownloadLog.xml") ){
              Console.WriteLine("Hello DownloadLog.xml");
              downloadLogs.FromXml("history", "DownloadLog.xml");

            foreach (var downloadLog in downloadLogs)
            {
                Console.WriteLine("download Name: {0} download OldPath: {1}  ", downloadLog.Name, downloadLog.OldPath );


            }


            }
            else {


            // make a loop just   to test
            // this is to simulate where the infomation will be
            // derived from  with some condition deturmining if 
       

Open in new window

0
I am trying to write code that will determine the resolution of the screen the user is using in order to properly size charts.  I am having trouble getting anything to work. Can someone please help? I am using ASP.Net chart control and vb.net.

Following is code that does not work.

Thanks for the help.

Dim CurScreenWidth As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim CurScreenHeight As Integer = Screen.PrimaryScreen.Bounds.Height
        Dim DesignWidth As Integer = 1680        
Dim DesignHeight As Integer = 1050 
        Dim WidthRatio As Single
        Dim HeightRatio As Single

        WidthRatio = CurScreenWidth / DesignWidth
        HeightRatio = CurScreenHeight / DesignHeight

        Dim ChartWidth As Single = DesignWidth * WidthRatio * 0.96         
Dim ChartHeight As Single = DesignHeight * HeightRatio * 0.85

Open in new window

0
Greeting,

I am converting and old VB6 program to VB.NET. Currently I am working on the function that takes a 'Listing File'  and uploads it to eBay. This function uses the eBay File Exchange API and has worked flawlessly for years within the VB6 program. I have modified/Converted it to VB.NET but I am still having some kind of issue with it. The API seems to execute fine but I receive the following error from the File Exchange 'Manager': "An unknown problem interrupted the file transfer. Please try again" The file that I am using as a test works fine and is uploaded to eBay  from the VB6 program so I am confident that the file is good with no syntax errors. I know that this might be a difficult task but hopefully another set of eyes can help me. I am including both function here for comparison.... Thanks in advance - Rick

------------------------------------
VB6
--------------------------------
Private Function PostListingsToEbay(UploadFileName As String) As String
        
    On Error GoTo MyTmpError
    
    Dim xmlHTTP As New MSXML2.ServerXMLHTTP40
    
    Dim MyBase64 As New Base64
    
    Dim XMLNodeValue As String
    Dim sContactURL As String
    Dim sUploadContents As String
    Dim sResponse As String
    
    Dim csUserNamePassword As String
    Dim sFileName As String
    
    Dim sEntityBody As String
    
    Dim MULTIPART_BOUNDARY As String
    
    Dim RtnVal As Integer
    Dim RtnValue As Integer
    
    RtnValue = MsgBox("Are You 

Open in new window

0
I am looking out on my local server and I did search for "Oracle.DataAccess.dll". I can see this file in two different directories. Can an Oracle or Microsoft.NET expert tell me the difference between the bin\2.x and bin\4 folders?

1. C:\dbms\oracle32\product\12.2.0\client_1\odp.net\bin\2.x

2. C:\dbms\oracle32\product\12.2.0\client_1\odp.net\bin\4
0
OK Greetings..

I have done some searching and I have not quite found the answer to my issue so I guess I will ask the question here. (I'll include code snippets)

(1) I use Visual Studio 2017 express
(2) I Use Visual Basic .NET
(3) I am creating a Windows Application

OK.. I have a ListView Control  contained with a TabControl on a Form... The ListView has a Header of 40 fields and I can populate as many rows as I desire each with 40 fields of data.. (all working).

I need to get each row from the list and output that row data to a .TXT file but NOT All of the fields of data and NOT in the same order as represented in the ListView Header.

I actually have most all of this working EXCEPT my code will output a Duplicate record for the number of records within the ListView control..  Example if I have 3 rows of data and a header record  it will successfully output the desired number of data fields in the desired order for the first row of data then it will REPEAT/DUPLICATE that row of data for the number of rows in the ListView Control and then one more for the Header row.. ie 4 in the current example..

The following code snippet  is what I currently have and need a bit of help. Please note that I load the Header field names into an Array and then use that array
to INDEX into the ROW Item data.

BTW I hope that this is the right way to ask and or present questions to EE.. If not please let me know.
Thanks in advance.

Rick
0
I have a c# application.
I am trying to Loop through records in a Grid with the  purpose of writing same into a table.
The full script is shown below.
The first 3 parameters are coming from a master record and this seam ok.

When i got to the line below

 foreach (DataGridViewRow dgvRow in dgvDetailsTable.Rows)

 dgvDetailsTable.Rows was flagged  as an error  even though
that is my gridname.


using (var command = new NpgsqlCommand("public.spjobhistory_insert", conn))
                {
                    conn.Open();
                    command.Parameters.Add(new NpgsqlParameter("staffnox", NpgsqlTypes.NpgsqlDbType.Varchar) { Direction = ParameterDirection.Input, Value = model.Staff_no });
                    command.Parameters.Add(new NpgsqlParameter("companycodex", NpgsqlTypes.NpgsqlDbType.Varchar) { Direction = ParameterDirection.Input, Value = LoginDetails.staticcompany });
                    command.Parameters.Add(new NpgsqlParameter("EmpIdx", NpgsqlTypes.NpgsqlDbType.Integer) { Direction = ParameterDirection.Input, Value = model.EmpId });
                   
                    foreach (DataGridViewRow dgvRow in dgvDetailsTable.Rows)
                    {
                        if (dgvRow.IsNewRow) break;
                        else
                        {
                            command.CommandType = CommandType.StoredProcedure;
                            //dgvtxtCompName
                            //dgvStartDate
            …
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.