Friday, September 3, 2010

CorFlags, C# and InteropServices.COMException (0x80040154): Class not registered

CorFlags is a Visual Studio command line utility that allows an executable that was compiled as (for instance) 'anycpu' to be run on a machine of a different architecture.

Some applications written in VS and compiled with x86, will not run on Windows 7.

The executable needs to be modified using corflags.

The error that caused me to find this issue is

System.Runtime.InteropServices.COMException (0x80040154): Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

Run this in the VS command line.  Navigate to the executable folder.

corflags [path] /32bit

Now, the /32bit tells the .net framework to run this app as a 32 bit application.  Other options are available.

Thursday, September 2, 2010

No applicable name scope exists to resolve the name, Error. C# WPF

This error can occur when:

      A storyboard begins ->  myStoryBoard.Begin(myElement); <- and a programatically created element has not been added to a parent yet.

Add 'myElement' to a parent on the form.

Tuesday, August 24, 2010

C# WPF Button Blink Problem

In a WPF application, if a button is clicked, the focus gets put on that button.

Sometimes this will cause the button to constantly blink.

In order to stop the button from blinking, some solutions say to put the 'focus' onto another button.

I think, a cleaner way, is to set the 'Focusable' property to false.  This doesn't seem as 'hacky' as setting focus to another button, and still fixes the problem.

Wednesday, August 18, 2010

HTML 5 Canvas

I wanted to put some HTML 5 Canvas stuff down.

Since HTML 5 is not finalized, some of this stuff might change.

There are a few gotchas that you will need to look out for.

HTML 5 is NOT XHTML.  This means that XHTML standards don't apply.  Attributes do not need quotation marks around values.  Element tags do not need to be closed.  These things are good ideas, but you do not need them.


CANVAS.  Man.  So, if you want to [STYLE] a canvas, there are some things you need to look out for.
To set the "WIDTH" and "HEIGHT" you need to set the "WIDTH" and "HEIGHT" attribute, not the "STYLE".  For instance, instead of style="width:20px; height: 20px;", you set attributes in the tag; like [ width="20" height="20" ].

Tuesday, August 17, 2010

Javascript Charts

This site is full of javascript chart websites.

http://www.articlediary.com/article/25-graph-chart-solutions-for-web-developers-277.html

Don't know if all are good, but www.highcharts.com is awesome.

Thursday, August 5, 2010

C# Stop Form Resize

An easy way to stop a C# WinForm from resizing is to set the 'FormBorderStyle' to any 'Fixed*' property.

(e.g. Fixed3D, FixedSingle, etc).

Tuesday, August 3, 2010

C# Forms Stop Redraw/Paint

I've tried to stop the 'Paint' event on a C# WinForm without overriding the 'Paint' event.

I've done some research and found a lot of people have this problem, but those problems can be easily fixed using the 'DoubleBuffered' property found on the form itself.  The main problem fixed by 'DoubleBuffered' is that the form flickers.

This is not my problem.

I want to stop the 'Paint' event of a 'TreeView', while I expand all the nodes.  This is important when there are many nodes in the tree.  If you 'Paint' while expanding, the form becomes unresponsive and ugly.

The only solution that I can come up with, is to 'Hide()' the control, expand the nodes, then 'Show()' the control again.  I tried this with the 'Form' itself, but it didn't seem natural.  By performing the operation with the control, it's tough to tell if the control is redrawing, or the nodes are just being added.

While this is a 'hacky' solution, I don't know any other way.

BTW: SuspendLayout() => ResumeLayout() doesn't stop the 'Paint' event.