Most voted ".net" questions
The Microsoft . NET is a set of libraries and functions that are part of the Basic Class Library (BCL), such as user interface functions, data access, connectivity, cryptography, web development, mathematical algorithms, and network communication.
Learn more…2,689 questions
Sort by count of
-
2
votes1
answer879
viewsHttpcontext.Current.Session is null in thread
Hi, I have a problem with my code. I’m doing a function that lasts about 3/4 hours long, and then I decided to do this function in a thread so that it doesn’t block the overall functioning of the…
-
2
votes2
answers2268
viewsWhat is the difference between Tolistasync() and Tolist()?
What difference between ToListAsync() and ToList()? As in the example below, what is the difference between one and the other? using Modelo.Classes.Contexto; using System.Data.Entity; using…
-
2
votes3
answers3159
viewsAdd SOAP Header to SOAP C#
I’m trying to add a header customized in one service SOAP using C#. I’ve searched everything and I can’t find a solution that works. I’m adding the service by Web References of C#. I’ve tried to do…
-
2
votes1
answer429
viewsHow do compiler recognize . as decimal separator?
I made a simple code in C# that receives a real number but only recognizes "," as a decimal separator. When I make you receive numbers that use "." as separator it ignores the point. For example, if…
-
2
votes2
answers814
viewsMonitoring internet connection at runtime
I’m using this method in C# to be able to identify whether or not the computer is connected to the internet private bool VerificarConexao() { if (NetworkInterface.GetIsNetworkAvailable()) { return…
-
2
votes1
answer114
viewsOrganizing forms inheritance - C#
I’m doing a program for selling products and I have a design problem. The differential of this program is that it can take on two different faces: one for the sale of chocolates and the other for…
-
2
votes1
answer48
viewsUniversal Apps 8.1 on Windows 10
Does Windows 10 have backward compatibility with Universal Apps from Windows 8.1? That is, applications written in for Windows 8.1 run on Windows 10?…
-
2
votes1
answer72
viewsReset a variable, or recreate it?
In terms of performance, what is more preferable? There are other differences between the two modes than performance? Reset a variable multiple times? Private Sub Metodo() Dim MeuTipo As Tipo For i…
-
2
votes1
answer230
viewsInaccessible logs error: Security
Good afternoon, I recently got the following error The source was not found, but some or all Event logs could not be searched. To create the source, you need permission to read all Event logs to…
-
2
votes1
answer54
viewsWhat are Staticresources and Dynamicresources in WPF?
When I use Resources in WPF, I can specify them as much as StaticResource, as DyanamicResource. However, most of the time only one works, and the other would initiate an exception. Starting from…
-
2
votes3
answers682
viewsHow to mount a lambda expression and pass it by parameter to a Generic function?
I need to pass two parameters to a generic function that returns database data and select only a few specific columns to display in one DataGridView. public List<TEntity>…
-
2
votes2
answers79
viewsColor Visualization and New Creation
I need to make use of the class Colors defined in namespace Windows.UI. There are many colors available and I need to find a way or place to see a preview of these colors, because only by name it is…
-
2
votes2
answers922
viewsRecover External IP without third party services
I have a WPF application. I need to know the external IP of the machine running this application. I found some tutorials that teach to do this through the method DownloadString() class WebClient…
-
2
votes1
answer426
viewsInstantiate class or use public methods?
When using a class method, there are two approaches: instantiating the class and using the method by the object, or making the method public static and call directly. Is there a problem using one or…
-
2
votes1
answer1215
viewsTransfer network files C#
I wonder if there is any way to transfer files on a local network without using the Socket Class in C#? and in terms of performance what is the fastest method of transferring files over a local…
-
2
votes1
answer154
viewsDatetimepicker with custom dates
I am developing a consultation marking system in Windows Forms and had the idea to include a DateTimePicker where only dates with available vacancies must be "clickable" by the user. There’s a way…
-
2
votes1
answer102
views -
2
votes1
answer4068
viewsHow to show error message?
I am developing a C# register in Visual Studio and created a method to include a new record in the database. The method is as follows:: public static bool Inserir(Usuario pUsuario) { try {…
-
2
votes1
answer198
viewsN for N Entity Framework
Dear, I am trying to carry out a relationship N to N in the Entity Framework for the tables described below. At the moment what is happening is a cyclical redundancy, where every time I open a…
-
2
votes1
answer105
viewsMonitor opening of Forms C#
I need to monitor the opening of Forms within a C#application. For example, every time you open a Form within the application, the application must execute a method or trigger an event with…
-
2
votes2
answers11603
viewsHow to break lines (console mode)?
How I break lines in C#, as if I put two commands Write the console will print them side by side, as I do to print on the bottom line. Ps: Code below var A1 = Console.ReadLine(); var A2 =…
-
2
votes1
answer192
viewsHow to add properties to WPF components?
I can use as an example the System.Windows.Controls.TextBox. How do I add more behaviors and properties to it? In a real context, I would like the component TextBox had a boolean property HasErrors,…
-
2
votes3
answers1098
viewsProblem with Padleft
I have a problem using the Padleft method. I need to put some zeros in front of a string, but I’m not getting it. For example: string value = "2001795"; string newValue = value.PadLeft(5, '0');…
-
2
votes2
answers306
viewsAny ASP.NET MVC solution for SQL injection?
I have in the application a code that validates the data entry, adjusting according to what is necessary, this would be considered a good or a bad option? public static string ValidaDados(string…
-
2
votes1
answer72
viewsRun fast things synchronously and time-consuming things asynchronously?
Usually, on . NET, I run things time-consuming asynchronously so as not to stop the thread visual. In a simple example, if I have a loading in the UI, should lengthy things be executed without…
-
2
votes2
answers113
viewsXML for Datatable
I’ve been searching on how to pass the data contained in an XML to a DataTable and found the following reply. Doubt: By doing so, the method theDataSet.ReadXml(theReader); is able to identify data…
-
2
votes2
answers547
viewsParse with quotation marks in the middle
I have in the database a column of the type varchar that takes a JSON. That column is the description of a company, but in 4 languages. The logic I have is the following: { "PT":"Descrição com…
-
2
votes1
answer237
viewsWhat is Guidattribute for and why?
I know the GUID is a 'unique' identifier, but I don’t see why your attribute application, as in the example below: [GuidAttribute("C281C7F1-4AA9-3517-961A-463CFED57E75")]…
-
2
votes2
answers66
viewsInclude all child objects (navigation properies) in the Entity search
I wonder if it is possible to search the object completely filled without calling the include specifying each child object (with their respective children) of my class. Currently, I’m doing so:…
-
2
votes1
answer23
viewsEntity Framework - Lazyload with null-enabled property
What happens to a search that uses the include of Entity Framework on a property that can be null. var ocorrencia = db.Ocorrencia .Include("Pessoa") .FirstOrDefault(c => c.id == 3); That object…
-
2
votes3
answers1401
viewsHow to access object created by another thread?
It is possible to access an object created by another thread?
-
2
votes1
answer51
viewsHow to obey the Open/Closed principle in this situation?
I have a situation where the solution that I have clearly identified violates the Open/Closed principle and I would like to find a better solution that does not violate that principle. Obviously my…
.net oop modeling software-architecture software-engineeringasked 7 years, 6 months ago SomeDeveloper 18,074 -
2
votes0
answers699
viewsX509 - Key set is not set
I use the class x509certificate of C# to read a certificate A3 for the signature of XML, occurs that it was necessary to renew the certificate and at first nothing changed, continued same type, but…
-
2
votes1
answer1676
viewsCannot Convert from 'string' to 'System.Iformatprovider'
Follow the code (works): var teste = 1; var teste1 = teste.ToString("000000"); Upshot: 000001 Follow another code (does not work): var teste = "1"; var teste1 = teste.ToString("000000"); Upshot:…
-
2
votes1
answer6800
viewsEntity Framework Connection String
I am creating a project using Entity Framework. My question would be, how can I create a connectionString (for SQL Server for example) and set in my Dbcontext where it will get from the Web.config…
-
2
votes1
answer185
viewsThe 'Connection' object can be discarded more than once in the method
Follows the code: public ActionResult Index(ViewModel model, string returnUrl) { string query = "UPDATE Table SET Status = 'C' WHERE Id = @Num"; using (SqlConnection connection = new…
-
2
votes0
answers521
viewsRESTFUL API - What it would be
What would be a RESTFUL API? What is different from a Web Service (which has Webmethods with CRUD operations for example)? Thank you
-
2
votes1
answer112
viewsCreation of anonymous objects vs "named (?)"
I have a class that loga some information in the database I am using it in the following way: new StudyLogRepository().Create(new StudyLog() { StudyId = Study.Id, CycleId = null, DateOccurrence =…
c# asp.net-mvc .net entity-framework pattern-designasked 7 years, 5 months ago Jhonatan Jorge de Lima 1,012 -
2
votes1
answer146
viewsGarbage Ollector is automatic?
I noticed that my application was deliberately consuming the memory even after the end of the processing, even finishing everything that was started so I called the GC.Collect(); and the memory was…
-
2
votes3
answers511
viewsWhat is the most recommended "Try" or "if"
{ public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { double SalarioBase = 0, Descontos = 0, Vantagens = 0; try { SalarioBase =…
-
2
votes1
answer53
viewsIn terms of performance, what is the best way to declare a variable that will be used in multiple Actions/Methods in a class?
Which mode is best performatically speaking? Which way you recommend and why? //Modo 1 MeuManager mm = new MeuManager(); JsonResponse MetodoDOIS(string urlImagem) { var abc = mm.Lista(); }…
-
2
votes1
answer119
viewsTimespan conversion
I am reading a file delimited by semicolon and one of the information that is the duration of the link is coming as "00:97:54". When trying to convert to Timespan, obviously gives error The Timespan…
-
2
votes1
answer698
viewsHow to get Tempdata value with List<Object>?
Follows code: List<object> list = new List<object> { "abc", // string 1, // int true // bool }; TempData["ID"] = list; The following code cannot get value: var data = TempData["ID"]; var…
-
2
votes1
answer706
viewsDoubt with @Style.Render
If I put in mine view Layout that line: @Styles.Render("~/Content/css") I’m stating that all the files .css in the briefcase Content will be rendered? I mean, I don’t need to put any .css explicitly…
-
2
votes1
answer116
viewsBuild error due to lack of constructor
I have the following classes: class Disciplina: public class Disciplina { public int Id { get; set; } public string Nome { get; set; } } interface IGenericaDAO: public interface…
-
2
votes1
answer183
viewsRun program in certain folder in IIS
I would like to know how to run an exe or jar program in a certain IIS folder, through the code c# . net core. It would have to be a synchronous call, that is when c# performs the call from the jar…
-
2
votes1
answer637
viewsCommunication with Siemens PLC
Soon I will be developing an interface with Siemens PLC, model ET-200A. This is a new subject for me and here I am with some doubts. Has anyone ever dealt with that kind of communication? The…
-
2
votes1
answer330
viewsOpen Asp.net project/solution that are coming from another machine
I have a project that was created on a machine and I have to give maintenance on it. I copied the project to my current machine and when I try to open Solution/project I get the following message…
-
2
votes2
answers689
viewsCall for generic methods in C#
I built a generic method that suits me well, but I’m having difficulty in calling this method. public List<T> CriaLista<T>(params T[] pars) { List<T> lista = new List<T>();…
-
2
votes1
answer734
viewsMVC - Creating a typed model as a generic list
I would like to create a typed model being a list of the type T. Utilizing: Razor from ASP.NET MVC 5 For example: My model in the cshtml will look like this: @model List<T> @foreach (var item…