Archive
How to compile .NET Core Console Application as .exe File?
When you compile .NET Core Console Application it will generate DLL file instead of exe file for the build project.
NET Core 3.0+ projects will now include an executable file for the platform you build on by default. This is just an executable and your main logic is still inside a .dll
file.
But .NET Core 3.0 also introduced single-file deployments so deploying with
dotnet publish -r win-x64 -p:PublishSingleFile=True --self-contained false
will create a single .exe file containing all your dependencies. You can change --self-contained
to true
to also include the .NET Core Runtime as well so .NET Core does not need to be installed globally on the target machine.
You can also do this from Visual Studio Publish

Hope it helps!
Define Composite Key in Model.(Core, EF Code First)
When there are composite keys in database table and when you try to put data annotation it will throw below error
Entity type ‘Orgmember’ has composite primary key defined with data annotations. To set composite primary key, use fluent API

The above code will not work and throw an error
Here is the solution for this problem
Step 1: Modify your modal class like

Step 2: Use the fluent API to set up a composite key.

Hope it helps!
How to remove x from Internet Explorer ?

How to remove X from IE input box, Here is the css we can write to remove x.
/* clears the ‘X’ from Internet Explorer */
input[type=search]::-ms-clear { display: none; width : 0; height: 0; }
input[type=search]::-ms-reveal { display: none; width : 0; height: 0; }
Or

/* clears the ‘X’ from Chrome */
input[type=”search”]::-webkit-search-decoration,
input[type=”search”]::-webkit-search-cancel-button,
input[type=”search”]::-webkit-search-results-button,
input[type=”search”]::-webkit-search-results-decoration { display: none; }
Thanks
The client and server cannot communicate, because they do not possess a common algorithm
I recently faced an interesting issue when trying to fetch data from third-party API. When trying to connect to the API endpoint, I received the following error message:
“An error occurred while making the HTTP request to https://<API endpoint>. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.” Inner exception was “Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.”
Solution :
The issue came up when we setup a Thycotic Secret Server on a hardened OS. On the OS TLS 1.0 was disabled for security reasons, however at the moment the used Microsoft SQL server didn´t speak TLS 1.1 or TLS 1.2. So the error message:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 – The client and server cannot communicate, because they do not possess a common algorithm.)
After TLS 1.0 was enabled on the Thycotic Server the installation could be performed without issues. So make sure that your Microsoft SQL environment is up to date and supports TLS 1.1/1.2 if you wish to disable TLS 1.0.
How to check if all items are the same in a list C#
Here is sample code to check if all the items are same in a list
if(list.Any(x=> x ! = list[0]))
If you want to check any specific property use following code
if(list.Any(x=> x.Name ! = list[0].name))
Hope this help!
How to Collapse all #regions only(!) in C# (Visual Studio)
Follow below step to Collapse all #regions
- Go to Tools Menu of Visual Studio
- Select Options
- Select Text Editor
- Select C#
- Select Advanced Option
- Checked Collapse #regions when collapsing to definitions
Now if you press ctrl + m + o it will collapse all #regions.
Issue: Password field returned empty in edit mode
This is as per design. Passwords are not filled to prevent accidental resubmits, and to prevent the page from containing unencrypted passwords.
Here is the solution
@Html.PasswordFor(model => model.Password,new{@Value=Model.Password})
OR
@Html.PasswordFor(model => model.Password, new { placeholder = "********" })
This will put some 'visual' asterisks in the input box which will be disappeared when the user starts entering an actual value.
Hope this help!
Load XML from URL giving an error (The remote server returned an error: (401) Unauthorized.)
If you are getting a 401 Unauthorized error while reading an XML from URL, here is the solution you can try
Hope this help!
How to use Variable in MySQL Like Clause ?
Here is an example to use SQL variable in the mysql select query like clause
SET @name = 'advancewebsoftware';
SELECT * from `user` WHERE name LIKE CONCAT('%', @name, '%');
Hope this help!
Error :(System.Web.UI.HtmlControls.HtmlIframe) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlGenericControl) in VS2017
Reason for the above error is I have my project in .NET framework 3.5 and I update it to .NET framework 4.5,
Solution for the above error is:
We need to change the *.designer.cs file reference from:
System.Web.UI.HtmlControls.HtmlIframe
to
System.Web.UI.HtmlControls.HtmlGenericControl
Comments