Thursday, 12 July 2018

ERR_CONNECTION_RESET - when you run application from visual studio over https

This site can’t be reached

The connection was reset.

ERR_CONNECTION_RESET



This error normally comes when local iis express certificate has corrupt. So please repair the IIS it will solve your Problem.

Tuesday, 21 November 2017

A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance

Ok, this exception "A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance" can happen with NHibernate if you have an entity with a list of other entities with the .Cascade.AllDeleteOrphan() mapping.

If you clear the list by assigning it a new List<entity>(), this exception will appear.

Instead clear the list by using the .Clear() method.




Error Code

using( var session = _sessionManager.GetSession())
        using (var transaction = session.BeginTransaction())
        {

            var order = _repository.GetOrderEagerlyByOrderId(session, fromDb.Id);
            var now = DateTime.Now;
            const string user = "GNB\\Username";
            var future = now.AddYears(1);
            var taxType = new TaxType(0, "Code", "AlternateNameE", "AlternateNameF", "NameE", "NameF", "DescriptionE", "DescriptionF", 13, now, future, user, now, user, now);
            var _serviceCatRep = new ServiceCatalogueRepository();

            var serviceCatalogueItem = _serviceCatRep.GetServiceCatalogueItemByCode(session, "VR-PASS");
            var orderLineItem1 = new OrderLineItem(0, null, "DescriptionE", "DescriptionF", 1, 10, null, null, 5, false, serviceCatalogueItem, null, user, now, user, future);

            order.OrderLineItems.Clear();

            order.OrderLineItems = order.OrderLineItems == null ? new List<IOrderLineItem> { orderLineItem1 } : new List<IOrderLineItem>(order.OrderLineItems) { orderLineItem1 };

            _repository.SaveOrUpdate(session, order);
            transaction.Commit();
        }

Solution Code

order.OrderLineItems.Clear();

order.OrderLineItems = order.OrderLineItems == null
    ? new List<IOrderLineItem> { orderLineItem1 }
    : new List<IOrderLineItem>(order.OrderLineItems) { orderLineItem1 };
firstly if order.OrderLineItems is null then the order.OrderLineItems.Clear() will throw a NullReferenceException, secondly the problem is arising because you're assigning a new List to order.OrderLineItems so NHibernate doesn't know what to cascade the delete for. To get it to work, just change the second line to:

order.OrderLineItems.Add(orderLineItem1);

Friday, 15 September 2017

{"Cannot access a disposed object.\r\nObject name: 'System.ServiceModel.Channels.ServiceChannel'."}

For this Service reference has been disposed. so we should register service as a Factory in windsor as below.


Component.For<ILoginMessageManagementService>()
                         .AsWcfClient(WcfEndpoint.FromConfiguration("N3A_LoginMessageManagementServiceHttps"))
                         .LifestylePerWcfOperation(),








usage

private readonly IServiceFactory<ILoginMessageManagementService> loginMessageManagementServiceFactory;


        public MeetXIntegrationSystem(IMeetXApi meetXApi, ICustomerRepository customerRepository, IUserApi userApi, IServiceFactory<ILoginMessageManagementService> loginMessageManagementServiceFactory)
        {
            this.meetXApi = meetXApi;
            this.customerRepository = customerRepository;
            this.userApi = userApi;
            this.loginMessageManagementServiceFactory = loginMessageManagementServiceFactory;
        }




 loginMessageManagementServiceFactory.ExecuteWithService(
                    loginMessageManagementService =>  loginMessageManagementService.SaveLoginMessage(messageModel));

Tuesday, 20 June 2017

Drop Down width increases automatically in IE 11

Add the onmousedown attribute and have it focus on the select dropdown so that it loses focus from the input box. For some reason focus on the input before accessing that select causes this error.
<select onmousedown="$(this).focus()">

Saturday, 3 June 2017

Cannot open database "" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\'. after hosting on IIS

Looks like it's failing trying to open a connection to SQL Server.
You need to add a login to SQL Server for IIS APPPOOL\ASP.NET v4.0 and grant permissions to the database.
In SSMS, under the server, expand Security, then right click Logins and select "New Login...".
In the New Login dialog, enter the app pool as the login name and click "OK".
enter image description here


If you are using some custom app pool then give your app pool name.

Cannot open database "" requested by the login. The login fled. Login failed for user 'NT AUTHORITY\SYSTEM'. in mvc

Finally I set the pool identity on LocalSystem and thought why it might be preventing "NT AUTHRITY\SYSTEM" from opening a connection to my database. I opened up SQL Server Management Studio as the user "Administrator" and checked out the Server Roles for NT AUTHORITY\SYSTEM under "logins" section. The default server role for this user was public by default. I also checked sysadmin and refreshed my web application form.

Monday, 27 March 2017

Error: $injector:unpr Unknown Provider


This error results from the $injector being unable to resolve a required dependency. To fix this, make sure the dependency is defined and spelled correctly. For example:
angular.module('myApp', [])
.controller('MyController', ['myService', function (myService) {
  // Do something with myService
}]);

 The above code will fail with $injector:unpr if myService is not defined.

For More visit https://docs.angularjs.org/error/$injector/unpr