Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

.NET Programming

132K

Solutions

38K

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

Hi Experts,

How do I get the current Windows Region Format, e.g "French (France)" ?

Regards,
Leigh
0
What is SQL Server and how does it work?
LVL 1
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Hi

I want to set Target Framework as .NET Standard 2.0 for my new .NET project. Where can I find the download so that I an install n my machine and use for new projects with .NET standard 2.0 as target .

Please se the attached,

Thanks
0
Troubleshooting a piece of code.
            Dim web As Net.WebClient = New Net.WebClient()
            Dim html As String = web.DownloadString("https://www.google.com/finance/converter?a=1&from=EUR&to=USD")
            Dim m1 As Match = Regex.Match(html, "<span class=bld>\s*(.+?)\s*</span>", RegexOptions.Singleline)
            Dim currency As String = m1.Groups(1).Value.Replace("USD", "")

            user.setEuro(Convert.ToDouble(currency))

Open in new window

currency is blank.  

My question is what does "<span class=bld>\s*(.+?)\s*</span>", RegexOptions.Singleline" do?
0
Hi,

How do I prevent users from resizing a Form by dragging its border using VB.NET?

Kind regards,

Victor
0
Hello Experts,
I am working on a Windows Service application in C#.  It is working fine in local machine.  I am getting the following error message when try to install in Production box.  I have set the Platform Target to Any CPU and Target Framework to .NET Framework 4.5. .  Also I tested it by changing the Platform Target to x86  and to x64.  But still getting the same error.  Please let me know how to fix it.  Thank you in advance.

Error Message
----------------------------
Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///D:\Domains\XxxService\XxxPmtService.exe'
or one of its dependencies. An attempt was made to load a program with an incorrect format..

Installation
------------------
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>installutil -i D:\Domains\XxxService\XxxPmtService.exe
0
Hello,
How can I Draw line from datagridview1 cell to another datagridview2 cell.
Just want to show a connection.
I am using vb.net desktop.

Thanks
0
I am writing a C# console application using VS2015 and .NetFramework 4.5.

My application reads in, for example, a filename of "JOB_MOR_251540_0.xml" and "JOB_MOR_251540_0.img"
                   
When I use the following code and read filename "JOB_MOR_251540_0.xml", statement A is reached:

        foreach (FileInfo file in parentDirectory.GetFiles())
            {
                StreamWriter sw = null;
                try
                {

                     if (file != null && XmlFile(file.FullName))
                     {
                             statement A;
                     }  

I have modified my code as follows to make sure only filenames that begin with "JOB_MOR_" are processed.
When I use the following code and read filename "JOB_MOR_251540_0.xml", statement A is bypassed:
Do you know how I can modify the following IF statement to read in ONLY file names that begin with "JOB_MOR_"
and if it ends with *.xml it will process statement A?

                    if (file != null && 
                    ((file.Name.StartsWith("JOB_MOR_"))                          
                    && XmlFile(file.FullName)))                    
                    (
                            statement A;
                    }
0
Hi

I have a simple document library and i want to loop threw all my documents and get a specific value from custom field/column i created in my library.

Here is my code:
List docList = context.Web.Lists.GetByTitle("IKSRevisjon");
                    context.Load(docList);

                    CamlQuery camlQuery = new CamlQuery();
                    //camlQuery.ViewXml = "<View Scope='RecursiveAll '></View>";
                    camlQuery.ViewXml = @"<View Scope='RecursiveAll '>
                                    <Query>
                                    </Query>
                                </View>";

                    ListItemCollection listItems = docList.GetItems(camlQuery);
                    context.Load(listItems);
                    context.ExecuteQuery();

                    foreach (ListItem listItem in listItems)
                    {
                        Console.WriteLine("Id: {0} ", listItem.Id);
                        string title = listItem.FieldValues["Created_x0020_By"].ToString();
                        var avd = listItem.FieldValues["Avdeling"].ToString();
                        Console.WriteLine("Title", title);
                        Console.WriteLine("Avdeling", avd);
                    }

Open in new window

i get the value of "Created By":
string title = listItem.FieldValues["Created_x0020_By"].ToString();

Open in new window


but why cant i get value from other fields...?
0
I inherited a WPF project in C# with an IDisposable class which keeps a static list of all instances of itself. It looks something like this:

using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Xyzzy : IDisposable
    {
        private static readonly HashSet<Xyzzy> MyList = new HashSet<Xyzzy>();

        public void AddXyzzy()
        {
            Xyzzy xyzzy = new Xyzzy();
            MyList.Add(xyzzy);
        }

        public void AddXyzzy(Xyzzy xyzzy)
        {
            MyList.Add(xyzzy);
        }

        public void Dispose()
        {
            this.Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                //... doesn't do anything with MyList.
            }
        }
    }
}

Open in new window


My problem is I can not dispose of this class from the main program when the main program exits.

The program seems to hang on exit because these resources are not freed yet.

  • I can't call Dispose() because I don't have an instance of the class.
  • I can't access the private list "MyList" of all instances because it's private.

I'm not allowed to add a static public method DisposeAll() that will go through the internal list and call Dispose() on all the instances.

Q1. I'm wondering what's wrong with this overall design? Is there any official looking documentation saying how disposable objects ought to be handled? Who's responsibility is it to properly dispose of objects that are IDisposable?

Q2. What's the purpose of using private static readonly when declaring MyList? The list gets added to anyway, so I'm not sure how that makes it 'readonly'.

Q3. I've seen code such as:
var myThing = new myThing();
MyThingList.Add(myThing);

Open in new window

Later the Visual Studio Code Analyzer warns that myThing should be disposed of before it goes out of scope; however, if I did that then wouldn't MyThingList contain a bunch of already disposed of objects?

Q4.
0
Hello Experts,
I have a Windows Service program in C#, 1. which is attaching a xxx.txt file in an email attachment, and 2. should delete it after that.  Only the first part of the program is working.  At 2nd part, I am getting the exception "The process cannot access the file XXX because it is being used by another process".  At this point the file has been locked #1.  Any idea how to fix it?  Thank you very much in advance.

This is how I am trying to delete the file.  At this point if I change the folder name and try to delete the file it works fine.

Array.ForEach(Directory.GetFiles(filePath), File.Delete);

Thank you !
0
[eBook] Windows Nano Server
LVL 1
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Dear,
I want to have bigger height to overall div below. What to adjust?
            <li>
                <div class="imagesList-item-frame shadow"/>
                    <img src=<%=lb_pict5.Text %> onclick="pict_click5();" />
                    <div class="legend">
                        <input type="textbox" id="tb_p5_desc" style="height:20px; width:116px; border:inherit; background-color:#C5C4CC;" runat="server" /><label id="show5"></label>
                        <input type="text" id="tb_p5_desc2" style="height:20px; width:118px; border:inherit; background-color:#C5C4CC; display: none" value="TEST:" runat="server" />
                        <!---span>Some descriptions here</span><br /--->
                        <input type="button" id="butt_p5" onclick="openPopup5();" style="height:26px; width:97px" value="删除照片" runat="server" />
                    </div>
            </li>

Open in new window

0
I'm used to being able to use session variables or (in an older application) the authentication provided by ASP .NET to control security/access within my web app. Now, for a couple of reasons, I need to POST and GET data between pages but I'm struggling with how this is done. I need a simple way,using C#, to POST some data from one page and then GET (process/retrieve) it on another page. Can someone provide me with simple clear examples or code for how this is done? I'm using VS 2012 and 2015.
0
Hi I have used telerik to convert code but getting error, please help

this is the c# version:
System.Xml.XmlElement[] headers = doc.DocumentElement.ChildNodes.Cast<XmlElement>().ToArray<XmlElement>();

Open in new window

       
this is the vb converted version:
Dim headers As System.Xml.XmlElement() = doc.DocumentElement.ChildNodes.Cast(Of XmlElement)().ToArray(Of XmlElement)()

Open in new window


the error message is

Error      109      Extension method 'Public Function ToArray() As TSource()' defined in 'System.Linq.Enumerable' is not generic (or has no free type parameters) and so cannot have type arguments.

I have the: Imports System.Linq
0
Items:

Two Computer with each program with textbox

PC1:
I have project with Textbox and Button

PC2:
Also have project with textbox only

Problem:
How can I send the text in the textbox from PC1 to PC2?

Any help please, Thanks
0
Say, I have an XML with Namespace (example contrived for the purpose of the question).
To read the XML below, I can add a namespace manager and read the element. but if i wanted to modify, write a new element to such
XML, how do i do it?

say i want to append, <xyz:status/> element, in the following XML and save it.

string resultStr=@"<xyz:Message xmlns:xyz="http://xyz.com"><xyz:result>...</xyz:result></xyz:Message>";

XmlDocument doc = new XmlDocument();
xDoc.LoadXml( resultStr);

XmlNamespaceManager mng = new XmlNamespaceManager( doc.NameTable );
mng.AddNamespace( "xyz", "http://xyz.com" );

string result = xDoc.SelectSingleNode( "xyz:Message /xyz:result", mng).InnerText;
0
Hello Experts,

I'm totally new to programming using MVC in .net 4.5 and using (DB first) approach beside scaffolding way to create controllers and views from existing models.

When I rum my application I got those 2 errrors:

1- Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>' to 'System.Collections.Generic.IEnumerable<WebApplication2.Models.tb_List_AgencyCategory>'. An explicit conversion exists (are you missing a cast?)

2-'IEnumerable<tb_List_AgencyCategory>' does not contain a definition for 'Concat' and the best extension method overload 'Queryable.Concat<SelectListItem>(IQueryable<SelectListItem>, IEnumerable<SelectListItem>)' requires a receiver of type 'IQueryable<SelectListItem>'


Here is my Model Code:

namespace WebApplication2.Models
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Web.Mvc;
    using System.Collections;
    
    
    public partial class tb_Current_Agency
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public tb_Current_Agency()
        {
            this.tb_Current_Activation = new HashSet<tb_Current_Activation>();
            this.tb_Current_Activation1 = new HashSet<tb_Current_Activation>();
            this.tb_Current_GSBService = new HashSet<tb_Current_GSBService>();
           

Open in new window

0
Can you please tell me where the error is?


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace Scaffld.Models
{
    [MetadataType(typeof(EmployeeMetaData))]
    [DisplayColumn("FullName")]
    public partial class Employee
    {
    }

    public class EmployeeMetaData
    {
        // Id property is hidden and cannot be changed
        [HiddenInput(DisplayValue = false)]
        public int Id { get; set; }

        // EmailAddress is read only
        [ReadOnly(true)]
        [DataType(DataType.EmailAddress)]
        public string EmailAddress { get; set; }

        [ScaffoldColumn(true)]
        [DataType(DataType.Currency)]
        public int? Salary { get; set; }

        [DataType(DataType.Url)]
        [UIHint("OpenInNewWindow")]
        public string PersonalWebSite { get; set; }

        [DisplayAttribute(Name = "Full Name")]
        public string FullName { get; set; }

        [DisplayFormat(DataFormatString = "{0:d}")]
        public DateTime? HireDate { get; set; }

        [DisplayFormat(NullDisplayText = "Gender not specified")]
        public string Gender { get; set; }
    }
}

Open in new window


Server Error in '/Scaffld' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific 

Open in new window

0
In a simple ASP.NET Core 2 Application in which I am using CodeFirst, I am trying to run Update-Database command in PackageManger Console Window (an InitialMigratio has already been created successfully). However I get the followin error.
Keyword not supported: 'mulitpleactiveresultsets'.
I suspect there is probably some erroy in my Connection String in my appsettings.json file.
The ConnectionString I have in appsettings.json file currently looks like this.

 "ConnectionStrings": {
    "Default": "Server=(localdb)\\mssqllocaldb;Database=Webroute;Trusted_Connection=True;MulitpleActiveResultSets=true"
  },

I would appreciate if could let me know if there is any error in the way I have defined the connection string and if the ConnectionString is correct what could the cause of the error message (Keyword not supported: 'mulitpleactiveresultsets'.) I am getting and how could I fix this.
Thank you for your help.

The complet appsettings.json file in my project looks like this:
{

 "ConnectionStrings": {
    "Default": "Server=(localdb)\\mssqllocaldb;Database=Webroute;Trusted_Connection=True;MulitpleActiveResultSets=true"
  },
  
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  }
}

Open in new window

0
Hello,

I'm trying to change multiple  panel back color depends on data from database,
the data comes from list called mylist  it have a strings with true and false,
so i need to change the back color of panels depends on that data , so if mylist(1) = true i want the back color is green:
this is what i tried  :

Dim p As List(Of Panel) = Me.Controls.OfType(Of Panel).ToList
        For i As Integer = 1 To duration
            If myList(i) = True Then
                p(i).BackColor = Color.SpringGreen
            End If
        Next

Open in new window


but its not working.
0
Free Tool: SSL Checker
LVL 10
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

So I've had a couple issues with Adobe,

Firstly I've had a popup error message from Windows when launching Adobe that says "Windows - Application Error  The application was unable to start correctly (0xc0000022). Click OK to close the application."  I can only select OK on the dialog box, and when I do it closes and opens again a couple of times, and then finally closes.  This happened initially without any perceptible effect on the program or loss of functionality.

Secondly, when going to print documents the printer Properties box doesn't open at all, and the Page Setup doesn't open either.  This happened just yesterday, and is the core functionality that needs to be restored.  

Adobe Reader has been fully uninstalled and reinstalled without change, including uninstalling and reinstalling the 2.5 and 3.5 .NET framework as well.  Additionally I've downloaded the latest printer drivers for the printer I'm attempting to print to, though I have the same issues when attempting to print to any printer.  Additionally the Windows error logs don't include anymore information than the popup window.
0
Hello,
I have code  which replaces the merge field.I need to replace with backspace.How can i achieve this .
Any suggestions are appreciated.
 oDoc.Content.Find.Execute(FindText:="«Date4»",
                       ReplaceWith:=Str_Date, Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll, MatchCase:=True)

Open in new window


Cheers
0
Hello Experts,

I'm totally new to programming using MVC in .net 4.5 and using (DB first) approach.
When I tried to edit any record by clicking edit hyperlink I got this error:

HTTP Error 400.0 - Bad Request



1- My model has composite key: (ServiceID nvarchar(50) ,DatasetID int)

2-Controller Code:
 public ActionResult Edit(string ServiceID, int DatasetID)
        {
             if (ServiceID == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            tb_Current_Intersection_Service_Dataset tb_Current_Intersection_Service_Dataset = db.tb_Current_Intersection_Service_Dataset.Find(ServiceID,DatasetID);
            if (tb_Current_Intersection_Service_Dataset == null)
            {
                return HttpNotFound();
            }
            ViewBag.DatasetID = new SelectList(db.tb_Current_MarsadDataset, "DatasetID", "DatasetFullName", tb_Current_Intersection_Service_Dataset.DatasetID);
            ViewBag.ServiceID = new SelectList(db.tb_Current_Service, "ServiceID", "ConsumerID", tb_Current_Intersection_Service_Dataset.ServiceID);
            return View(tb_Current_Intersection_Service_Dataset);
        }

Open in new window


3- Index.Chtml Code:
  @Html.ActionLink("Edit", "Edit", "tb_Current_Intersection_Service_Dataset", new { id = item.ServiceID, DatasetID = item.DatasetID }, null) |

Open in new window


Thanks a lot in advance.
Harreni
0
Can you please tell me why its not showing the database?
screenshot.pngscreenshot2.pngscreenshot3.png
0
Dear,
How to identify reason of StackTrace got below?
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteScalar()
   at RegRec2._Default.remove_rec(Int32 rec_id)

Open in new window

0
Can you please tell me where the error is?
screenshot.pngscreenshot2.pngscreenshot3.png
System.Data.SqlClient.SqlException was unhandled by user code
  Message=A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
  Source=.Net SqlClient Data Provider
  ErrorCode=-2146232060
  Class=20
  LineNumber=0
  Number=2
  Server=""
  State=0
  StackTrace:
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
       at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer

Open in new window

0

.NET Programming

132K

Solutions

38K

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.