Category Archives: Common errors

Unit Test Adapter threw exception: Type is not resolved for member ‘FluentNHibernate.Cfg.FluentConfigurationException,FluentNHibernate

I’ve seen this error while running my test project from Visual Studio.

Type Is Not Resolved Exception

Although, I tried several solution alternatives, I couldn´t find a good one. These are some posts I followed,

I finally found the solution by catching the real exception as follows.

  • Fisrtly, I added a try catch block in the line where the exception was being raised. After all, the Type Is Not Resolved exception didn’t give enough information to infer what was wrong.
  • In second place, I debugged setting a break point just after the catch statement

 

Type Is Not Resolved Exception Detail

  • The I could find the real exception, which said,

The following types may not be used as proxies: SolutionName.Core.ClassName: method InitializeMembers should be ‘public/protected virtual’ or ‘protected internal virtual’

One of my Core classes (one of the classes mapped by NHibertane to the database)  was calling a method named InitializeMembers in the constructor and this method’s signature was public void.

  • I finally fixed it by changing the method’s signature as shown in the image bellow

Reduce the scope of initialization method to private or protected internal

WCF – Error 500.21 Handler svc-Integrated has a bad module ManagedPipelineHandler in its module list

If you have received this error while trying to launch a WCF service on a new server installation.
It’s produced by a missing module registration. To fix it, simply registering aspnet modules again.

1) Open a command prompt window (It could be a Visual Studio Command Prompt)
2) Run aspnet_regiis -i
aspnet_regiis command

That’s it.

Try to launch your service again. It should be working.

Configuration binding extension ‘system.serviceModel/bindings/webHttpBinding ‘ could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.

I found this error while trying to get the service wsdl.

Configuration binding extension ‘system.serviceModel/bindings/webHttpBinding ‘ could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.

Please, notice that there’s a blank space at the end of webHttpBinding

To fix this issue, simply remove that from the configuration file =)

NHibernate.HibernateException SqlDateTime overflow

Working on a project based on the wonderful Sharp Architecture, I’ve noticed that under some circumstances, creating and saving an instance of an object which has DateTime members raised an exception like this one,

NHibernate.HibernateException SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

Here is a sample code, where I just change the customer name.

Let’s suppose I have Customer persistence class, which is defined as,

public class Customer : Entity

{   #region Members

public virtual string Name { get; set; }

public virtual DateTime Birthday { get; set; }

#endregion Members

}

Now, get our first Customer and change his Name,

Customer cust = customerRepository.Get(1);

customerRepository.DbContext.BeginTransaction();

cust.Name = “John”;

customerRepository.SaveOrUpdate(cust);

customerRepository.DbContext.CommitTransaction();

Quick Solution: Change the DateTime fiel to null able adding a ? sign. So, the Birthday declaration should be like this,

public virtual DateTime? Birthday { get; set; }

In order to know the reason of this issue, please refer to this great explanation at http://barchitect.blogspot.com/2009/07/nhibernate-sqldatetime-overflow-issue.html