Skip to main content

Posts

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