Skip to main content

Posts

 Problem : I was writing API in .NET Core 3.1. The API's exported list of custom classes for [httpget] methods from controller. I used Postman for testing the API's. And observed that from code the list of  classes were returned correctly but it were always coming as empty entries in Post man result window. Solution : The class was returning list as Action result. The  native data types like int or string lists were working fine. On further debugging I noticed that the class members were declared public. The get and set modifiers were missing from the class. After adding the get and set methods to the data members of the class. For example: The following code was not working // GET: api/<Controller>         [HttpGet("Sample/Run")]         public async Task<ActionResult> Sampletest()         {             var result = await _datafromDB.GetDaataFromDB();     ...

Online Exam App with .NET Core Web API and Blazor Client

 We will develop an app that can host online exam. It will have the feature to register user, allow the user to log in. Dashboard for creating sample tests.  The code is shared in GIT hub repository https://github.com/ SwagatikaGoswami/ OnlineExamApp.git The database is MySQL database. The server is a WEB API .NET Core service that uses entity framework for DB operations. The client is a web assembly blazor application. The password stored in the database is encrypted. Register window is as follows. It checks for the mandatory fields. The log in page is as follows: The admin dashboard after logging in  The admin dashboard when new test button is clicked. It uses a Blazor component for adding new test samples.

CRUD operation with WCF service and WPF client

 The database restored on local server WCF Service is talking to the database. Used Visual Studio 2019, entity framework 6 for data base operations from the service. The service exposes the following API’s.  The WCF contracts has both synchronous and asynchronous API's The client is in WPF. It has three windows, main window, customer window and order window as follows. The client uses the WCF service for database operations. When customer button is clicked, the customer window is displayed as below. We can perform CRUD operation from it. The customer can be searched based on ID. New customer window The order button launched order window. It has combo box to choose the customer ID. On selecting the ID, the order details are displayed in the data grid as follows. The source code is available in the GIT hub, URL below: https://github.com/SwagatikaGoswami/WPF_WCF_CRUD.git

Default .NET Core Web API stops working on name change

Problem : I create a .Net core web API application using Visual Studio template as follows. I renamed the default controller class “ WeatherForecastController ” to some thing else. My project stopped working. Solution : The solution is to change the at the following places: IN launchSettings And in the controller file, WeatherForecastController.cs  

Web App issue in migrating to Docker Image

Problem: A web service application works fine in IIS Server but does not work if hosted in a docker image in Docker desktop. Analysis: The web service application was using an external software. The dependent software files were not getting copied to the docker image. Hence the web application was failing to do the operation. Solution: The solution was to update the docker file that was generated by Visual Studio while docker support is added. The following changes were made to the docker file to copy the dependent software to the docker image. The files to be copied from the host system also has to be present relative to the docker file. In this case the Model folder is at the same level of the docker file.   FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-nanoserver-1809 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809 AS build WORKDIR /src COPY ["YourProject.csproj", ""] RUN dotnet restore "./YourProject.c...

Events in .NET

Events A class defines an event member to notify other objects For example, when a Button object is clicked, a Form object receives a notification and performs some action. The CLR’s event model is based on delegates Event member An event member declaration provides the class with three capabilities Objects can register for the event Objects can unregister the event The type that defines the event maintain the set of registered objects and notifies these objects when the event is raised. public event AlarmMessageEventhandler AlarmMessage when viewed in ILDASM, notice that compiler translates the above line to following three constructs private AlarmMessageEventhandler, add_AlarmMessage, remove_AlarmMessage. BurglarSystemManager.cs namespace Event_Demo {     /// <summary>     /// I have declared a class named BurglarSystemManager     /// </summary>     class BurglarSystemManager     {     ...

Real time data to web application using Microsoft Signal R and Razor Pages

Today we are going to learn how to create razor pages and how to send run time value to the razor page using Signal R Create a new .NET core web application Add Signal R library by,  Add Client-Side Library dialog in the project, for Provider select "unpkg" and select the latest version from the drop down For Library, enter @aspnet/signalr@1, Add a new folder to the project named as Hubs The chat hub class inherits from HUb class that manages connections and messaging The send message is called to send the message to all the clients. MyHub.cs file contains the following code using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; //using System.Threading.Tasks; namespace SignalRSample.Hubs {     public class MyHub : Hub     {         public async Task SendMessage(string user, string message)         {       ...

Delegates in .NET

What is a delegate? Microsoft framework exposes callback functionality via delegates. Call back functions are used in various application like Microsoft Windows software, OPC subscriptions in Industrial Automation software's, for providing real time data for web applications, menus, file system changes, exception handling etc.  Delegates can call multiple methods in order wise.  A delegate object is a wrapper around a method and an object to operate on. All Delegates types are derived from System.Multicastdelegate. Delegate supports the calling of both static and instance methods and callback method is type safe. How to use it? class TempretureSensor {         // Subscribers to the tempreture sensor instance         public List<int> subscribers = new List<int>();         //Define a sensor data type         public delegate void TemperatureFeedback(int unitId, double value, stri...

SQL Lite CRUD operation using Visual Studio Web Application

Problem: How do I perform CRUD operation in web? Solution: I will explain in detail steps how to write a simple web application that is capable of crud operation in SQL server.  From Visual Studio create a MVC web application. I used Visual Studio 2017. Add entity framework core, sql server compact packages from NuGet browser if you want Get a SQL lite database (mdf file) and add an employee table with columns, Id (int), name, address and phone number as varchar. Copy it to the data folder in the application folder Add a class named employee to the modal class with properties same as the column names in the employee table Add a controller class named employees Go to the appsettings.json file,  rename your copied database file to the same name as the database name in the connection string Go to the layout page and add the newly created employees CRUD operation index page to the web layout Build the project  Launch the website by pressing F5 Check if you a...

Hang due to modal overlap window

Problem: The problem was that the application would hang for one of the use cases that the customer was not sure of. Analysis:   The dump files of the hang pointed to the fact that the application hung while trying to close a window that is blocked by a modal dialog. On further analysis we could dig that, the application was hung while closing all the child windows from a menu option.The thread or the window that was blocked by the modal dialog was due to an exception message dialog. Solution: The solution was to not close a window that is blocked due to some reason. Hence the method that closed all the overlap was modified to check if the window is blocked from its window handle. All the blocked windows are left and other modeless windows are closed in that case.

Dual Signing or SHA 256

Problem: Application signed with SHA 256 is not opening in Windows 2008 R2 nodes. Earlier the application was signed with SHA 128. Analysis: SHA 128 is going to be depreciated soon. Therefore applications signing needs to be moved to SHA 256. But the problem is for classic applications that still supports Windows 2007 and 2008 operating systems. The application might not work on these nodes. On debugging it was found that SHA 256 requires .NET 4.5 and above. SHA 128 signing required .NET 3.5 framework which came by default in Windows 2008 R2 operating system. Solution:  a) Dual signing of the application modules.We tried Microsoft patches for supporting dual signing without installing .NET 4.5 framework.  c) Or else, install 4.6 or above .NET framework on the nodes for supporting SHA 256. Net framework 4.5 will no longer be supported by Microsoft.

Windows software licensing user interface tool

Problem: I was not able to activate Windows 2016 server standard using product key from settings --> Activate Windows now option. Every time I launch the window for providing the correct key, it will try to activate the windows and change product key would grey out. Solution: The easiest way to provide the key for activating windows is to use the software licensing user interface tool. It is a command line utility tool that can be launched from run command. Type slui.exe in the run command and provide the correct key in the text box available from the user interface of the tool.

Why application fails to start at startup?

Problem: In some customer node the application does not start after installation. It crashes at the startup. What are the possible common reasons to investigate in such cases? Analysis: As per my experience, most probable causes are as follows: Pre-requisites software of the application are missing.- It is not always possible to package all the pre-requisites of an application in installation package. Hence it is documented in the installation and configuration manual.Check in the add and remove programs if all the software are installed. One of the pre-requisite software may be missing on the node. Use the dependency viewer or dependency tool to find the missing dependent binaries on the node. Or use Windbg tool and start the application, it may give some idea on the pre-requisite software. Compare the loaded binaries of the application process with the list that it is supposed to load. For example, compare it with the list of binaries loaded by the application on a working no...

Application window missing from my computer screen

Problem:  Sometimes the application window opens outside the screen of the computer in Windows Operating System. What is the easiest way to view the hidden window on the screen? Solution:  It is very irritating if the window of the application is not visible on the screen. The easiest way of making the window visible is to to press <SHIFT> key followed by context menu on the application icon in the task bar. From the context menu select the "Maximize" option.

How to know if a process window is live or hung?

Problem: In real time systems, normally application will be running for all the time, 365 days and 24/7. Some dashboards will be displaying the mission critical parameters like trends, alarms events etc. How do we make sure that the dashboard windows of the application are showing correct real time data and it is not hung? Analysis: The application or the window may hang due to various reasons like OS going to hibernate mode or due to some exception the window thread may not be showing the live real time data. To make sure that the windows are not freeze, we need some mechanism for alerting the user in such cases. Solution: The solution is to have a watchdog process, that keeps on monitoring all the threads of the running application. A mechanism to send alive time out message and receive the acknowledgement from the threads of the main application. In case the application hangs there should be a way to let the user know that the main application has hang and needs to be restar...

Association vs Aggregation vs Composition

Association vs Aggregation vs Composition   Association  Defines relation between two objects All entities are different from each other For example, if Ram is friend of Shayam, Shayam is friend of Hari. All three are different individuals.  Aggregation Aggregation is subset of association, where the relation between the objects is more compared to association. Ripened fruits and seeds, fruit use seed for next generation It can be thought as one entity using the other  Composition Composition is also subset of association where bonding or relation is maximum One entity cannot exist if the host is not available For example, one room cannot become part of another house, room doesn’t exist if the house is demolished. It’s also called death relationship. Another metaphor can be, child in mother’s womb is composition, dependent child or infant is aggregation, adult child and mother is association. The dependency of the c...

COM threading issue with overlap windows

Problem :   The application sometimes hangs during normal operation. The hang is more prominent in case of more overlap window usage. . Analysis : The problem occurred rarely and in some operating systems. There were no clear steps on how and why the hang happens. On debugging the hang dumps from customers site, it pointed to fact that the hang happens while releasing a com object of the process. The application used smart class auto pointers like CComPtr and CComQIPtr for creating and deleting the com objects. On more digging the dump files we could notice that the com object thread where it was created is not available in the dump files. Com objects are created on the thread where we call co-create instance. In case of overlaps opened from the application, each overlap is a different thread. And it is possible to open another overlap from the already opened overlap via context menu. Hence the parent of the new overlap is the first overlap that was opened from the main thre...

A feature of a product was working in one of the previous releases, but it is not working now.

Problem: A feature of a product was working in one of the previous releases, but it is not working now. We might have come across this problem statement many times in software development. Due to some correction of issue or enhancement of the product might lead to this kind of issue. And sometimes this broken functionality issue gets missed from the organization and it comes back as a customer reported issue. Analysis: This kind of issue is not uncommon. Some products have a life cycle of more than 10 years like Windows. In such cases, the code would have been written long back by some developer and fix would be done by some one else. So the impact of changes on the existing functionality may not be fully known by the new developer who is working on that code. With busy schedule and manual testing, even the testers some time miss to test all the scenarios or features of the product. Solution: Impact analysis of both major and minor changes should be conducted thoroughly. Code...

Add in process takes a long time to load in the host process

Problem:  Add in process takes a long time to load in the host process. Hence the host process seems to be hung till the add in process is completely loaded. This issue becomes more prominent if the add in process is responsible for displaying graphics in the host process. Analysis:  On analysis we found that the add in process was taking a lot of time to load during initializing itself. The add in process was loading both managed and un-managed code. We tried to make the loading of the process faster by using dependency injections and late binding mechanism. This improved the loading time significantly but still it was not enough. Solution:  Then we came up with the peer process idea. That is by default one add in process will always be available as standby for the host process to load. Host process would fork another add in process and use the current running add-in process for its usage. If the add-in process crashes due to some reason, another process would b...

Learn Kannada numbers from Odia

Odia     Numbers Kannada     Numbers Words in Kannada   Kannada Pronunciation 0 0 ಸೊನ್ನೆ ଶୂନ୍ୟ   ୧ ೧ ಒಂದು ଊନ୍ଦୁ  ୨ ೨ ಎರಡು ଏରଡ଼ୁ ୩ ೩ ಮೂರು ମୁରୁ ୪ ೪ ನಾಲ್ಕು ନାଲକୁ ୫ ೫ ಐದು ଆଇଦୁ ୬ ೬ ಆರು ଆରୁ ୭ ೭ ಏಳು ଏଲୁ ୮ ೮ ಎಂಟು ଏଣ୍ଟୁ ୯ ೯ ಒಂಬತ್ತು ଊଂବତୁ ୧୦ ೧೦ ಹತ್ತು ହତୁ ୧୧ ೧೧ ಹನ್ನೊಂದು ହନୋଊନ୍ଦୁ  ୧୨ ೧೨ ಹನ್ನೆರಡು ହନଏରଡ଼ୁ ୧୩ ೧೩ ಹದಿಮೂರು ହାଦିମୂରୁ   ୧୪ ೧೪ ಹದಿನಾಲ್ಕು ହାଦିନାଲକୁ  ୧୫ ೧೫ ಹದಿನೈದು ହାଡ଼ିଆଇଦୁ ୧୬ ೧೬ ಹದಿನಾರು ହାଦିଆରୁ ୧୭ ೧೭ ಹದಿನೇಳು ହାଦିଏଲୁ ୧୮ ೧೮ ಹದಿನೆಂಟು  ହାଦିନେଣ୍ଟୁ  ୧୯ ೧೯ ಹತ್ತೊಂಬತ್ತು ହାତଊଂବତୁ ୨୦ ೨೦ ಇಪ್ಪತ್ತು ଈପତୁ  ୨୧ ೨೧ ಇಪ್ಪತ್ತ್’ಒಂದು ଇପତଊନ୍ଦୁ ୨୨ ೨೨ ಇಪ್ಪತ್ತ್’...