Blog Archives

Could not load type System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=

If you already have .Net 4.0 installed and install a program that brings in an earlier version of .Net, or manually install an earlier version of .Net afterwards, you may get an exception page that matches the title of this article.

This is a simple fix, outlined in detail in MSDN article referenced at the bottom.

Navigate to:

%windir%\Microsoft.NET\Framework\v4.0.30319

%windir%\Microsoft.NET\Framework64\v4.0.30319 (on a 64-bit computer)

Run:

aspnet_regiis.exe /iru

That’s it!

http://support.microsoft.com/kb/2015129

Advertisement

asp .net could not establish trust relationship for the SSL/TLS secure channel

A quick google search revealed multiple reported resolutions, however, after following the steps in the MSDN blog reference listed below, the issue was still unresolved in my situation.

Additional details in the stack trace will reveal another similar message: “The remote certificate is invalid according to the validation procedure.”

In this specific scenario, the site in question is either not configured with a wildcard certificate for a subdomain of the parent site or the operation system I am working on does not support SNI. In the meantime, a workaround is needed to continue testing and development.

Additional reading on google revealed another solution which was more suitable and utilized a code based approach, as opposed to a server configuration based solution.

To make it more dynamic, I added a key into the app/web config to control if SSL errors should be ignored. Please note that it is also possible to replace the code based approach solely with an app/web config entry listed in the west-wind blog referenced below, but I personally prefer to go with code whenever possible.

<?xml version="1.0"?>
<configuration>
  <configSections>
  </configSections>
  <connectionStrings>
    <add name="ConnectionString"
      connectionString="Data Source=servername;Initial Catalog=databasename;"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="ignoresslerrors" value="true"/>
  </appSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
 public class ConfigValues
    {
        public static string IgnoreSSLErrors { get { return getval("ignoresslerrors"); } }
}

public function main() {
connect("https://sitename.com",ConfigValues.IgnoreSSLErrors);
}

public function connect(string url, string ignoresslerrors) {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

try
            {
                if (Convert.ToBoolean(ignoresslerrors))
                {
                    System.Net.ServicePointManager.ServerCertificateValidationCallback +=
            delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                                    System.Security.Cryptography.X509Certificates.X509Chain chain,
                                    System.Net.Security.SslPolicyErrors sslPolicyErrors)
            {
                return true; //will always accept the cert and ignore errors. this is not good common practice unless you are sure of the destination you are connecting to. needed in this scenario to continue development until issue with cert is resolved.
            };
                }
            }
            catch (Exception ex)
            {
                Shared.HandleError(ex);
            }
}

References
http://www.west-wind.com/weblog/posts/2011/Feb/11/HttpWebRequest-and-Ignoring-SSL-Certificate-Errors

http://blogs.msdn.com/b/jpsanders/archive/2009/09/16/troubleshooting-asp-net-the-remote-certificate-is-invalid-according-to-the-validation-procedure.aspx

Arithmetic overflow error converting type to data type numeric

This error usually occurs when the type you are trying to convert to a decimal or numeric is larger than the column or casted type you are converting to.

Ex.

insert into tablename (decnumber) values (cast(1000.00 as decimal(5,2)))

Since the number specifed is 7 digits long include after the decimal and the converted type can only contain a maximum of 5 digits, you will receive this error.

Changing the table to hold 7,2 and/or changing this in the cast will resolve it.

References
devshed (forums), http://forums.devshed.com/ms-sql-development-95/arithmetic-overflow-error-converting-numeric-to-data-type-numeric-89157.html