MEI Series 2000 Bill Acceptor Goof

by sunil ravulapalli /2. April 2013 23:24 /kiosk /Comments (0)

I was recently trying to install a MEI Series 2000 Bill Acceptor on my machine for development with a kiosk software called Kioware. Initially I thought, I wasn't interfacing with Kioware correctly, turns out I did not hook MEI Series 2000 Bill Acceptor correctly.

I downloaded and installed on my development machine. Launched a desktop app called "MPOST .NET Demo in C# .NET". The Status in the App was "Disconnected". I tried the "Open" button but it did not work and threw some errors.

At this point I was sure I didn't hook up the MEI bill acceptor correctly and it had nothing to do with kioware.

Luckily, I got hold of the production machine in which the manufacturer hooked up the device to the computer. I installed on that machine and to my amazement when I hit the "Open" button, it actually connected!

Upon further investigation I saw that two things in the production machine.
1. The Red status light was blinking twice
2. All the "Bill acceptance switches" were in the off position.

While hooking up my development machine I read in the MEI manual that if the Red status light blinks twice it is supposed to be bad and I have to switch the 6th switch to the ON position. When I did that the Status actually went back to steady red which is supposed to be a good thing.

Turns out that actually messes things up. So on my development machine, I powered down the unit, turned all the switches to the off position. Re-powered it. Started the MPOST application and this time it connected. I tried Kiowares' demo HTML and it also worked.

Using ELMAH's SqlErrorLog to manually insert into Sql Server

by sunil ravulapalli /27. March 2013 00:47 /.net-tools /Comments (0)

This is a class I use to manually log into ELMAH tables

using Elmah;

namespace WesternUnionService
 public class Logger
  public static bool LogError(Exception exception)
	Error error = new Error()
		HostName = System.Environment.MachineName,
		Type = exception.GetType().ToString(),
		Source = exception.Source,
		Message = exception.ToString(),
		StatusCode = 0,
		Time = System.DateTime.UtcNow


	return true;

  public static bool LogInfo(string info)
	Error error = new Error()
		HostName = System.Environment.MachineName,
		Type = "Info",
		Source = ConfigurationManager.AppSettings["applicationName"],
		Message = info.Length <= 500 ? info : info.Substring(0,500),
		StatusCode = 0,
		Time = System.DateTime.UtcNow


	return true;

  private static void Log(Error error)
	  SqlErrorLog sqlErrorLog = new SqlErrorLog((Hashtable)ConfigurationManager.GetSection("elmah/errorLog"));


It can be used like below:

 //do something
catch (Exception ex)


Logger.LogInfo("Peek a boo");

Mocking session variables using Moq

by sunil ravulapalli /22. March 2013 00:20 /.net-tools /Comments (0)

If we want to test a controller method which uses session variables like the following example, we can use the Moq library to Mock up the session variables.

public ActionResult ShowBalance()
  var accountId = Convert.ToInt64(Session[SessionConstants.AccountId]);
  var last4DigitsOfSsn = Session[SessionConstants.Last4DigitsOfSsn].ToString();
  AccountStatus accountStatus = _quickPayService.ValidateAccount(accountId, last4DigitsOfSsn);
  if (accountStatus.IsValid)
    return View(accountStatus);
    return RedirectToAction("ShowError", accountStatus );

Below is an example of how session variables can be mocked

public void ShowBalance_WithNonExistantAccount_GoesToShowError()
  Mock<HttpSessionStateBase> session = new Mock<HttpSessionStateBase>();
  session.SetupGet(s => s["AccountId"]).Returns(99999999);
  session.SetupGet(s => s["Last4DigitsOfSsn"]).Returns("9999");
Mock<HttpContextBase> httpContext = new Mock<HttpContextBase>(); httpContext.SetupGet(c => c.Session).Returns(session.Object);
ControllerContext ctx = new ControllerContext(); ctx.HttpContext = httpContext.Object;
var quickPayServiceMock = new Mock<IQuickPayService>(); quickPayServiceMock.Setup(quickpayservice => quickpayservice.ValidateAccount(99999999, "9999")).Returns(new AccountStatus { IsValid = false }); KioskController controller = new KioskController(quickPayServiceMock.Object); controller.ControllerContext = ctx; //Act RedirectToRouteResult redirectToRouteResult = controller.ShowBalance() as RedirectToRouteResult; //Assert Assert.AreEqual("ShowError", redirectToRouteResult.RouteValues["action"].ToString()); }

Error loading module 'Ninject.Web.Mvc.MvcModule' of type MvcModule Another module (of type MvcModule) with the same name has already been loaded

by sunil ravulapalli /5. March 2013 00:58 /.net-tools /Comments (0)

Error loading module 'Ninject.Web.Mvc.MvcModule' of type MvcModule
Another module (of type MvcModule) with the same name has already been loaded
 1) Ensure that you have not accidentally loaded the same module twice.
 2) If you are using automatic module loading, ensure you have not manually loaded a module
    that may be found by the module loader.

While using NINJECT, If you are getting this error when using 


one possible solution might be is to do it this way, by listing out the dll's individually



I haven't figured out why the modules were loading more than once, but the above work around does achieve the "loose coupling" we seek.



TF271001: An error occurred while attempting to send an e-mail notification

by sunil ravulapalli /2. March 2013 00:44 /tfs /Comments (0)

After setting up the Email settings in the "Team Foundation Administration Console", I still did not get any emails. Upon looking into the event logs I found:

TF53010: The following error has occurred in a Team Foundation component or extension:

Date (UTC): 3/1/2013 8:37:30 PM


Application Domain: TfsJobAgent.exe

Assembly: Microsoft.TeamFoundation.Framework.Server, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a; v2.0.50727

Service Host: 

Process Details:

  Process Name: TFSJobAgent

  Process Id: 1468

  Thread Id: 2440

  Account name: COMPANY\TFS

Detailed Message: TF271001: An error occurred while attempting to send an e-mail notification to the following address: Further e-mail notification errors that occur within the next five minutes might not be logged. Verify that the e-mail notification settings are correct in the Team Foundation Administration Console.

Exception Message: Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender (type SmtpException)

Exception Stack Trace:    at System.Net.Mail.DataStopCommand.CheckResponse(SmtpStatusCode statusCode, String serverResponse)

   at System.Net.Mail.DataStopCommand.Send(SmtpConnection conn)

   at System.Net.Mail.SmtpClient.Send(MailMessage message)

   at Microsoft.TeamFoundation.JobService.Extensions.Core.NotificationJobExtension.SendEmail(TeamFoundationRequestContext requestContext, TeamFoundationNotification notification)


1. TFS was a valid active directory user

2. "From address" was

3. Anonymous sender was enabled in Exchange

Upon requesting the exchange team, they found this entry in their event log:

Log Name:      Application

Source:        MSExchangeTransport

Date:          2/26/2013 4:37:31 PM

Event ID:      1025

Task Category: SmtpReceive

Level:         Error

Keywords:      Classic

User:          N/A



SMTP rejected a (P1) mail from '' with 'Spam Filter' connector and the user authenticated as 'GOPFS\TFS'. The Active Directory lookup for the sender address returned validation errors. Microsoft.Exchange.Data.ProviderError

Event Xml:

<Event xmlns="">


    <Provider Name="MSExchangeTransport" />

    <EventID Qualifiers="49156">1025</EventID>




    <TimeCreated SystemTime="2013-02-26T23:37:31.000000000Z" />




    <Security />




    <Data>Spam Filter</Data>







The last thing we tried was to enable a mail box to the "TFS" user in exchange and the emails started flowing!

Convert large hex to decimal

by sunil ravulapalli /28. February 2013 20:07 /other /Comments (0)

C# does have a big enough data type to hold big decimal numbers.

So, coding will not help.

After googling a lot I found a website to do it for me:

Luckily, I didn't need this in a program. I just had to verify some numbers. When you pull up the certificate properties in the "certificate repository", it shows up in hex. But in my "Signed Xml", the serial number showed up as decimal. So, i just needed a tool to convert between the two.

TFS build not picking up correct configurations

by sunil ravulapalli /20. February 2013 23:34 /tfs /Comments (0)

I encountered a bizarre problem where TFS was picking up the wrong configuration settings. For example, if I wanted to do a production build using, it was picking up settings from

After a lot of investigation, I found the answer in the Solution(.sln file). Essentially I think the solution was telling TFS to pick Qa settings when TFS asks for Prod. 

{AB15DD03-6329-4468-96F9-DE694B31617C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Debug|Any CPU.Build.0 = Debug|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Prod|Any CPU.ActiveCfg = Qa|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Prod|Any CPU.Build.0 = Qa|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Qa|Any CPU.ActiveCfg = Qa|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Qa|Any CPU.Build.0 = Qa|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Release|Any CPU.ActiveCfg = Release|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Release|Any CPU.Build.0 = Release|Any CPU


I still don't know what I keep doing for this to happen. But it happens multiple times for different projects and each time I have to go and fix this by manually going and editing it like below. 



{AB15DD03-6329-4468-96F9-DE694B31617C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Debug|Any CPU.Build.0 = Debug|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Prod|Any CPU.ActiveCfg = Prod|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Prod|Any CPU.Build.0 = Prod|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Qa|Any CPU.ActiveCfg = Qa|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Qa|Any CPU.Build.0 = Qa|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Release|Any CPU.ActiveCfg = Release|Any CPU

{AB15DD03-6329-4468-96F9-DE694B31617C}.Release|Any CPU.Build.0 = Release|Any CPU


How do I even google this? :)

Intranet and Internet site look different in IE 10

by sunil ravulapalli /20. February 2013 21:18 /other /Comments (0)

Recently, when I opened a local site intranet site in IE10, it looked broken. When I cross checked the same on my production sever it looked fine. I checked to make sure all my code was same, it was.

So, what gives?

I hit F12 and saw 3 things which seemed off.

1. Browser mode: IE10 Compat View

2. Document Mode: IE7 Standards

3. What was my DOCTYPE commented?

So I started googled "ie10 doctype getting commented out" and I found my answer here:

The following post also says, "Are you on the same domain? If so, IE automagically forces one into intranet-friendly compatibility mode. "

To summarize, if you put this in your web.config, it generates a META tag in the HEAD telling IE to use latest rendering mode instead of going to older modes no matter what.

    <clear />
    <add name="X-UA-Compatible" value="IE=edge" />

Force Windows Phone 7.8 Update

by sunil ravulapalli /13. February 2013 01:17 /other /Comments (0)

Like many people I was desperate to update my Noikia Lumia 7.5 to 7.8. I kept reading all gadget websites everyday to see if ATT would send out the update. Some sites suggested using an update software by an enthusiast but it came with several warnings, so I decided not to go that route. I my quest for other information, I bumped into this forum which talked about some weird Zune bug to force an update. This seemed much safer to me as it was still Zune which was doing your update. So I tried it. I am glad to report that it works great!

1. Disable Wifi and Cellular Data

2. Connect to PC, open zune, settings, then phone, then update. It won’t find any, but you NEED to do this.

3. Change the tab (navigate away from Update). Now click on Update again, but disconnect your internet connection after 2 seconds. BAM an Update is available after waiting a few seconds!

4. Hook up internet and proceed!

Additional notes:

1. I had a tough time doing STEP 3. You had to be really quick to disconnect the internet after you hit UPDATE. I dragged Zune to my lower right corner, so that my mouse has lesser distance to travel. I guess if there is a Keyboard shortcut to disconnect the internet, it would be advisable.

2. I also had to do this whole thing twice. I think first update just preps it and second actually does the 7.8 update.

HTML Canvas Rotate Image

by sunil ravulapalli /22. January 2013 04:08 /javascript /Comments (0)

The following is a function to rotate an image using javascript on html canvas:

    function rotateImage(img, x, y, width, height, deg) {

        //Convert degrees to radian 
        var rad = deg * Math.PI / 180;

        //Set the origin to the center of the image
        ctx.translate(x + width, y + height);

        //Rotate the canvas around the origin

        //draw the image    
        ctx.drawImage(img, width * (-1), height * (-1), width, height);

        //reset the canvas  
        ctx.rotate(rad * (-1));
        ctx.translate((x + width) * (-1), (y + height) * (-1));

It can be used a follows:

    var ctx = canvas.getContext("2d");

    var img = new Image();
    img.src = "fish.png";

    rotateImage(img, 50, 50, 100, 100, 45);