File x.inf contains DirIDs, which are not supported

I was compiling a cab for a Windows Mobile install when I came across an unexpected error.

Windows CE CAB Wizard    ?Error: Line  92 - unsupported DirID 0  Error: File c:\users\joeljo~1\appdata\local\temp\wizb912.inf contains DirIDs, which are not supported

It took a little while to figure out what this means. Searching on the web I found this can happen if you package more than 1000 files in a cab (or more than 262 in some cases). That wasn’t the cause of the problem that I was encountering though. It took a little while and I finally figured out what was causing it. One of the registry keys had a typographical error in it. I had typed “%InstallDir” instead of “%InstallDir%”. So if you ever encounter this problem remember to double check your registry key names.


From the Blog Engine Archives

Posts may contain products with affiliate links. When you make purchases using these links, we receive a small commission at no extra cost to you. Thank you for your support.

Mastodon: @j2inet@masto.ai
Instagram: @j2inet
Facebook: @j2inet
YouTube: @j2inet
Telegram: j2inet
Twitter: @j2inet

Handling Cookies with Redirects and HttpWebRequest

The HttpWebRequest handles redirects automatically. That’s usually a nice feature but it can actually get in the way when the web server is setting cookies in the same response in which it is sending a redirect. For some odd reason the HttpWebRequest object will totally discard cookies that are set with a redirect response. I ran into a problem with this when I was working in some code that interfaced to Google Voice and it was driving me crazy since I didn’t know where the problem was coming from.

Once I figured out what was happening the solution to the problem was simple. The first step is to disable the class’s automatic response to redirect request. When a response is returned from the class it’s necessary to check the response to see if it includes a redirect and if so create a new request. Since a redirect could occur more than once it is necessary to do this in a loop. With each new WebRequest that is created it is necessary to set the CookiesContainer member.

A simplified version of my code looks like the following:

using System.Net;

HttpWebRequest GetNewRequest(string targetUrl) { 
	HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(targetUrl); 
	request.CookieContainer = SessionCookieContainer; 
	request.AllowAutoRedirect = false; 
	return request; 
}
HttpWebRequest request = GetNewRequest(targetUrl); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 
while (response.StatusCode == HttpStatusCode.Found)
{
	response.Close(); 
	request = GetNewRequest(response.Headers["Location"]); 
	response = (HttpWebResponse)request.GetResponse();
}
//--At this point the redirected response is ready to be used  

Trying to perform this same thing on the .Net Compact Framework is a little more challenging since it doesn’t support cookies at all. I’ll discuss the solution I used in another post within the next few days.


From the Blog Engine Archives

Posts may contain products with affiliate links. When you make purchases using these links, we receive a small commission at no extra cost to you. Thank you for your support.

Mastodon: @j2inet@masto.ai
Instagram: @j2inet
Facebook: @j2inet
YouTube: @j2inet
Telegram: j2inet
Twitter: @j2inet

Making Designer Friendly Controls

I discovered this blog entry by way of SmartMobiDevice.com and thought that it was something I should share. If you’ve ever made your own controls for Windows Mobile you know that if the control is making any P/Invoke calls to native methods then it will not render in the designer. Simon Hart has a simple solution for this. The identity of the application domain is different on the desktop and in Windows Mobile devices and using that identity he conditionally makes the P/Invoke call which results in a design friendly control. To see his example source code read on.


From the BlogEngine Archives

Posts may contain products with affiliate links. When you make purchases using these links, we receive a small commission at no extra cost to you. Thank you for your support.

Mastodon: @j2inet@masto.ai
Instagram: @j2inet
Facebook: @j2inet
YouTube: @j2inet
Telegram: j2inet
Twitter: @j2inet

Popular Misconception: The override that was not

I was interviewing for jobs this past week and at all of the interviews I was presented with questions about object oriented techniques and C#. When asked abouit overriding a method on a class that wasn’t marked as virtual I informed the interviewers that it can’t be done. I didn’t realize that the interviewers were considering my answer to be wrong until yesterday when an interviewer presented to me the answer that he was looking for. He told me that I could override an otherwise unoverridable method by using the new keyword on it. That started a discussion which resulted in the interviewer wondering whether or not the method was really effectively overridden. After I had the discussion with him I realized the earlier interviewers may have also thought that my answer was incorrect.

The misconception comes from an observation of what happens when one uses the new keyword on a method. To make this discussion a little more concrete I’ll share some example code.

class MyBase
{
    public virtual string MethodA() 
    { 
        return "Hello from MethodA"; 
    }
    public string MethodB() 
    { 
        return "Hello from MethodB"; 
    }
}

What this class does is obvious.It has two methods both of which return a unique string. The class is simple enough that I’m sure you’ll trust me when I say it reliably does its job without error. One of the methods is marked as virtual, so it is overridable. The other is not. So now I derrive a class from this base class.

class Derived : MyBase 
{ 
	public override string MethodA() 
	{ 
		return "Hello from Derrived::MethodA"; 
	} 
	public new string MethodB() { 
		return "Hello from Derived::MethodB"; 	
	} 
}

In this derrived class I have overridden MethodA. Since MethodB is not marked as virtual I could not override it so I used the new keyword. Let’s test the program to see what type of output it produces.

using System;

static void Main(string[] args) 
{ 
	var a = new Derived(); 
	var b = new MyBase(); 
	Console.Out.WriteLine(b.MethodA()); 
	Console.Out.WriteLine(b.MethodB()); 
	Console.Out.WriteLine(a.MethodA()); 
	Console.Out.WriteLine(a.MethodB()); 
}

The output from running this is what one would expect. When I call MethodA and MethodB the the strings derrived in the derrived class are displayed.

Hello from MethodA  
Hello from MethodB
Hello from Derrived::MethodA
Hello from Derived::MethodB

Upon seeing this behaviour it seems that the developers I spoke to last week thought this to be the functional equivalent of overriding. But the difference shows up when the instance of the class is handled through either an interface or a base class reference. Let’s say I appended the following to the above code.

var c = a as MyBase;    
Console.Out.WriteLine(c.MethodA());  
Console.Out.WriteLine(c.MethodB());  

The output is not consistent with what we would expect an overridden method would produce.

Hello from Derrived::MethodA  
Hello from MethodB

The above output demonstrates that when a method has been overridden then the method will be called regardless of the interface used to interact with the object instance. MethodA had been overridden so even though a variable whose type is of the base class is used the overridden implementation is invoked. MethodB was never truly overriden so when a base class reference is used the base class implementation is called.

So then what did the new keyword really do? It allowed some one to create a method that has the same signature and name as an existing method. While the method is called with the same notation that would have been used to call the original method it is not actually performing an override. It is only hiding it. For confirmation one can also look at the C# documentation for the new keyword on MSDN which refers to this as name hidinghttp://msdn.microsoft.com/en-us/library/51y09td4(VS.71).aspx#vclrfnew_newmodifier

Name hiding through inheritance takes one of the following forms:

  • A constant, field, property, or type introduced in a class or struct hides all base class members with the same name.
  • A method introduced in a class or struct hides properties, fields, and types, with the same name, in the base class. It also hides all base class methods with the same signature. For more information, see 3.6 Signatures and overloading.
  • An indexer introduced in a class or struct hides all base class indexers with the same signature.

Digging deeper into the documentation we find the following:

The scope of an entity typically encompasses more program text than the declaration space of the entity. In particular, the scope of an entity may include declarations that introduce new declaration spaces containing entities of the same name. Such declarations cause the original entity to become hidden. Conversely, an entity is said to be visible when it is not hidden.The conclusion: The new keyword is not performing an override, it is a scoping operator.


From the BlogEngine Archive

Posts may contain products with affiliate links. When you make purchases using these links, we receive a small commission at no extra cost to you. Thank you for your support.

Mastodon: @j2inet@masto.ai
Instagram: @j2inet
Facebook: @j2inet
YouTube: @j2inet
Telegram: j2inet
Twitter: @j2inet

Landing Page Removed

I’ve had a landing page on my site for some time now that would allow you to get to either the old site content or the newer site content. I’m going to remove that page now and just post the link to the old site content here. Eventually the old site content will go away. Some of the more popular content with in it has already been replaced with redirects to repost of the same content within the newer site. You can get to the old site content here: http://j2i.net/blogs/blogs/home/default.aspx.


From the BlogEngine Archives

Posts may contain products with affiliate links. When you make purchases using these links, we receive a small commission at no extra cost to you. Thank you for your support.

Mastodon: @j2inet@masto.ai
Instagram: @j2inet
Facebook: @j2inet
YouTube: @j2inet
Telegram: j2inet
Twitter: @j2inet

Caxixi now available for the Omnia II

Samsung has a percussion application for their phones known as Caxixi (pronounced Ca-shee-shee) . The application makes use of the touch screen and the accelerometer to allow you to control up to 5 percussion instruments at once. If you’ve never seen it before take a look at this YouTube video.

Samsung has recently updated the application so it is now available for the Omnia II. You can download it from samsungcaxixi.com.


From the BlogEngine Archives

Posts may contain products with affiliate links. When you make purchases using these links, we receive a small commission at no extra cost to you. Thank you for your support.

Mastodon: @j2inet@masto.ai
Instagram: @j2inet
Facebook: @j2inet
YouTube: @j2inet
Telegram: j2inet
Twitter: @j2inet

WCF Guidance for Windows Mobile on Codeplex

I was looking for a Windows Mobile specific WCF reference since I knew that the Compact Framework doesn’t support all of the same WCF profiles that the desktop framework does. I was searching for a webcast that was done on the topic when I stumbled upon a document that had the information I was seeking on the CodePlex. You can see the document for yourself here. The document was created by Michele Bustamante aka That Indigo Girl.

The document contains a lot of good information and is written for the developer that has no experience with the compact framework or WCF. Only experience with the .Net framework is required. It will walk one through the steps of setting up their development environment for mobile development.

By the way, I did find a listing of the limitations for which I was looking.

FeatureSupport
StreamingNot Supported. Contract can use Stream parameters but they will not be buffered or streamed.
SessionsTransport sessions not supported. Service contract can use SessionMode.Allowed. Service should use InstanceContextMode.PerCall behaviour.
DuplexServices designed for duplex communications with callback contracts cannot be called by mobile clients. Duplex requires a transport session.
TransactionsService contract cannot require transaction for any service operations.
Data Contracts and Serializable TypesCan freely use. The mobile client will use XmlSerializer types that are wire compatible
Message ContractsCan freely use. If the message contract includes custom headers proxy generation will not work. Mobile client requires additional custom code to work with headers.
Fault ContractsCan include in the service contract. Proxy generation will not include fault contracts so additional custom code for mobile client is required to work with faults.

There are quite a few more limitations to know about for WCF in the Compact Framework. I won’t name all of them here since I think the document does an excellent job of detailing the limitations. At a length of only 72 pages including diagrams its a document that a developer should be able to easily get through.


From the BlogEngine Archives

Posts may contain products with affiliate links. When you make purchases using these links, we receive a small commission at no extra cost to you. Thank you for your support.

Mastodon: @j2inet@masto.ai
Instagram: @j2inet
Facebook: @j2inet
YouTube: @j2inet
Telegram: j2inet
Twitter: @j2inet