WCF Data Services – Debugging

I have been building some data services that are used to connect too Oracle data sources. Everything worked fine within VS 2010 but on pushing my service to IIS locally and remotely I was getting error 500’s. I managed to solve the issues locally without to much trouble but on the remote server I really couldn’t for the life of me see what was going on. By default there was really very little in the way of debugging information.

ISSUE 1:

My First issue was error 500’s with no real logging. To find out what is happening here I used tracing. If you add the following to your web.config you will get some nice trace information:

<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>

MS info on this can be found here:

http://msdn.microsoft.com/en-us/library/ms733025.aspx

Then use the trace tool to look at the results:

http://msdn.microsoft.com/en-us/library/ms732023.aspx

ISSUE 2:

I was running Windows Server 2008 64bit but the data source from Oracle for odata only appears to be available in 32bit and that is what I installed. I was getting an error 500. To fix this you need to set your App Pool to support 32bit executables. To enable this in IIS right click your app pool and under “Advanced Settings” set Enable 32-Big Applications to True. This fixed my error 500.

ISSUE 3:

I was calling my WCF Data Service and getting a NotSupportedException with an InnerException of “An error occured while processing this request” there was no other information provided. I had no idea why this was happening, I needed to know more! After a lot of searching the net I found this setting:

public static void InitializeService(DataServiceConfiguration config)
{
config.UseVerboseErrors = true;
}

Building and deploying with this enabled gave me a nice error with the inner exception exposed.

ISSUE 4;

ORA-12154: TNS:could not resolve the connect identifier specified

This doesn’t seem like much, and there are HEAPS of articles where it pops up but nothing I could find told me how to fix it. Until I came across this:
ORA-12154: TNS:could not resolve the connect identifier specified

It basically says copy your data connection configurations to your client folder. When I installed the VS Compoents and the Odata/Asp.net client it created a new home directory and the configurations files were not getting picked up from the server home. I copied these and everything started to work!
NOTE: I needed to restart Oracle and IIS for these new settings to take effect.

Small things often cause pain – So why can’t I create a variable inside a switch statement?

Sometimes the smallest things can cause you pain. I had a nice example of this today. I’m still new to Objective C and find something new everyday. Was using a switch statement and had what at the time seemed like an odd little issue. I couldn’t seem to create variables and call methods. The error message I was getting back really wasn’t that helpful. Turns out it was as simple as surrounding the case statement calls in curly brackets. See below:

Fails:

case 2: 
    Alert *alert = [allAlerts objectAtIndex:indexPath.row];

    alertCell.textLabel.text = alert.date;//@"Date";
    alertCell.detailTextLabel.text = @"Alert Message";
    return alertCell;
 break;

Works:

case 2: {
    Alert *alert = [allAlerts objectAtIndex:indexPath.row];

    alertCell.textLabel.text = alert.date;//@"Date";
    alertCell.detailTextLabel.text = @"Alert Message";
    return alertCell;
} break;
http://stackoverflow.com/questions/4902568/how-do-i-create-a-variable-inside-a-switch-statement-for-a-uitableview

Yup all I need was those two curly brackets 😉 Now if only Xcode could have told me that!  Yeah I know this isn’t a big thing, just think it’s funny how the small things can be such a pain at times and how knowing the syntax of a language really can be an advantage at times. I guess the moral of the story is that small things really do matter.

 

Web Performance Tests – VS 2010 Crashing – Webtest Results Viewer

I’ve been doing a bit of work on Automated testing at work lately. As part of this I have been writing some custom web test plugins for creating data on the fly. Some pretty cool stuff can be done with these things.

Only issue is that I was getting some really annoying crashes. I couldn’t figure out what it was since it would crash VS with no errors. Turns out there is a bug in the webtest results viewer integrated into devenv.exe, this can crash when the very useful and seemingly innocent WebTest instance method AddCommentToResult() is used.

On the positive side it appears that this is fixed in VS 2010 SP1 – Link below
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=75568aa6-8107-475d-948a-ef22627e57a5&displaylang=en

More to come on Automated testing soon…..

cocos2d Transition Issues – ” undeclared (first use in this function)

Just a short post. I was trying to get a simple transition working using some code similar to below this:

[[Director sharedDirector] replaceScene:[RotoZoomTransition transitionWithDuration:1.0 scene:[PlayScene node]]];

Oddly enough I was getting an error:

'RotoZoomTransition' undeclared (first use in this function)

Although it was really quite obvious, I didn’t see the issue and on searching the net I didn’t find much. Eventually I clicked that I was just not reading the error very carefully. Looking at transitions.h I quickly realized the names of the classes were now different.

The transition classes were renamed:
Old <–> New
CCXXXTransition <–> CCTransitionXXX
Example
CCFadeTransition <–> CCTransitionFade

Just figured I would put it out there for anyone else who is missing the obvious 😉 For more information have a look here:
http://www.cocos2d-iphone.org/wiki/doku.php/release_notes:0_99_5

cocos2d – Basic Menu

I figure I will start off with something nice and simple. All apps need a menu and games are of course no different. With cocos2d is is fairly simple to create a menu.

I’m going to presume you already have cocos2d installed and the templates installed. You are going to need at least two images, a button-up state image and a button-down state image. You could also create “-hd” versions of these for the iPhone 4.

1. Start off by creating a new cocos2d application.

2. Add your button-up and button-down images to the resources by dragging them into it. Copy them to your project.

3, Find the HelloWorldScene.m file and the remove the code between the if statements

// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super" return value
	if( (self=[super init] )) {
		
		// create and initialize a Label
		CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker Felt" fontSize:64];

		// ask director the the window size
		CGSize size = [[CCDirector sharedDirector] winSize];
	
		// position the label on the center of the screen
		label.position =  ccp( size.width /2 , size.height/2 );
		
		// add the label as a child to this Layer
		[self addChild: label];
	}
	return self;
}

Becomes

// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super" return value
	if( (self=[super init] )) {
	}
	return self;
}

4. Add you menu items. These will be CCMenuItemImage items.

CCMenuItemImage *item1 = [CCMenuItemImage itemFromNormalImage:@"item1.png" selectedImage:@"item1Down.png" target:self selector:@selector(menuAction1:)];	
CMenuItemImage *item2 = [CCMenuItemImage itemFromNormalImage:@"item2.png" selectedImage:@"item2Down.png" target:self selector:@selector(menuAction2:)];	

The code is here is fairly self explanatory. Substituting your image names for me add this code between the if statement in the init method. “menuAction1” and “menuAction2” are methods that are called one touching the menu item

5. Create the menu
Add the after the code you added above.

CCMenu *menu = [CCMenu menuWithItems:item1, item2, nil];
[menu alignItemsVertically];

6. Add the menu to the scene

[self addChild: menu];

7. FInally you need to add the event methods to .h and .m files
.m

-(void) menuAction1: (id) sender
{
// do something
}
-(void) menuAction2: (id) sender
{
// do something
}
.h
-(void) menuAction1:(id) sender;
-(void) menuAction2:(id) sender;

And that’s about all there is to it.

I know this is a little breif, so feel free to ask if you have any questions. I will try make my future posts more detailed if time permits.

Selenium IDE – Automated testing of websites

Someone at work came across Selenium IDE. It is a nice little add-on for Firefox for testing websites. It allows you to script out tests and run them. Seems pretty powerful for a free tool. I’m not going to say a lot since the documentation on there site can do that for me. But if you need something for scripted website testing then this is worth a look.

Documentation found here: http://seleniumhq.org/docs/03_selenium_ide.html

The plug-in is based on Selenium Core which is a DHTML test execution framework. There are all sorts of nice things built from and around this framework, allowing everything from browser based testing too integration with unit tests.

Worth a look anyway.

http://seleniumhq.org/projects/core/