Saturday, December 14, 2019

Install Visio on Computer with Office 365

I ran into compatibility issues when installing a stand alone version of Visio Professional on a new Windows 10 computer with Office 365 installed.   Install complained of compatibility issues with the Office Click-to-Run Extensibility Component.


I solved the issue by going to account.microsoft.com. I had registered my Visio product there 4 years ago and an install link and product key were displayed there.   I clicked the install link and Visio installed without issue.   Office applications still work too.

Monday, July 16, 2018

Google Analytics Exceptions

You may have noticed some exceptions in the Visual Studio output window when using Google Analytics.    I had 3 exceptions of  "Automation server can’t create object" and one exception of  "Unable to get property getRandomValues of undefined or null reference".

Automation Server Can't Create Object

The Google Analytics javascript in analytics.js tries to determine what version of ShockwaveFlash is installed on your computer by trying to create objects of three versions of ShockwaveFlash and use an instance even if it's null which throws an exception.  The exceptions are caught and not re-thrown so there are no issues, but you will see the exceptions in the Visual Studio output window.

 Here is the code of interest:

 function fc() {
var a, b, c; if ((c = (c = O.navigator) ? c.plugins : null) && c.length)
for (var d = 0; d < c.length && !b; d++) {
var e = c[d]; - 1 < e.name.indexOf("Shockwave Flash") && (b = e.description)
}
if (!b) try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"), b = a.GetVariable("$version")
} catch (g) {}
if (!b) try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"), b = "WIN 6,0,21,0", a.AllowScriptAccess = "always", b = a.GetVariable("$version")
} catch (g) {}
if (!b) try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"), b = a.GetVariable("$version")
} catch (g) {}
b &&
(a = b.match(/[\d]+/g)) && 3 <= a.length && (b = a[0] + "." + a[1] + " r" + a[2]);
return b || void 0
};


Unable to get property getRandomValues

An analytics.js function relies on an exception to determine if the  .crypto object is defined.  The function returns a value in the catch().

Again, the exceptions is caught and not re-thrown so there are no issues, but you will see the exceptions in the Visual Studio output window.

Here is the code of interest: 

var hd = function() {
return Math.round(2147483647 * Math.random())
},
      Bd = function() {
      try {
      var a = new Uint32Array(1);
      O.crypto.getRandomValues(a);
      return a[0] & 2147483647
      } catch (b) {
      return hd()
      }

Thursday, May 3, 2018

Format Phone Number

You have nine digits but you want to format the phone number for a readable display. 


string strContactPhone = "123456789";
Int64 phoneInt;

if (Int64.TryParse(strContactPhone, out phoneInt)) ;
{
    strContactPhone = String.Format("{0:(###) ###-####}", phoneInt);
}


Visit www.BlueCanyonSoftware.com for custom software development.

Sunday, April 22, 2018

View GAC from Visual Studio

What assemblies are running in the Global Application Cache (GAC)?   

You can use the gacutil utility to view the GAC but it's really convenient to view GAC assemblies in Visual Studio.

Open the Assembly Explorer.
Click the "Open from GAC" button as shown in this image.




Visit www.BlueCanyonSoftware.com for custom software development.

Friday, August 4, 2017

WCF Transport Quotas

Check out this article "Making Sense of Transport Quotas".

Monday, April 24, 2017

Session is Null with SQL Server Session Mode

The Problem

Session variable works fine with InProc Session Mode but is null when you switch the Session Mode to SQLServer mode. 
You may see the following exception.
"Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode." 

Make sure you check the inner exception to see which class needs to be changed to Serializable.

Review all the data you have stored in Session variables to verify the data is serializable.  .NET knows how to automatically serialize the simple built in types like string, enum, integer, etc. Any classes you create are NOT serializable by default. Fortunately, you can make your classes serializable with a simple class attribute of [Serializable] like this.

[Serializable]
public class Address
{
       public int      nStreetNum;
       public string strStreetName;
}

[Serializable]
public class Customer
{
      public string strFirstName;
      public string strLastName;
      public Address Addr;  // The Address class must be serializable.

      public Customer(string FirstName, string LastName, Address theAddr)
     {
          strFirstName = FirstName;
          strLastName = LastName;
          Addr = theAddr;
     }
}

Your class must meet these requirements to be serializable:

  • Your class must have the Serializable attribute
  • Any classes it derives from must have the Serializable attribute.
  • All class member variables must be serializable types.  For example, the Address type used for Customer Addr member variable must also be serializable.


Visit www.BlueCanyonSoftware.com if you need custom software development.

Saturday, April 8, 2017

Get Session Variable and Check for Null

Accessing a Session variable that hasn't been created causes a null exception.   You can use the C# null-coalescing(??) or 'as' operators to simplify and avoid a null exception.

First two examples yield the same result;
myClassObj will receive the myClassObj stored in the Session variable if it exists; otherwise null.

With ?? Operator

   MyClass myClassObj = (MyClass)Session["mySessionName"] ?? null;

With as Operator

   MyClass  myClassObj = Session["mySessionName"] as MyClass 


With Both Operators

   string strMyClass = Session["mSessionName"] as string ?? "";