.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 have an Excel add-in firing an HRESULT 0x800401A8 error, when calling the getter of Worksheet.Parent.

I would be glad if anyone could let me know what the error might be, but more importantly and more generally, I would like to know how I can understand these HResult codes?

I did the following but am still confused:

Read the Microsoft's documentation on the Structure of COM error Codes.
Checked this SO thread.
Tried my chances with Magnum DB.

Thanks!
0
Need .NET Framework VDI / VM Preconfigured

Are there VDI's where Visual Studio / SQL Server / Source Code Management

come pre-installed? That would save me some potential aggravation...

Thanks
0
C#: Please explain relationship between "async" and "await"

I generally see how this code works:

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/

but need a better understanding of when to use both "async" and "await" together. I was a little confused by the transition of one paradigm to the the better paradigm in this one example...so, a simple explanation would be helpful.

Thanks.
0
Need a C# Web Service to call external Web Services. How?

I need to create a back-end web service which then calls a small handful of external web services in order to complete the calculations. Is this a simple task? Using C# to execute an external web service?

How would I call four different such calls at the same time? Does this qualify as "parallel processing"? Anything fancy needed? Or, can I quickly call one after the other, then get a callback for each?

How does this work?

Thanks
0
How can I upload a system that was developed with ASP.net/SQL Server to Microsoft cloud?
They are decommissioning all physical servers and want to move this system Aldo, so the users can use it in the MS cloud.
0
I am brand spanking new to ASP.NET MVC and I'm working through a tutorial to get the basics. The tutorial is in C# and I'm converting it to VB to stay consistent with some related projects. I have to assume that I'm missing something in that conversion but can't figure out what it could be.

I have the following class:

Public Class GuestResponse
    Public Name As String
    Public Email As String
    Public Phone As String
    Public WillAttend As Boolean?
End Class

Open in new window


and a strongly-typed view related to that class:

@ModelType PartyInvites.GuestResponse

@Code
    Layout = Nothing
End Code

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>RsvpForm</title>
</head>
<body>
    @Using Html.BeginForm
        @<p>Your name: @Html.TextBoxFor(Of String)(Function(x) x.Name)</p>
        @<p>Your email: @Html.TextBoxFor(Of String)(Function(x) x.Email)</p>
        @<p>Your phone: @Html.TextBoxFor(Of String)(Function(x) x.Phone)</p>
        @<p>
            Will you attend?
            @Html.DropDownListFor(Of Boolean?)(Function(x) x.WillAttend,
                                                        New SelectListItem() {New SelectListItem With {.Text = "Yes, I'll be there", .Value = Boolean.TrueString},
                                                        New SelectListItem With {.Text = "No, I can't come", .Value = Boolean.FalseString}}, "Choose an option")
        </p>
        @<input type="submit" value="Submit RSVP" />
    End Using
</body>
</html>

Open in new window


My controller has a simple action method that takes that class and responds with another view:

<HttpPost>
Function RsvpForm(g As GuestResponse) As ViewResult
    'TODO: Email response to the party organizer
    Return View("Thanks", g)
End Function

Open in new window


Unfortunately, the form data from the post request isn't being populated in my GuestResponse class. If I insert a breakpoint in that action method, all the GuestResponse properties are empty. At the same time, the Request.Form values look as expected - they're just not filling in the GuestResponse object.

I'm sure it's something small I'm missing. Any help is appreciated.
0
I am testing some web parts in SharePoint 2019 that were developed for SharePoint 2010. I have installed Visual Studio 2019 on my dev server, and the projects have been upgraded when Visual Studio offered to do so.When I try to deploy a web part, I get the error: "Error occurred in deployment step 'Recycle IIS Application Pool': Cannot connect to the SharePoint site: http://ehnordic/default.aspx/. Make sure that this is a valid URL and the SharePoint site is running on the local computer. If you moved this project..."
I have double-checked the URL (it is an internal URL) and it is correct. Then why do I get this error?
0
I'm looking at database monitoring and seeing that nearly all of our SQL databases report a high degree of fragmentation in their indexes. 99.8-99.9% fragmented is not uncommon. Can this play significantly into poorer performance for database interactions from .NET web servers which integrate with SQL?
0
Hi Experts!

Need your help.
In C# LINQ how do you get the latest enrollment and return a List that's ordered by PerId?

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTestProject2
{

    internal class Enrollment
    {   public int  PerId;
        public string Class;
        public Nullable<System.DateTime> DateFrom;
    }

    [TestClass]
    public class UnitTest2
    {
        [TestMethod]
        public void LinqQuery()
        {
            //Arrange
            List<Enrollment> latestEnrolled = new List<Enrollment>()
            {
                new Enrollment() {PerId = 1, Class = "Chemistry", DateFrom = new DateTime(2018, 1, 1)},
                new Enrollment() {PerId = 1, Class = "Modern Drama", DateFrom = new DateTime(2017, 1, 1)},
                new Enrollment() {PerId = 1, Class = "Math 302", DateFrom = null},
                new Enrollment() {PerId = 3, Class = "Physics", DateFrom = new DateTime(2016, 1, 1)},
                new Enrollment() {PerId = 3, Class = "Comp 101", DateFrom = new DateTime(2017, 1, 1)},
                new Enrollment() {PerId = 3, Class = "Music", DateFrom = new DateTime(2017, 6, 1)},
                new Enrollment() {PerId = 2, Class = "Leadership", DateFrom = null},
                new Enrollment() {PerId = 2, Class = "Film Study", DateFrom = new DateTime(2017, 1, 1)},
                new Enrollment() {PerId = 2, Class = "Microbiology",

Open in new window

0
original error causing showing upHello,

A strange problem popped up on Visual Studio 2019 today.  Both Projects were created recently in VS2019 vb.net

1) Project A built and working no problem on my machine and everyone else's machines.  It includes a reportview v 15.0.
2) Project B needed a new report made but I wanted to make it a local report (populated with data that was already queried and brought down from the server and residing in a dataset).  I couldn't remember how to do this so I was fiddling with some of the settings in VS 2019 for THAT project and THAT report.  So I thought...

3) When I return to Project A I get a "required privilege is not held by the client" error when executing the reportviewer1.refresh command.  Everything else in the program seems to be working fine.  Earlier versions of Project A produce the same error BUT ONLY ON MY COMPUTER.  Everybody elses works just fine.  I broke something somewhere but I have no idea where to start looking.

Any ideas are welcome.  I've already flushed out the bin, reset VS settings, Reloaded the reportviewer references, and now the project won't build at all.  Got worse as I tried to fix it....

Thanks
0
Hi,
I just installed a new Microsoft Surface for my customer on their Windows 2012 domain network.

The network has a WSUS server for all updates.

.NET 4.0 was installed by default on the laptop.

However the customer has some applications that need .NET Framework 3.5 which is NOT installed by default on new Windows 10 install.

When I try to add it through Control Panel / Programs / Windows features I get an error :
Error code:  0x800F0954

I've done some googling which is suggests there is Microsoft BUG or problem where Windows 10 is unable to install .NET Framwork 3.5 from WSUS.

I can't believe Microsoft would fail to provide for a WSUS mechanism to install .NET - or in indeed any feature from Windows Features.....

Can someone please assist / advise here ?


Picture1.png
Picture2.png
Picture3.png
Picture4.png
0
Need to install Node.js on my Windows 10 .NET Development machine

I need to install Node so I can install jsinspect so I can find code duplication that got there through heavy us of copy-paste.

I have worked with Node in the past. But, I want to be 100% sure I am not going to in any way harm my Windows PC, since that is my bread-and-butter machine.

Can you provide me the safest set of steps to do this?

Thanks
0
Duplicate code removal with ReSharper?
 
I read it now helps highlight duplicate code, but at jetbrains.com I am not finding an specific feature for that.

At the moment, I care most about UI files, first and foremost HTML and Javascript.

Does anyone know if ReSharper highlight duplicate code within a file? And between different files?

IO am about to get the 30-day free trial. But, before I start the clock, I hope to nail down even if that feature exists.

Thanks
0
I have a SBS 2008 SP2. I need to install .Net Framework 4.8. I can't seem to be able to find the download that will not error when trying to instal. Te error referenced a compatibility problem.
0
Does Selenium support White Box Testing?

We developers find that sometimes a lengthy test can be truncated by us doing a particular database query during the test workflow. So, I wonder if Selenium can be configured to perform such a database query?

This seems to be White Box testing. Can Selenium  do this?

Thanks
0
My IT team installed the Trend Micro antivirus software couple of months ago. Since then, our in-house built .NET program that deployed via ClickOnce technology got this message prompting out every time we launch the program.

Untitled.jpg
We know that this is relating to Trend Micro's feature of Newly Encountered Program Detection

Understanding Behavior Monitoring detections in OfficeScan
https://success.trendmicro.com/solution/1121152-behavior-monitoring-detections-officescan#collapse4

But how can we bypass this configuration so that the prompt of Newly Encountered Program Detection can be disabled for our in-house built .NET program?

We tried to include the installation path of .NET program (such as C:\Users\xxxxxx\AppData\Local\Apps\2.0) into the Trend Micro's Exclude List in local machine, but it doesn't help and the message is still keep prompting.

Any help is greatly appreciated, thanks.
0
Just wondering about the following C# syntax:

public ActionResult<Pet> Create([FromBody] Pet pet)

What is [FromBody] doing and how long has this been a part of the language?
0
recently, we have PCI audit. and the report tells us to make the machine.config debug to false.
I found this article: https://dotnetstories.wordpress.com/tag/machine-config/

If I add below inside of  the machine config. Does it mean the debug mode is false to all of the websites within IIS?

<system.web>
<deployment retail=”true” ></deployment>
</system.web>
0
public async Task<IActionResult> Login(LoginViewModel model, string returnUrl = null)
{
    if (ModelState.IsValid)
    {
      // work with the model
    }
    // At this point, something failed, redisplay form
    return View(model);
}

Open in new window


Expert please explain me why

One has to validate i.e below

if (ModelState.IsValid)

Open in new window


Can this view object can be used in services structure where business logic resides.
0
namespace DataLayer.DataClasses.Concrete
{
    public class Blog
    {
        public int BlogId { get; set; }
        [MinLength(2)]
        [MaxLength(64)]
        [Required]
        public string Name { get; set; }

        [MaxLength(256)]
        [Required]
        [EmailAddress]
        public string EmailAddress { get; set; }

        public ICollection<Post> Posts { get; set; }

        public override string ToString()
        {
            return string.Format("BlogId: {0}, Name: {1}, EmailAddress: {2}, NumPosts: {3}",
                BlogId, Name, EmailAddress, Posts == null ? "null" : Posts.Count.ToString());
        }
    }
}

Can let me know why ICollection being used instead of List or Arraylist which is better ICollection or ArrayList?
I am just a beginner in C sharp
0
Hi,

I have some procedural .NET core code I would like to convert to Linq - or at least get as close as I can.

From the code below have "group_list" generated via linq.

Thanks,

Ward.

using System;
using System.Collections.Generic;
using System.Linq;

namespace Linq_Test1
{
    class Email_Message
    {
        public string From;
        public string From_Address;
        public string Subject;
        public DateTime TimeRecieved;
        public string Body;
        public string Message_ID;
    }

    class Email_Group
    {
        public string From;
        public string From_Address;
        public List<String> Message_ID_List = new List<string>();
        public String Combined_Body;
    }
    class Program
    {
        static void Main(string[] args)
        {
            List<Email_Message> message_list = new List<Email_Message>();
            List<Email_Group> group_list = new List<Email_Group>();

            Email_Message message;

            message = new Email_Message();
            message.From = "A"; message.From_Address = "a@test.com"; message.Subject = "Subject 1";
            message.TimeRecieved = DateTime.Now; message.Body = "Body A-1"; message.Message_ID = Guid.NewGuid().ToString();
            message_list.Add(message);

            message = new Email_Message();
            message.From = "A"; message.From_Address = "a@test.com"; message.Subject = "Subject 2";
            message.TimeRecieved = DateTime.Now; message.Body = 

Open in new window

0
I've created a react app and an API that I'm trying to make a call to through my react app. How do I do this? I'm doing this on my local machine (lap top). I'm using .Net Core 2.2 for my react app and .Net Core 3.1 for my API. What files or code other information can I / should I share to get the best help with this. I set up the React project right out of the box in Visual Studio 2019 as instructed by a basic tutorial. My API has been tested using swagger and it does work. Its very basic right now. React Error
1
Hi

I'm using npgsql for first time with postgres 11 db

My code is as follows

    cmd = new NpgsqlCommand("INSERT INTO \"tracking_dataa\"(imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data)	" +
                                                                          "VALUES(@ImeiNumber, @GPSDateTime, @EventId, @Speed, @Latitude, @Longitude, @Heading, @RawData);", con, transactSql)
                                {
                                    CommandType = CommandType.Text
                                };
                                cmd.Parameters.AddWithValue("@ImeiNumber", item.ImeiNumber);
                                cmd.Parameters.AddWithValue("@GPSDateTime", item.GPSDateTime);
                                cmd.Parameters.AddWithValue("@EventId", item.EventId);
                                cmd.Parameters.AddWithValue("@Speed", item.Speed);
                                cmd.Parameters.AddWithValue("@Latitude", item.Latitude);
                                cmd.Parameters.AddWithValue("@Longitude", item.Longitude);
                                cmd.Parameters.AddWithValue("@Heading", item.Heading);
                                cmd.Parameters.AddWithValue("@RawData", item.RawData);
                            
                                cmd.ExecuteNonQuery();

Open in new window


However, I get the error
{"42P01: relation \"tracking_dataa\" does not exist"}

Open in new window


i've tried the following

INSERT INTO \"tracking_dataa\"(imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data

INSERT INTO tracking_dataa (imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data

INSERT INTO \"public\".\"tracking_dataa\"(imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data

INSERT INTO public.tracking_dataa (imei_number, gps_datetime, event_id, speed, latitude, longitude, heading, raw_data

Open in new window


Nothing seems to work, the same error exists

When I browse my DB in Navicat, the table is under the public schema and I can connect fine

What am i doing wrong?
0
I have a feeling that my app is not reading my appconfig file

I know this because i tried 2 IP address for the local server (127.0.0.1)  and an external server  (99.99.99.99)  (Please note that 99.99.99.99  is just a dummy)


in the connection string section (see below)

 <connectionStrings>
    <add name="Tournaments" connectionString="Host = 99.99.99.99; Database = tournaments; Port = 5432; Username = postgres" />
  </connectionStrings>

on both runs it was only connecting to the local server 127.0.0.1 and running my userprofile   form

I tried to debug the application starting with the first line in program.cs

and each time it run my userprofile  form connectining to  127.0.0.1.  I dont even know where it picks 127.0.0.1  when i am using the external server

How can i confirm and ensure that my application recognises and uses the connection string

in the appconfig file.

below is my program.cs  and appconfig   scripts


 
 static void Main()
        {
            DatabaseType db = default(DatabaseType);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            GlobalConfig.InitializeConnections(true, db);
            Application.Run(new UserProfileForm());
          
        }

Open in new window


<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="filePath" value="C:\data\TournamentTracker" />
    <add key="greaterWins" value="1" />
    <add 

Open in new window

0
Hi,

I'm looking at ways to convert MGRS coordinates to Decimal  Latitude, Longitude  I've come across CoordinateSharp  the Developer Guide makes use of tryParse but dosn't seem say how to trap the errors nor dose the dotnetfiddle example

I also note the output is Degree minute seconds not digital

The Developer Guide Suggests "c.FormatOptions.CoordinateFormatType = CoordinateFormatType.Degree_Decimal_Minutes;"


However this Errors

		string mgrs = "16R CV 05774 44722";
		Coordinate c;
		if(Coordinate.TryParse("16R CV 05774 44722", out c))
		{
			c.FormatOptions.CoordinateFormatType = CoordinateFormatType.Degree_Decimal_Minutes;

			Console.WriteLine(c);
		}

Open in new window


So how do I rewrite the above trapping errors and output to  Decimal  Latitude, Longitude variables?
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.