Tuesday, February 8, 2022

Windows Service Error: The service did not respond to the start or control request in a timely fashion.

 Problem:

While deploying Windows Service built with .Net, you may have encountered this issue.

The service did not respond to the start or control request in a timely fashion.

Solution:

There is no description about the error appears anywhere, and you may have spent too much time in diagnosing this issue. Same happened to me, later I get it solved after searching a number of sites. Finally succeeded. So I decided to document the possible solutions:


1. DLLs Missing: 

Check if there is any dll file missing in the deployment. This is the most common mistake that the developers perform.

2. Service Logon Account: 

Check if the service running with Account has all the priviliges that are required to perform any operation. Open "View Local Services" then right click on your deployed service and take Properties. On "Log On" tab you will find the windows account which the service will be using to run. You can change the account credentials with privileged user to diagnose the problem.

3. Corrupt Installation or Corrupt files 

Files are corrupted required to run the service.

4. Network Related Issues:

There may be many other issues like Network configuration, Windows not updated,  required Version of .Net Framework is missing, Using Debug/Release build, Platform architecture mismatch, etc.


Hope you will get the solution from above solutions.

Happy Coding!

Saturday, December 19, 2020

How to Execute an Oracle stored procedure that returns LOB parameter using Entity Framework Core in .Net Core 3.1 with C#

Problem:

How to Execute an Oracle stored procedure that returns LOB parameter using Entity Framework Core in .Net Core with C#.

Solution:

Executing a simple stored procedure without LOB value is not a headache in Entity Framework, but if you try to execute a procedure that returns an LOB parameter, it may be a headache for you, because using any other method like FromSQLRaw, etc, procedure is executed but the Oracle connection closes before fetching LOB value. Here is the sample code to execute a stored procedure, lets say 'MY_PROC' that returns a CLOB parameter.


 private void ExecuteProcedure(IDbConnection dbConnection, Document d, DocumentDetail di, bool IsApproved, long? AgentKey, out string Status,out string Error)
        {
            try
            {

                Error = "";

                OracleParameter p1 = new OracleParameter("LOT_TYPE", OracleDbType.Varchar2, (d.Category == LotCategory.IMPORT) ? "BL" : "CRN", System.Data.ParameterDirection.Input );
                OracleParameter p2 = new OracleParameter("LOT_ID", OracleDbType.Varchar2, (d.Category == LotCategory.IMPORT) ? d.BLNo : d.CRNNo, System.Data.ParameterDirection.Input);
                OracleParameter p3 = new OracleParameter("ERRR", OracleDbType.Clob, System.Data.ParameterDirection.Output);
                OracleParameter p4 = new OracleParameter("STATUS", OracleDbType.Varchar2, System.Data.ParameterDirection.Output);
                OracleParameter p5 = new OracleParameter("DOC_ID", OracleDbType.Varchar2, di.BillingDocId,System.Data.ParameterDirection.Input);
                OracleParameter p6 = new OracleParameter("pIS_APPROVED", OracleDbType.Int16, (IsApproved)? 1:0, System.Data.ParameterDirection.Input);
                OracleParameter p7 = new OracleParameter("pVALIDITY", OracleDbType.Date, di.Validity, System.Data.ParameterDirection.Input);
                OracleParameter p8 = new OracleParameter("pAGENT_KEY", OracleDbType.Int64, AgentKey, System.Data.ParameterDirection.Input);
                OracleParameter p9 = new OracleParameter("pCREATOR", OracleDbType.Varchar2, HttpContext.ConnectedUser(), System.Data.ParameterDirection.Input);


                p3.Size = 5000;
                p4.Size = 50;

                

                var CON = _context.Database.GetDbConnection();
                {
                    con.Open();

                    var CMD = new OracleCommand();
                    CMD.Connection = (OracleConnection)CON;

                    CMD.CommandText = "MY_PROC";
                    CMD.CommandType = CommandType.StoredProcedure;
                    CMD.Parameters.Add(p1);
                    CMD.Parameters.Add(p2);
                    CMD.Parameters.Add(p3);
                    CMD.Parameters.Add(p4);
                    CMD.Parameters.Add(p5);
                    CMD.Parameters.Add(p6);
                    CMD.Parameters.Add(p7);
                    CMD.Parameters.Add(p8);
                    CMD.Parameters.Add(p9);
                    

                    CMD.ExecuteNonQuery();

                    Status = ((Oracle.ManagedDataAccess.Types.OracleString)p4.Value).Value;

                    if (!((Oracle.ManagedDataAccess.Types.OracleClob)p3.Value).IsNull)
                    {
                        Error = ((Oracle.ManagedDataAccess.Types.OracleClob)p3.Value).Value;
                    }

                     con.Close();
                };


            

               
                                
            }
            catch (Exception x)
            {
                log.Error("Exception : " + x);
                Status = "Error";
                Error = x.Message;
            }
        }

Sunday, August 2, 2020

Problem

Image not saving / updating / uploading properly in Oracle Database using Entity Framework / EF Core in BLOB / CLOB field using Oracle.EntityFrameworkCore provider.


Solution

Oracle BLOB / CLOB has by-default restriction of 2000 bytes in Oracle.EntitiyFrameworkCore provider. Due to this reason it trims the larger image bytes array to 2000 bytes and store in database without giving any error. As a result image not appear properly when retrieved.

To overcome this issue, an attribute is provided by Entity Framework which increases its capability of accepting large sized images. MaxSize attribute is available in Data Annotations assembly which helps to solve this problem.

Hope your problem is solved. Happy Coding!!!

Tuesday, July 7, 2020

Crystal Reports for VS 2010 and .Net 4 framework : "Load Report Failed" error

Problem:
If you have recently upgraded your project and started using Crystal Reports for VS 2010 and .Net 4 framework in your project, you might seen this error randomly or continuously after generating some reports. 

Cause:
Unlike previous versions of Crystal Reports, Crystal Report Engine is not releasing memory after closing reports. 

Solution:
After getting tired of this error, I started diagnosing this issue. I monitored the memory usage and found that memory usage is getting increased even after closing down the reports. So I added some code to restore memory after closing. Here is the addition to my code that solved my problem:


            rpt.Close()
            rpt.Dispose()
            rpt = Nothing
            GC.Collect()


Hope it will solve your problem. Enjoy Coding!

Friday, March 6, 2020

The DataColumnMapping.SourceColumn is required to be unique. 'ColumnName' already exists in the collection.

Problem:

While configuring Table Adapter query in ADO.Net Dataset, you may have received this error:

 The DataColumnMapping.SourceColumn is required to be unique. 'Column' already exists in the collection


Solution:

Open the Dataset's xsd file with XML text editor. Search for the column name showing in the error. Manually remove the mapping column and then save the xml file.

Hopefully you will have no error from now on.

Friday, March 22, 2019

Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet...

Problem


Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Solution



  1. Open Menu Nuget Package Manager > Manage Nuget Packages for Solution
  2. If you are using EFCore then, Browse Package Microsoft.EntityFrameworkCore.Tools
  3. If you are using EntityFramework then, Browse Package Microsoft.EntityFramework.Tools
  4. Instal the Package
  5. Run the command again : add-migration initial
Hope your problem will be solved.



Tuesday, September 4, 2018

VirtualBox Error during Installation: Failed to retreive the preconfiguration file.

Problem:

While Installing Raspberry Pi over VirtualBox, you may encounter the following error:
Load debconf preconfiguration file.
The file needed for preconfiguration could not be retreived from....blah, blah, blah... The installation will proceed in non-automated mode.




Solution:

The installation file (Disk image) might be corrupt. Re-download the image from the official site, hopefully your problem will be resolved.

I would love to hear from you. Happy coding!

Popular Posts