Welcome to WindowsClient.net | Sign in | Join

Zuker On Foundations

The realm of .NET (WPF, WCF and all around)

August 2008 - Posts

Execute code within timeout using threads

Via this post

Following is a quick way to execute code and limiting it within a certain timeout.

Note that the code spawns a new thread.
A better safer code would be using the ThreadPool and wait on the WaitHandle.

Thread t = new Thread(
   () =>
   {
      //Do Stuff Here
   });

   t.Start();
 
   bool success = t.Join(TimeSpan.FromSeconds(10));
   if (success)
   {
      //Thread completed successfully
   }
   else
   {
      throw new TimeoutException();
   }

Posted: Aug 21 2008, 09:20 AM by Amir Zuker | with no comments
Filed under:
PNG Transparency for IE6

Internet Explorer 6 has problems displaying a PNG image with alpha transparency.

Follow the instructions detailed in this post to solve the issue.

Note that you should apply width & height for every image you apply the style to. (At least from my experience)

Posted: Aug 11 2008, 11:09 AM by Amir Zuker | with no comments
Filed under:
Hosting WCF Service in IIS w/ Windows Authentication

I can't believe I wasted 10minutes on something that should be the simplest ever.

You might encounter an exception when trying to host a WCF service in IIS with windows authentication where it would say the IIS isn't configured with windows auth so the service itself can't be configured with windows auth.

I had that exception.

The problem is that the IIS vdir was configured with windows auth! and it still blew up.

After a quick searching, I found this post which did the trick.

So.. if you do encounter this, I hope I saved you some time.

Posted: Aug 10 2008, 02:00 PM by Amir Zuker | with no comments
Filed under:
LINQ to SQL Dynamic Mapping

Via this post.

The post discusses the issue of using LINQ-to-SQL with dynamic mappings.

The problem
You have SQL Servers for each of your environments (development, test, pre-prod, production) and in each one, the table names are different.  In fact, it’s not the table names that are different but the schema names but since the schema name is part of the table name, it must be specified.
Ex : dev.ZeTable et prod.ZeTable

Easy to solve, right?  Just put the schema value in the config file and do a simple concatenation at runtime.  Well, it’s not as easy as it seams because the table name is stored in an attribute of the partial class generated by the LINQ to SQL designer and Microsoft didn’t provide a way or method to change it at runtime.

[Table(Name="dev.ZeTable")]
public partial class TheTable

Solution
The solution is to dynamically load at runtime a mapping specific for each environment.
Here’s how to do it:. (Go to the post..)

Posted: Aug 10 2008, 11:18 AM by Amir Zuker | with no comments
Filed under:
Hosting WCF Service in IIS - 404 / Get Plain Text

If you're trying to host a WCF service with a .svc extension and you get a 404 response or get plain text, it means your IIS had not been configured with the .svc extension.

Follow this post instructions.

Posted: Aug 06 2008, 10:42 AM by Amir Zuker | with 1 comment(s)
Filed under:
IntelliSense for Expression Blend

Via Stefan's post.

Wonderful News! You can enable intellisense in blend

You need to install a plug-in and there's a few gotcha's so do read Stefan's post for all the details.

A great discovery :)

 

Posted: Aug 05 2008, 08:48 AM by Amir Zuker | with no comments
Filed under: ,
Page view counter