Saturday, April 20, 2019

VBA Range Run-time error 91 Object variable or With block variable not set

Run-time error 91;Run-time error 91 Object variable or With block variable not set;Run-time error 91 while defining Range;VBA Range Run-time error 91 Object variable or With block variable not set;create 5 seconds before unload userform


Error:


I encountered the below error when I try to define a range variable.

Run-time error '91':
Object variable or With block variable not set


Code:

Dim changedRange As Range

changedRange = Sheets(sheetName).ListObjects(table).DataBodyRange --Error on this line

Solution:


Needed to use "Set", because I had defined changedRange as Range - and this is an Object ;)
Set changedRange = Sheets(sheetName).ListObjects(table).DataBodyRange

That solved the issue.


VBA - Create a time delay before unloading User Form

create delay to unload VBA userform;VBA;VBA unload userform delay;create 5 seconds before unload userform


I had a requirement to unload an VBA user form after few seconds delay, that I used to display progress of the tasks.

Solution:


You may try the below:

Application.Wait Now + TimeValue("0:00:03") 'Create a time delay of 3 seconds

Sample Code:

FrmProgress.Label1.Caption = "Loading data from database...."
FrmProgress.Show
FrmProgress.Repaint

'...code for whatever it is you want to do

Application.Wait Now + TimeValue("0:00:03") 'Create a time delay

Unload FrmProgress


Thursday, January 24, 2019

Citrix SSL Error 61: Contact your help desk with the following information

Citrix SSL Error 61;Citrix SSL Error 61: Contact your help desk with the following information;the issuer of the server's security certificate ((SSL error 61)


I am using Ubuntu 12.04 LTS (32bit) and the latest Linux version of Citrix Receiver. Whenever I try to connect to my work network through Citrix I used get the error message below:

SSL error : Contact your help desk with the following information: You have not chosen to trust "/C=US/ST=/L=/O=Equifax/OU=Equifax Secure Certificate Authority/CN=", the issuer of the server's security certificate (SSL error 61).


Solution:


Make Firefox's certificates accessible to Citrix. Run the below code in the terminal.

sudo ln -s /usr/share/ca-certificates/mozilla/* /opt/Citrix/ICAClient/keystore/cacerts
This did the trick for me.

Could not load file or assembly System.Web.Mvc, Version=3.0.0.1


Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.1;Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified;

Error:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified

Solution:

  • Remove the MVC reference and add the correct reference to the project
  • Change the Copy Local property of the reference to true
  • Update the bindingRedirect setting in web.config as below

web.config runtime section:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.1" />
</dependentAssembly>

Change the Copy Local setting will include the System.Web.MVC.dll file in the bin folder when you publish the project, so that it works even if the server is not updated with the new version.

Error 3 'CompareAttribute' is an ambiguous reference between 'System.ComponentModel.DataAnnotations.CompareAttribute' and 'System.Web.Mvc.CompareAttribute'

Error 3 'CompareAttribute' is an ambiguous reference between 'System.ComponentModel.DataAnnotations.CompareAttribute' and 'System.Web.Mvc.CompareAttribute';Error 3;CompareAttribute is an ambiguous reference

Error:


Error 3 'CompareAttribute' is an ambiguous reference between 'System.ComponentModel.DataAnnotations.CompareAttribute' and 'System.Web.Mvc.CompareAttribute'

Cause:


This happens when running VS 11 with mvc Beta 4 and .Net 4.5.

Solution:


To make this work between .NET4 and .NET45 you need to add the below statement in those files to:

using CompareAttribute = System.Web.Mvc.CompareAttribute;

Wednesday, January 23, 2019

Error 8 The type or namespace name 'PagedList' could not be found

Error 8 The type or namespace name 'PagedList' could not be found;Error 8 The type or namespace name 'PagedList' could not be found (are you missing a using directive or an assembly reference?)

I encountered the below error while compiling the project.

Error 8 The type or namespace name 'PagedList' could not be found (are you missing a using directive or an assembly reference?)


Solution:

Try installing the PagedList.MVC NuGet package for your project.
You could use the following steps to do so :

Right-click your Project within the Solution Explorer
  • Choose the "Manage NuGet Packages" option that appears
  • Search for "PagedList.MVC" within the search box
  • Click "Install" on the first option that appears : 



This should add all of the appropriate references that you need. You'll then just need to add the appropriate using statements within your code (generally, you could right-click on the ToPagedList() method and choose the "Resolve..." option to do this automatically).

Wednesday, January 25, 2017

Telerik ASP.NET Ajax client-side framework failed to load

Telerik;0x800a139e - JavaScript runtime error: ASP.NET Ajax client-side framework failed to load;0x800a1391 - JavaScript runtime error: 'Sys' is undefined

For Internet Explorer users getting the following error:


Problem:

Recently I encountered an issue, RadScriptManager started throwing the following errors:

0x800a139e - JavaScript runtime error: ASP.NET Ajax client-side framework failed to load.

0x800a1391 - JavaScript runtime error: 'Sys' is undefined


This issue is observed on IE 11 and doesn't appear on Chrome or Firefox Browsers.

Suggested solution:


I had below in my web.config. I removed runtimeversion2.0 and it worked well.


<add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd"
                 type="Telerik.Web.UI.WebResource" verb="*"
                 preCondition="integratedMode,runtimeVersionv2.0"/>  




Thursday, October 13, 2016

0 and 1 String was not recognized as a valid Boolean - Boolean Parameter in SQLDatasource

String was not recognized as a valid Boolean, System.FormatException: String was not recognized as a valid Boolean,Boolean parameter SQLDataSource,Setting up Boolean Value SQLDataSource InsertParameters

I had a SQLDataSource with insert parameters and one of which data type was set to Boolean. And I was setting the default value for insert parameters in code behind.

aspx code:
<asp:Parameter Name="bIsActive" Type="Boolean" />


I assumed that 1 or 0 would naturally be converted into Boolean when I did this:

SqlDataSource1.InsertParameters["bIsActive"].DefaultValue = c.Checked ? "1" : "0";


But instead I saw this:

String was not recognized as a valid Boolean.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: String was not recognized as a valid Boolean.
Fig 1: String was not recognized as a valid Boolean


ASP.NET can easily convert 1 and 0 (integer types), but struggles with Strings.

Solution:


I used True and False strings instead of 0 and 1.

SqlDataSource1.InsertParameters["bIsActive"].DefaultValue = c.Checked ? "True" : "False";

Thursday, October 6, 2016

This Page Can’t Be Displayed Turn On TLS 1.0, TLS 1.1, And TLS 1.2

This Page Can’t Be Displayed Turn On TLS 1.0, TLS 1.1, And TLS 1.2,This page can't be displayed error,Cannot Access Some HTTPS Sites with Internet Explorer

For Internet Explorer users getting the following error:

This page can’t be displayed - Turn on TLS 1.0, TLS 1.1, and TLS 1.2
in Advanced settings and try connecting to https://websitename
again. If this error persists, contact your site administrator.
Change settings. 
This issue is observed on IE 11 and doesn't appear on Chrome or Firefox Browsers.


Resolution:


 Launch Internet Explorer | Tools (Alt+X on IE 11) | Options | Advanced and make sure the settings match those below: 


Wednesday, October 5, 2016

Access denied error message while saving files on C drive - Windows 7

Access denied,Access denied saving files,Windows 7 Access Denied saving files, Windows 7 Cannot save files to Drive:,open text files as administrator

I have Windows 7 machine and have set myself as the Administrator. However, when trying to modify an XML file in Notepad and save the file, it states 'Access Denied!'. It will not save the file.



Below is the solution worked for me:

Step 1. Open the notepad application in elevated mode. This can be done by right click the Notepad icon from Windows > Click 'Run as administrator'.

Step 2. You can now edit and save that file in the same folder without any issues.



If you want to open the notepad elevated every time, then right click the Notepad shortcut icon > in 'shortcut' tab click on the 'Advanced' button > tick 'run as administrator'.



Win32Exception (0x80004005): The wait operation timed out

Win32Exception (0x80004005),Win32Exception (0x80004005) The wait operation timed out, The wait operation timed out,SQL Timeout expired
I was running an .NET console application that upon initial load pulls a list of items from a SQL server via a stored procedure. Within few seconds of loading the application, received the below error message:

Exception::System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out::Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.::.Net SqlClient Data Provider

Cause:
The problem was that the stored procedure took ~37 seconds to complete, which is slightly greater than the default timeout for a query to execute - 30 seconds. I figured this by executing the stored procedure manually in SQL Server Management Studio.

Resolution:
We need to set the CommandTimeout (in seconds) so that it is long enough for the command to complete its execution.

added the below line before filling the data adapter.
SqlCommand.CommandTimeout = 60; //60 seconds that is long enough for the stored procedure to complete.

Tuesday, October 4, 2016

Unable to connect to remote server while calling a Webservice

Unable to connect to remote server,Unable to connect to remote server WebService, System.Net.WebException Unable to connect to remote server
I received the following error, while calling a Webservice from an ASP.NET application.

System.Net.WebException: {"Unable to connect to the remote server"}.

Cause:

The internet explorer had the settings of a company proxy server and the application's web.config had no defaultProxy element on it. If the defaultProxy element is empty, the proxy settings from Internet Explorer will be used.


Resolution:

Add the defaultProxy element in web.config and set useDefaultCredentials=true.

<system.net>
    <defaultProxy useDefaultCredentials="true" >
    </defaultProxy>
  </system.net>