Friday, November 22, 2019

Error: Parser Error Message: Could not load type” in Global.asax

I resolved this error to change project OutputPath property to "bin" instead of "bin\Debug" or "bin\Release"

Go to the Project right click and select Property > Compile and change "Build output path" to "bin\"


or Unload project and open for Edit and Modify Outputpath property to "bin\" instead of "bin\Debug" or "bin\Release".
and also you can check IIS pool should be in correct .NET version (2.0 or 4.0)

Create Pipeline build to Push DLL into Nuget Repository using Azure DevOps


Here simple steps to follow and create new Automated Build using Azure DevOps to push your DLLs into NuGet Repository 

You mainly needed three task to Restore, Pack and Push library into NuGet repository.

Go to Pipeline > Build > Create New Build , Add following Task on your build 

  1. Get a Sources
    1. Choose Repository (TFVC or Git)
  2. Add Agent Job
    1. NuGet Tool Installer : leave all default
                                                    i.     Type: Map
                                                   ii.     Server Path: choose source code location
                                                  iii.     Clean: true
                                                  iv.     Clean Options: sources
                                                   v.     Label sources: OnSuccess
                                                  vi.     Label format: $(Build.BuildNumber)
    1. NuGet  for Restore
                                                    i.     Choose command : restore
                                                   ii.     Path to solution, packages.config, or project.json (.sln file path)
                               iii.     Use packages from this Azure Artifacts/TFS feed
                                iv.     Check: Use packages from NuGet.org
    1. Update AssemblyInfo
                                                    i.     Root Folder: $(Build.SourcesDirectory)
                                                   ii.     File pattern (AssemblyInfo.cs)
                                                  iii.     Version: $(Build.BuildNumber)
                                                  iv.     File Version: $(Build.BuildNumber)
    1. Visual Studio Build
                                                    i.     Solution :   .sln file path
                                                   ii.     Visual Studio Version: Latest
                                                  iii.     Platform : AnyCPU
                                                  iv.     Configuration: Release
                                                   v.     Check: Clean
    1. NuGet (for pack)
                                                    i.     Command: pack
                                                   ii.     Path for proj or nuspec
                                                  iii.     Pack Option: “Use the build number”
    1. NuGet (for Push)
                                                    i.     Command : push
                                                   ii.     Path to NuGet package to publish ($(Build.ArtifactStagingDirectory)/*.nupkg)
                                                  iii.     Target Feed: Select a feed hosted in this account. You must have Package Management installed and licensed to select a feed here.”

Go to this video for more details 

Common errors when you automate build using Azure DevOps build


Error-1
The nuget command failed with exit code(1) and error(System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory.

Solution
I observed this error when I was trying to create automated build using Azure DevOps Pipeline and I changed **/*.csproj  from **/*.Sln as a file to build.

To Resolve this error, in the Pipeline Task select  NuGet & use Pack Option instead of Restore Option, Restore Option work for Solution file only not for project file.

Error-2
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(775,5): Error : The OutputPath property is not set for project 'ABC.csproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Release'  Platform='Any CPU'.  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.

Solution
Again if you are switching from .Sln file to .csproj or .vbproj file to be build then make sure you are selecting the correct "Platform" property.

For Project file , Platform property value is "AnyCPU" and 
For Solution file, Platform property value is "Any CPU" (with space)

so, you need to open project file in notepad and check PropertyGroup section and OutputPath tag should look like below.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <OutputPath>bin\Release\</OutputPath>
      .
      .
</PropertyGroup>

Error-3
Response status code does not indicate success: 409 (Conflict - The feed already contains “*.dll <Version Number>”)

Solution:
When you get this error that mean project is building correctly but not increasing the build number, so server trying to push same dll version into NuGet and it not allow duplicate version number, and throw 409 error
If you choose "Skip duplicate version" option then it will resolve the issues but that will not be correct because latest version never deployed into NuGet server. 

The best solution I found, in NuGet Task select following option 
Command : pack
Automatic package versioning : Use the build numbers 

This will create new version every time when new DLL build successfully, so No 409 error.

Wednesday, November 13, 2019

Error: The visual tree has been changed during a 'VisualTreeChanged' event.

Error: The visual tree has been changed during a 'VisualTreeChanged' event.

Solution: 
Go to Visual Studio, Tools >> Options and unchecked "Enable UI Debugging Tools for XMAL"

 

Tuesday, November 12, 2019

Error: The authentication schemes configured on the host ('Ntlm, Anonymous') do not allow those configured on the binding 'BasicHttpBinding' ('Negotiate'). Please ....

ErrorThe authentication schemes configured on the host ('Ntlm, Anonymous') do not allow those configured on the binding 'BasicHttpBinding' ('Negotiate').  Please ensure that the SecurityMode is set to Transport or TransportCredentialOnly.  Additionally, this may be resolved by changing the authentication schemes for this application through the IIS management tool, through the ServiceHost.Authentication.AuthenticationSchemes property, in the application configuration file at the element, by updating the ClientCredentialType property on the binding, or by adjusting the AuthenticationScheme property on the HttpTransportBindingElement.

Solution:

I have done following two things in IIS setting to resolve following error

1) Make sure for Hosted WebSite/App two Authentication option is set to Enabled
     Anonymous Authentication = Enabled and Window Authentication = Enabled


2) Right click on Window Authentication >> Providers
     make sure you have NTLM and Negotiate is added as Enabled Providers, If not just add it.



Sunday, May 19, 2019

How to add innerHTML or Multi line text to NgbPopover


I was trying to show multi line text on Popover and want to format my display contain as I want using HTML tag. text construction has to be done in .ts file.

I achieved this in following way.

Label where, on mouseover I want to show popover with employee detail data.
I want when use mouseover then popover display and if user click outside or click “esc” then popover disappears. You can also use moverover and mouse leave using triggers="mouseenter:mouseleave"

npm install --save @ng-bootstrap/ng-bootstrap

app.module.ts

//Popover- menu item
import { NgbPopoverModule, NgbModalModule, NgbAlertModule } from '@ng-bootstrap/ng-bootstrap';
@NgModule({imports: [NgbPopoverModule]})

Employee.html file 

            name="EmployeeProfile "
(mouseover)="getEmployeeProfileData()"
            [ngbPopover]="ShowEmployeeProfile" 
popoverTitle="Employee Detail Profile"
            triggers="mouseenter" [autoClose]="'outside'">
</label>

 <ng-template #ShowEmployeeProfile >
 <div[innerHtml]="employeeDetailDataForToolTip"</div>
</ng-template>

Employee.ts file

employeeDetailDataForToolTip: string ="";

getEmployeeProfileData(): string
{
this.employeeDetailDataForToolTip="";
this.employeeDetailDataForToolTip+='<ul><u>Ritesh Kesharwani</u>';
this.employeeDetailDataForToolTip+='<li>Address: Mile City, USA</lt;li>';
this.employeeDetailDataForToolTip+='<li> Department: Education</li>';
this.employeeDetailDataForToolTip+='<li> Salary: $300000</li>';
this.employeeDetailDataForToolTip+='<li> Base Location: MN</li></ul>'
}
If you want scroll bar on Popover then you need to override style sheet
.popover {
  max-width500px !important;
  background#F9F9F9 !important;
  max-height400px !important;
  overflowscroll !important;
}

sample pop over on label mouse over 


Tuesday, May 07, 2019

During Test Debug control not hits to the break points + Not able to debug test case


Go to the project property > Build and Uncheck following
  • Allow unsafe code
  • Optimize Code

 And Select Platform target: Any CPU



Error: testhost.x86.exe' has exited with code 0 (0x0).


Error: testhost.x86.exe' has exited with code 0 (0x0).

After my research I found, below nuget package was missing from my project.

I have installed below and it resolved the issue.

MSTest.TestFramework

Make sure following package are installed in your test project

MSTest.TestFramework And MSTest.TestAdapter

Monday, May 06, 2019

Render Date field in specific Date Format into ag-Grid Angular 6

In you ag-Grid if you want to display date field in specific format do the following steps

  1. npm Install moment --save
  2. in your .ts file use below

 import * as moment from 'moment';

columnDefs =
[{
headerName: 'Effective Start Date', field: 'EffectiveStartDate',
cellRenderer: (data) => {
return  data.value ? (moment(data.value).format('MM/DD/YYYY')) : '';}
}];


For more info on moment please use https://momentjs.com/


Add hyperlink click event into ag-Grid Angular 6

I had spent lots of time to figure how to add hyperlink into ag-grid column and how to call function executed at on click event. This was looking very difficult but later it came with very simple solution.
My requirement was to add hyperlink on Grid column with the rendered data, so no button where we have static word like “Add” etc.

Simple solution I could figure out is to add cellClicked event

.html page

<ag-grid-angular
    (cellClicked)='onCellClicked($event)'>
</ag-grid-angular>

And when cellClicked   by user execute Type Script function

.ts page

onViewCellClicked(event: any)
  {
    if (event.column.colId =="FirstName" ) // only first column clicked
    {
      // execute the action as you want here in on click of hyperlink
    }
// here you can add multiple if statement based on colId to do the action      //on cell clicked
  }

Your column definition as below

columnDefs = [{
headerName: 'First Name', field: 'FirstName', suppressMenu: false, unSortIcon: true, width:150,
      cellRenderer: function(params) {
        // below line is just to create empty without any action hyperlink
// to trick the user, but actual action happen onViewCellCliced() // function
        return '<a href="#">' + params.value + '</a>';
            },
            tooltipField: "FirstName", headerTooltip: "First Name"     
      }];