C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

Share tech news, updates, or what's on your mind.

Sign up to Post

I've written a C# asp.net application that uses Microsoft.Office.Interop.Excel.  Application creates an Excel spreadsheet, saves it and then tries to close and quite Excel but the Excel process is still running in the Task Manager.  (same code works in a console app or Windows Forms application but not in my asp.net web app).

Here is the basis of the code:

using MyExcel = Microsoft.Office.Interop.Excel;
MyExcel.Application xlApp;
MyExcel.Workbook xlWorkBook;
MyExcel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
 xlApp = new MyExcel.Application();
 xlWorkBook = xlApp.Workbooks.Add(misValue);
 xlApp.DisplayAlerts = false;
 xlWorkSheet = (MyExcel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
 xlWorkSheet.Name = "Daily Report";
xlWorkBook.SaveAs(myFile, MyExcel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, MyExcel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

Open in new window

Hello, and thank you for your assistance!

I would like a graphical design interface to edit and dress up some web pages that I will create using Microsoft C# MVC Code First migrations, which create CSHTML files with Razor code within them.  Is there a tool that will let me drag & drop, etc., move things around visually and let the tool change the file as I design it?  And if there are several, which one or ones are the easiest to learn & use?  I am also in a time crunch with this project.  

Many thanks!

Hello Experts,

I am fairly new to C# programming for MS Word document.
I am trying to create an interactive Word document for users.
I have separate csv file that has values for "Country Name, Country code".
Now from my word document, I want users to have ability to search by country name and pick the value of country code to the text box in Word.
Not sure if have to use any local database like SQLLite or how I can make this search interactive for users from the Word document.
Can you help by throwing pointers that I can use to get started.

Thank you.
I have mailchimp call from API.
but I do not know how to show the value on the aspx.

Can you show me how to do that?

{ "members": [ {
    "id": "f777bbffab8d1ceca8b757df63c47cb8",
    "email_address": "urist.mcvankab+1@freddiesjdfasdfokesasdfds.com",
    "unique_email_id": "882e9bec19",
    "status": "subscribed",
        "FNAME": "",
        "LNAME": "" },
        "9143cf3bd1": true,
        "3a2a927344": false,
        "f9c8f5f0ff": false,
        "f231b09abc": true,
        "bd6e66465f": false },
//And so on...

public static List<mailchimp> DeserializeAccounts(string json)
            return JsonConvert.DeserializeObject<List<mailchimp>>(json);

public class mailchimp
        [JsonProperty(PropertyName = "id")]
        public string id { get; set;}

        public mailchimp()
            // Setting default values here
            // With C# 6 we could use auto property initializers above instead!
            id = "-1";            
or an OPENXML spreadsheet, can you create all the rows needed like this loop

for (uint i = 1; i < 44; i++)
 row = new Row() { RowIndex = i };

Open in new window

And elsewhere in the code reference specific rows and create new cells etc as needed
row1.RowIndex = 5;

//create a new cell
Cell celltest = new Cell() { CellReference = "I5", DataType = CellValues.String, CellValue = new CellValue("Issue:"), StyleIndex = 7 };

//append the cell to the row

Open in new window

And then update cells later by referencing the specific row index?
Do the cells need to be created/updated during the creation of each row?

I am not having much luck with this approach and want to ensure I am not going crazy.

Jed -
I have an c# application created in VS2005(.Net Framework 2.0) using Microsoft Interop Word Dlls.
Now we are migrating this application to Windows 10 and while building the solution I get the below errorsScreen shot of Word Interop ErrorScreen shot of Word Interop ErrorScreen shot of Word Interop ErrorScreen shot of Word Interop Error
I am trying to get a Salesforce report into a C#.net application so I can save as a datatable,  then saving as a CSV file, i am able to connect and get what seems to be the report data but cant figure out how to use the data.

Can someone point me in the right direction on how to use the data from the report - thanks

Code I am using

        static void Main(string[] args)

            System.Net.ServicePointManager.Expect100Continue = true;
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

            var task = ExecuteReport();


        public static async Task<string> ExecuteReport()
            var sf_client = new Salesforce.Common.AuthenticationClient();
            sf_client.ApiVersion = "v39.0";
            await sf_client.UsernamePasswordAsync(consumerKey, consumerSecret, username, password + usertoken, url);

            string reportUrl = "/services/data/" + sf_client.ApiVersion + "/analytics/reports/" + reportId;

            var client = new RestSharp.RestClient(sf_client.InstanceUrl);
            var request = new RestSharp.RestRequest(reportUrl, RestSharp.Method.GET);
            request.AddHeader("Authorization", "Bearer " + sf_client.AccessToken);
            var restResponse = client.Execute(request);
            var reportData = restResponse.Content;

             return reportData;

Open in new window

I had this question after viewing Textbox Textchanged event doesn't fire....

I have a number of problems with using C# Tasks.

I have put all my questions in code but have copied them in here.

Given I have a number of questions I am hoping to get as many answered as I can. As I suspect the same problem might be causing the others.

Ideally I would like to get some edits to the code below to fix the problems.

If I need to I will adapt the code and post some extra questions with what is left to offer some more points in other questions.




 Here is some code that will simulate processing items in a queue. I want it to process from 1 - n and do it asynchronously and display
 a progress bar and for the UI to be responsive. Ultimately it will be reading file btw. I can work that bit out. Just getting the UI part

 For example if I put in 3 items.

 1 - Count from 1 to 100.
 2 - Count from 1 to 100.
 3 - Count from 1 to 100.

 So an interim result would look like this.

 1 - 35%
 2 - 20%
 3 - 30%

The final display would look like:

 1 - 100%
 2 - 100%
 3 - 100%
 The number of items determines how many C# tasks I should create and use from processing.

 Here are the issues / questions:

1. The items are not processed sequentially in the UI.
2. If I put in a large number like 1000 it only displays when the work is done.
3. Also with the large number like > 100 then the progress bar will sometime display on items = 101
4. The UI seems un-responsive on a large …
Hello EE,

In vb.net, I have a dictionary(Of Date, String).
Looks like this :

01/01/2018         Robert
01/02/2018         Steve
01/03/2018         Jenny
01/04/2018        Paul
01/05/2018        Veronica
03/11/2019         Jenny

Open in new window

With this, in marketing we have some code that, if let's say as of now, if Jenny still was not picked up with our system, she will be in a list like this :

Jenny  - 90 days
robert - 56 days
Phil - 42 days
Catherine - 41 days

Open in new window

meaning, its been 90 days that Jenny was not picked up by our system in marketing.
if tomorrow she gets picked up, she will be removed from the list and if the others were not picked, it will go like this :

robert - 57 days
Phil - 43 days
Catherine - 42 days

Open in new window

so Jenny is not in that dictionary(Of string, Integer) any more, but the others are and their days has been increased by one.

so all this works well.

My question is :   If I would like to check the history and the past, "who was picked up every week for the whole year", without manually writing it on a paper, how can I do it in vb.net ?
You see, we keep everything in the first dictionary I showed on top. the dictionary (Of Date, String) I have all the picks.

I would like to retrieve in the past, by week who was picked
so maybe in one week there is just 1 .. maybe in one week there are 3..
Because when it picks days goes to "zero" I have a hard time in vb.net, linq, and so forth, to do a function that goes back in time and read all this

can you help ?
I want to upload a local file into a remote file using C# SSH.NET library using SFTP client. I am able to do that in the parent directory , but when I want to upload file in a child directory , It is returning null .
My remote directory structure is /xyz/abc/finaldir . i want to upload a file in finaldir . That is not working . It is able to read xyz directory and abc directory and not finaldir.
When i try to change directory to /xyz/abc/finaldir for SFTP client It is throwing error telling "file not found"
Please help me !
How can I get / retrieve all members of a specific Sharepoint group with C#?
For example I have the Sharepoint group "Visitors" and I need all members of it respectively their e-mail adresses.
How to read multiple result sets from edmx? Edmx is always returning first result set. How to Fetch all result sets ?
Hello Experts,
In a web from I am trying to get confirm window stating "All the selected rows will be deleted, would you like to continue?".  I need two buttons "Yes" and "No".  All the above should happen when I click a "Delete" button on the screen.  Please help.

Thank you very much in advance.
Hi there, I am using C# wpf and trying to operate on a rich text finding and replacing words and formatting them in bold italics etc by using code behind. What is the simplest way to do it as I have read many complicated options and can't decide on one. Thanks.
Hi Experts,

Can you please share me the solution in C# to upload the document and file information to another system by using the restful request .

I have following :

1) Url ( They provided the service url to upload the documents)

 I try to send messages to lock screeen  in windows 10 through my uwp application

according to this

I have create on button click event

 private void button_Click(object sender, RoutedEventArgs e)
            Microsoft.Toolkit.Uwp.Notifications.TileContent content = new Microsoft.Toolkit.Uwp.Notifications.TileContent()
            Visual = new Microsoft.Toolkit.Uwp.Notifications.TileVisual()
                LockDetailedStatus1 = "Meeting with Thomas",
                LockDetailedStatus2 = "11:00 AM - 12:30 PM",
                LockDetailedStatus3 = "Studio F",

                TileWide = new Microsoft.Toolkit.Uwp.Notifications.TileBinding()


        var notification = new TileNotification(content.GetXml());


Open in new window

but nothing happens when I click the button no errors no message. I have declare my app so to be used on background in Package.appxmanifest and I have also select
Control Channel, Push Notification and Timer in Declarations.

Any idea or other way to send notification to lock screen?

thank you!
Hi, I need to know how to force close one window from another in WPF.
I have one window,splash screen with do some background work. When it finish do all it have to it have to disappear and new window have to opens.
I use following code to do that:

MainWindow main = new MainWindow();


Open in new window

It works always on PC on tablet it works only one time after program was installed or tablet restarted,
Second time main window shows with splash screen over it.  Because the splash screen give to some global variables values that make possible to run Main form
I suspect the this splash screen not closed when application close. I close the application from main window:

Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;

Open in new window

It is very difficult to debug because the problem is visible only on tablet not on PC.
Because of that I think I have to force closing of Splash screen on some way
Here we go again...

So, for some reason, in the equation below the left side is considered an object and the right a decimal.

myWS.Cells[49, col].Value += myRecordSet.Fields["amount"].Value;

Is there any way to accomplish the feat above in C#?
Hi Experts,

I need to help on writing the C# code develop a following solution.

Basically my requirement is to export the files to another application through restful web-service call (POST).

They provided following  :
URL ( Insert document service )
its restful web service call  - POST

They are expecting the request  multipart/Mixed  with json structure.

Please let me know if any questions.

I want to live my android screen to display on my gridcontrol in c#. I think we can use  'adb screenrecord ' but I don't know how to create and send video streaming. thank you in advance.
I have
public class myPage: BasePage{
[FindsBy(How = How.XPath, Using = $"//img[@src='//{MyPath()}/img.png']")]
      public IWebElement MyImg {get; set;}


Open in new window

public abstract class BasePage{
     public string MyPath(){
          return result.toString();

Open in new window

inside myPage class, I used MyPath() inside the string interpolation.
And I am getting this error there.
an object reference is required for the non-static field method or property 'BasePage.MyPath()'

What's the reason that I am getting this error and how to fix it?

I have this datagridview filled with a dataset using C#.  The grid is designed to display up to 12 rows. In the screenshot you will see how it looks when there are less than 12 rows. Can anyone provide suggestions or provide that would illustrate how to fill in the extra rows with blanks  so the grid will allows appear full? Let me know if you want to see my code.
I have a code in java and need to write it in C # please help me. Thank you

import org.junit.Assert;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.RemoteWebDriver;

import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class BrowserProfile {
    public static void main(String[] args) throws Exception {
        BrowserProfile bp = new BrowserProfile();
        //TODO replace with existing profile ID. Define the ID of the browser profile, where the code will be executed.
        String profileId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

        //Define DesiredCapabilities
        DesiredCapabilities dc = new DesiredCapabilities();

        //Instantiate the Remote Web Driver to connect to the browser profile launched by startProfile method
        RemoteWebDriver driver = new RemoteWebDriver(new URL(bp.startProfile(profileId)), dc);

        //Perform automation
        Assert.assertEquals("Multilogin - Replace Multiple Computers With Virtual Browser Profiles - Multilogin",driver.getTitle());

    private String startProfile(String profileId) throws Exception {
        /*Send GET request to start the browser profile by profileId. Returns response in the following format:
        '{"status":"OK","value":""}', where XXXXX is the 

Open in new window

I have a c# asp.net application that needs to play 10 videos. Each video will need to be started by the user pressing the next button. Once a video ends then I need to write to the database that user completed the video.   I have setup  a Ajax control with a timer for the length of each video.   Once the timer fires, then I want to stop  the video from looping, record to the database the user id  and the video id.  Then when the user presses the next button start the next video.






C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).