C#

94K

Solutions

25K

Contributors

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 have an MS Access database and need to interface with a C# DLL that is about to be created for me (as a COM object).  My C# guy has no experience in interfacing with MS Access, and I have only interfaced Access with COM objects that I have purchased (EASendMail etc).  

We have run a few tests, and I can half interface with his test DLL (once referenced), but the Intelisense isn't working correctly.  However, whilst I am sure that we can overcome that one easily enough, it's the return messages that I am struggling to get my head around.  How do I tell Access to listen for them and then, trigger an event/function?

I know this is a little vague - but I could really do with some pointers to get started.
0
Learn Ruby Fundamentals
LVL 13
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

i have 10000+ images and I want to prevent people download the images. I am thinking using watermark (my domain name). and my question is below.

1. using c# and mvc / razor, is it possible to add watermark on the image? like a domain name from left top to right bottom.
2. if the watermark text is added, will it still show on the image if someone downloaded it?

3. do you have any ideas beside the watermark?
0
Hi, I have the float array which is populated in c#

temperatureData= new float[570, 429];

Open in new window



I then prepare the data in c# to be send to the front end by doing the following (this might be where its going wrong)

System.Web.Script.Serialization.JavaScriptSerializer jSearializer = new System.Web.Script.Serialization.JavaScriptSerializer();
jSearializer.MaxJsonLength = int.MaxValue;
pd.TemperatureDataArray = jSearializer.Serialize(temperatureData);

ViewBag.TempDataArray = pd.TemperatureDataArray;

Open in new window



then in the front end i have

var tempDataArray = @(ViewBag.TempDataArray);


var imageTemperatureDataArray = JSON.stringify(tempDataArray);
imageTemperatureDataArray = JSON.parse(imageTemperatureDataArray);


alert(imageTemperatureDataArray[321, 228]);

Open in new window


However the value in position 321,228 in JS is not the same as in C#, so i assume its re-ordered the data some how


Can anyone advise where its getting muddled up?


I've attached the dataset which is was taken on a BP on this line
ViewBag.TempDataArray = pd.TemperatureDataArray


The correct value in the float array at this position  [321, 228] should be 346.795624
However in the front end i'm seeing 304.92453
0
I have two lists of alphanumerics provided below, How could I ensure that they are sorted based on our regular expression i.e. [Z-A, 9-0] and [0-9, A-Z] . In list two blank should come first as mentioned in List-2.

List-1
T
S
IApplicationCache
D
A
10
9
8
7

Open in new window


List-2
""
1
2
34
56
A
B

Z

Open in new window

0
Trying to convert VB code to C#. Never really worked with C#. It's just taking a pulling the information from a JSON file so I can upload to a database. Have in VB but want to switch to C#. Below is the VB code:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim filePath As String =
            IO.Path.Combine(_desktop, "Upload.txt")

        Dim data As Upload =
            JsonConvert.DeserializeObject(Of Upload)(IO.File.ReadAllText(filePath))
End Sub
Public Class Upload
        Public Property Primaryimage() As WebImage
        Public Property Secondaryimages() As List(Of WebImage)
        Public Property Notes() As List(Of String)
        Public Property SafetyPrecautions() As SafetyPrecautions
End Class
Class WebImage
        Public Property Alt() As String
        Public Property Src() As String
End Class
Public Class SafetyPrecautions
        Public Property Warnings() As List(Of String)
End Class

Open in new window


Might be all wrong but this is what I have for C#

public partial class frmProcessJsonFile : Form
    {
        private string _desktop;
        public frmProcessJsonFile()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string filePath = System.IO.Path.Combine(_desktop, "Upload.txt");

            Upload data = JsonConvert.DeserializeObject<Upload>(System.IO.File.ReadAllText(filePath));
                  }

        public class Upload
            {
             public IEnumerable<WebImage> Primaryimage { get; set; }
              
    }

        class WebImage
        {
            public string Alt { get; set; }
            public string Src { get; set; }
        }
    }

Open in new window


Any help would be appreciated.
0
I'm very new to MVC5 using razor. I've been able to stumble through some problems but I'm stuck now. Here's what I need to do:

  • Move items from one listbox control to another listbox control
  • Access/get the items from both list boxes at some point in time for processing

my model contains the following:

        public IEnumerable<SelectListItem> AllAvailableServices { get; set; }

        public IEnumerable<string> AllAvailableSelectedServices { get; set; }

		public IEnumerable<SelectListItem> AddedServices { get; set; }

		public IEnumerable<string> AddedSelectedServices { get; set; }

Open in new window


my view contains the following. I would like to access the items in the AddedServices list when the user clicks the "Submit" button

@using (Html.BeginForm("Category", "Manager", FormMethod.Post))
{
    <table class="contain">
        <tr>
            <td>
                <table class="nav">
                    <tr class="nav">
                        <td class="navLeft">
                            <input type="submit" value="Submit" name="btnSaveCategory" class="button" onclick="location.href = '@Url.Action("UpdateCategoryAndServices")'"/>
                            <input type="button" value="Back" name="btnBack" class="button" onclick="location.href = '@Url.Action("Back")'"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
.
.
.
            

Open in new window

0
I have the following if statement that I'm returning a model if it match my current model. I'm trying to re write the example bellow without an if else statement. Any suggestions would be great...

        public ActionResult ReportWriter(ReportRequestViewModel viewModel)
        {
            bool hasAccess = true;
            if(!hasAccess)
            {
                return RedirectToAction("Index", "Reports", new { area = "Reports" });
            }
            ViewBag.IsAngularJS = false;
            var model = GetViewModel(viewModel.ReportType.ToString(), viewModel.ConfigurationId);
            var type = model.Data.GetType().Name;
            ReportViewModel vm = null;
            #region ViewModel Casting
            if (type.Equals("SalesReportViewModel"))
            {
                vm = model.Data as SalesReportViewModel;
            }
            else if (type.Equals("CustomerReportViewModel"))
            {
                vm = model.Data as CustomerReportViewModel;
            }

Open in new window

0
I have a chart control in asp.net that I am trying to display annotation in the chart area - topcenter of 'ChartArea1'.  It does not display on the chart.

Why?

Below is my asp.net code

<Annotations>
                                        
                                            <asp:TextAnnotation Alignment="TopCenter" Font="Arial, 10pt" ForeColor="#00FFCC"
                                                Name="Chart1Annotation" Text="Nominal" TextStyle="Default" ClipToChartArea="ChartArea1">
                                            </asp:TextAnnotation>
                                        </Annotations>

Open in new window

0
Hi I am using Authorize.net for payment gateway in my Asp.net code, It suddenly stopped working few days back, I want to fix that immediately, Please help me,
I am getting error on below line
myWriter = new StreamWriter(objRequest.GetRequestStream()
Error is The exception message is 'The request was aborted: Could not create SSL/TLS secure channel.'. See server logs for more details.
Here is code, My windows machine is Windows server 2008 and I have installed Framework 4.5.

    I tried to setup that on Windows server 2012 R2 and it is working fine there, Problem is in current Production machine which is 32bit machine, Is Authorized.net not compatible with 32 bit machine? Please let me know.

 
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
        String ApiLogin = System.Configuration.ConfigurationManager.AppSettings["ApiLoginL"];
        String TransactionKey = System.Configuration.ConfigurationManager.AppSettings["TransactionKeyL"];

    
        String post_url = "https://secure2.authorize.net/gateway/transact.dll";

        Dictionary<string, string> post_values = new Dictionary<string, string>();

        post_values.Add("x_login", ApiLogin);
        post_values.Add("x_tran_key", TransactionKey);
        post_values.Add("x_delim_data", "TRUE");
        post_values.Add("x_delim_char", "|");
        post_values.Add("x_relay_response", "FALSE");

        post_values.Add("x_type", "AUTH_CAPTURE");
        post_values.Add("x_method", 

Open in new window

0
Hi I am using Authorize.net for payment gateway in my Asp.net code, It suddenly stopped working few days back, I want to fix that immediately, Please help me,
I am getting error on below line
myWriter = new StreamWriter(objRequest.GetRequestStream()
Error is The exception message is 'The request was aborted: Could not create SSL/TLS secure channel.'. See server logs for more details.
Here is code, My windows machine is Windows server 2008 and I have installed Framework 4.5.

 ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
        String ApiLogin = System.Configuration.ConfigurationManager.AppSettings["ApiLoginL"];
        String TransactionKey = System.Configuration.ConfigurationManager.AppSettings["TransactionKeyL"];

   
        String post_url = "https://secure2.authorize.net/gateway/transact.dll";

        Dictionary<string, string> post_values = new Dictionary<string, string>();

        post_values.Add("x_login", ApiLogin);
        post_values.Add("x_tran_key", TransactionKey);
        post_values.Add("x_delim_data", "TRUE");
        post_values.Add("x_delim_char", "|");
        post_values.Add("x_relay_response", "FALSE");

        post_values.Add("x_type", "AUTH_CAPTURE");
        post_values.Add("x_method", "CC");
        post_values.Add("x_card_num", OrderD.CARDNUMBER);
   
        post_values.Add("x_card_code", OrderD.CVV);
       
        post_values.Add("x_exp_date", OrderD.MONTH + "" + OrderD.YEAR);…
0
CompTIA Network+
LVL 13
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

I had this question after viewing How to use OpenRequest() of CHttpConnection?.

I need to send a POST to Google.Vision server, using MFC and c++. The code is the following:

        CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded");
      CString strFormData = "{'requests':[{'image':{'source':{'imageUri':'https://www.galileo2000.it/download/1.jpg'}},'features':[{'type':'FACE_DETECTION'}]}]}";

      CInternetSession session;
      CHttpConnection *pConnection = session.GetHttpConnection(_T("https://vision.googleapis.com/v1/images:annotate?key=MY_GOOGLE_API_KEY"));
      CHttpFile *pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,_T("https://vision.googleapis.com"));
      BOOL result = pFile->SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData,strFormData.GetLength());


Actually I am not very fond on these topics, so I got the above code in Internet. But I successfully wrote a WebService in C#, which works. The strFormData is the same I use in the WebService, so it should be correct. The main doubt is the second parameter of the OpenRequest. Of course I get an error "Impossible to resolve the server or the address". (Unluckily the message is in Italian and I translated back to English, so the actual error message could be slightly different).
Thanks
0
I used open source Packet Capture(Pcap) and Wireshark to view video sent by USB Device.  The device sends 512 Bytes packet about every 200 us.  It's a composite device class.  It's a virtual port and bulk video.  Each monochrome raw frame is 640 x 480.

There is a GUI tool that runs in windows that extracts video from this USB device and plays video on the PC.  The company who wrote this GUI tool gave us the source code.  I opened this source code into Visual Studio 2017 Professional version without creating a solution or project.  There are Sixteen projects in this codebase.

The code is in C Sharp.  How do I find out if this codebase will build?  I didn't see any makefiles in this codebase.  Do I need to make any changes to build it?  Do I build project at a time?  How to find out if it's complete solution or just libraries?
0
This question is a two parter. First of all, using C#, is there a way to check the specific encoding information on a .WAV file? I know I am able to check things like the sampling rate, number of channels, etc. But I want to be able to detect if the .WAV file uses either µ-law (u-law), PCM, or any other formats I'm not aware of.

If the .WAV file turns out to be something other than µ-law, how do I convert the .WAV file into µ-law using C#?
0
I have a several JSON source files (about 500 MB total size, with 76,000 individual records) that I'm working on importing into a SQL database using C#.  I prefer importing into SQL using SQLBulkCopy, but to use that for multiple tables I would need to effectively create the entire database in C# before importing, or else read through every JSON file once for each table I'm importing.  

Neither option which seemed good to me, so I have written code to import each line of data individually using parameterized SQL queries, but that hits the database once for each record on each table.  There is also a potential problem in that our database has a record keys table for the primary key on each database table, and in order to not be writing to that table after every row insert (doubling the number of database writes), I'm keeping track of it in C# and updating it at the end.  The code to keep track of the value is more complicated than I would like, which means the risk of an issue is higher than updating it once after a SQLBulkCopy.

The most important question is which would be faster, parsing the JSON files once for every database table and using SQLBulkCopy for one insert per table, or parsing the JSON files once and writing each individual line?  Also, if the times are similar, it might be worth rewriting it to parse the files once for each table anyway, just to make the code simpler and reduce the likelihood of primary key errors.
0
I am trying to get a object out of IEnumerable collection which is in Dictionary.

I have a method which return IEnumerable of Employees. so In my code I am saying:

var emplist = employeelist.GetEmployeelist(ids);

Open in new window


I want a get a object depeding on the key i.e empid. So I am saying:

if(emplist.containKey(id)) { var emp = emplist.where(x => x.key == id);

Open in new window


so I am hoping that i would get the employee object in emp and can go though the emp object like emp.id, emp.name etc.

Could you please let me know how can i get the object from IEnumerable collection which is in Dictionary?
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
I need help using CKEDITOR with my form text area field.  http://docs.cksource.com/CKEditor_3.x/Users_Guide
I have a form field that is a text area. I need to update this field so that it works like a Rich Text Editor.  I have included the javascript file in my layout view as:
<script type="text/javascript" src="~/Scripts/ckeditor/ckeditor.js"></script>

My Database has a field for the Comments field that is a varchar(MAX) data type.
The Form View has a Text area field:

<div class="col-xs-6">
                @Html.TextArea("newComment", null, new
       {
           @class = "form-control",
           @type = "grow"
       })
</div>

I just display the notes as:  @note.Content
The onclick event of the Submit Button has:  onclick="editCR.addNote();

The JavaScript for addNote:
addNote: function () {
        this._post(SubmitNoteURL, {
            id: this.id,
            content: document.getElementById("newComment").value
        }, function (data) {
            var commentDiv = document.getElementById("commentArea");

            var para = document.createElement("p");

            var contentSpan = document.createElement("span");
            contentSpan.innerHTML = data.content;
            para.appendChild(contentSpan);

            document.getElementById("commentArea").appendChild(para);
        });

The controller to Add the Note:

public class NoteController : Controller
    {
        [HttpPost]
        public JsonResult Add(int…
0
This code in Java works perfectly:

    URL url = new URL(PREREQ_URL);
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("POST");
    con.setRequestProperty("Authorization", authorization);
    System.out.println(authorization);

    InputStream is = (InputStream) con.getInputStream();
    BufferedReader in
            = new BufferedReader(new InputStreamReader(is));

    String line;
    while ((line = in.readLine()) != null) {
        System.out.println(line);
    }
    in.close();

Open in new window


I am trying to convert it into C# and I am getting
System.Net.WebException: 'The underlying connection was closed: An unexpected error occurred on a send.'

This is what I have:

    Uri prereqUri = new Uri(PREREQ_URL);
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(prereqUri);
    //request.Headers["Authorization"] = authorization;
    request.Headers.Add("Authorization", authorization);
    //request.PreAuthenticate = true;
    request.Method = "POST";
    //var postData = "Authorization=" + authorization;
    //var data = Encoding.ASCII.GetBytes(postData);
    //request.ContentLength = data.Length;

    //using (var stream = request.GetRequestStream())
    //{
    //   stream.Write(data, 0, data.Length);
    //}

    var response = (HttpWebResponse)request.GetResponse();

Open in new window


I have also tried the commented out code with the same problem. Any ideas, please.
0
Hello,

I have always been a c#, .NET developer and our company is gradually transitioning to MVC and Angualr.  I am very new to MVC and Angular concepts, done a few courses about Angular and MVC on plural sight since last week and that is where I am at currently.

One the tasks I have on hand is to display a modal pop from from which needs to triggered to display from an MVC controller based on certain conditions and this modal pop up form which is a very basic form needs to be displayed using Angular.

This Modal pop up is as simple as it gets and will have a text box which needs to have an input of a 14 digit alpha numeric characters ( failure on providing it will show a validation error message on the modal pop up itself) a submit and a cancel button. On click of the submit button (after validation), the MVC controller needs to receive this value and continue its normal process.

Currently the MVC page where the modal pop up needs to be displayed has a few controls and a button. On click of this button the MVC controller calls the data access method and stores certain values in the DB. But if this 14 digit code is missing it currently throws an exception. Hence the need to for a modal popup for the user to enter the missing data.

I would very much appreciate if you can point me in the right direction by providing me some useful links or some code samples.

Thanks in advance AJ
0
Announcing the Winners!
LVL 13
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

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
dateshit.JPG

everything looks right why is it still throwing that stupid error, i hate strings and date they need to do something regarding this :(
0
I have an MVC 5 project where I have local processing RDLC reports using report viewer 14. For some reason I have a report that is called and after about 1 minute and 40 seconds and my site says that "No data was heard from..." in Chrome, and in IE it thinks there is a DNS problem after that 1 minute and 40 seconds. I have confirmed the SQL Query running in just a second. I am thinking that the biggest time factor is I am using a Matrix in my report.

I guess I would like to know how to extend my timeout. I have had other stored procedures that take a long time to run and I used the below reference and it fixed that. But I do not know how to fix this problem.

https://www.codeproject.com/Questions/238245/Dataset-xsd-Timeout-Problem
0
I need to build a aspx page that collects data.
On the page I have a dropdown for the number of people attending the event.
I want a dynamic  form that requests attendees information, but only for the number of attendees.
This has to live in the .net world
0
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);
xlWorkBook.Close();
xlApp.Quit();

Open in new window

0
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!

Dean
0

C#

94K

Solutions

25K

Contributors

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).