Perfil de PaulioIT BytesBlogListasScraps Ferramentas Ajuda

Blog


17 de novembro

How to connect to a SQL2008 machine

Ok I admit it, I’m a developer and configuring access to SQL Server is not my bag (baby). SQL 2005 had a nice big Surface Area Configuration button than just allowed access from clients, so I ignored what it was doing, pressed it and got on with my work. However, SQL 2008 seems to be have been targeted at me because it no longer has such a backdoor and forced me to find out what I should do. So I thought I’d write it down for others who prefer to search the web rather then read the documentation <oops>,

First off you need to open the SQL Configuration Manager and check your favourite protocol is enabled, for me that would be TCP/IP. Double click that and select the IP Addresses tab. You’ll notice in there a list of possible IP addresses and ports for SQL to listen on. You can, if you maintain your (mine) lazy tendencies simply change the setting from dynamic to static and plug in port 1433. When clients attempt to connect to your server they attempt to use 1433. Now this isn’t supposed to be a good idea (no idea why – you’ll see why later) so stick with dynamic ports. Now this means that SQL will listening on some port but you’ve no idea what as it may change each time the server starts. So you must start the SQL Browser Service, this acts as the go-between and “tells” the client what port to use. So there you are, you should now be off and running. But why not use 1433? I thought the idea was slow those pesky hackers down, but if you have to open the Browser Service then what does that achieve? Something I need to look into, when I have the time, when I have the time, when I have the time…..

04 de novembro

Quick guide to starting a WinMobile widget application

It’s still early days for the W3C Widget, but the idea of been able to write a little application that I can run on numerous devices and platforms without requiring any changes is interesting (well I spose you could call that Adobe Air, maybe even my beloved Silverlight at a stretch – but even they requires an additional plug-in). So knowing that in reality they’d be difference I set of downloading various SDKs. However, I hit a number of installations problems all of which I’m sure are down to dodgy installers, beta software and 64bit Windows – not a clever combination I admit. So I grabbed trusty WinMobile and started on that first. The first issues was getting Visual Studio to sync up with the emulators. No chance, there is no project for widgets you have do everything by hand. So here is my very quick guide to get you working;

  1. Install Win Mobile 6 SDK refresh
  2. Install Win Mobile 6.5 Dev Toolkit – you’ll now have the emulators available to the device manager
  3. Create a blank web site
  4. Add content – see
  5. http://windowsteamblog.com/blogs/windowsphone/pages/getting_2D00_started_2D00_with_2D00_widgets.aspx

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

  6. To test I used a great little util http://widgetemulator.codeplex.com/
  7. Then to try it out for “real” create a shared folder in the emulator pointing to your .wgt file, and browse to it from the PDA folder browser

 

     

23 de outubro

ActiveX cannot create object on old site hosted on Win7 64bit

My colleague and I ran into a problem today where an old ASP site had problems creating old VB6 components. So as not to forget what to do;

In Win64 the registry is conceptually broken into two versions, one for 64 and one for 32 (or Wow). So when you register a 32bit COM component then it lives under HK_CLASSES_ROOT\Wow6432Node rather than just HK_CLASSES_ROOT. This is important because when we were profiled the registry access would could see that the call to create the object was failing because it couldn’t locate the prog id in CLASSES_ROOT. The reason it was looking there was the web site was running as a 64bit process and therefore was looking in the Wow section. The answer to the problem was hidden away in the Advanced Settings of site’s Application Pool in IIS. By turning on ‘Enable 32bit applications’ the OS was able to redirect the registry requests to the correct location and the object was successfully created.

Fake AntiVirus attack

I thought I’d show what happens when you’re attacked by a fake anti-virus scam…

It starts off by popping up a message (note it says from webpage and not the OS)

image

Then it looks like Windows Explorer but it’s really still just the browser. Also this is running Win7 and not XP as the fake page tries to look like

FakeExplorer0

Looks realistic though doesn’t? You can see why people have fallen for it. And now for the money…

image

Yeah I think I’ll say no to that don’t you, thanks for asking.

 

So be careful out there.

21 de outubro

How to enable Network DTC Access on Windows 7

This confused me for a bit, they’ve moved the Network DTC Access dialog from the MSDTC tab to it’s own node…

image

Select properties on the above node…

image

11 de outubro

Silverlight control lifecycle

Just happended across this post and thought it would be good to keep it referenced;
 
30 de setembro

Trip to the Fields of Flanders

Not my usual IT related comments but I felt compelled to post. I've just got back from a trip to Bruge which included an excursion to various locations and cemerateries related to World War 1 (http://www.visitbruges.org/). It may seem like a depressing subject but I think everyone should make such a trip. It really is worth getting some sort of understanding of the huge loses and suffering of the people involved. Our trip was a small group which consisted of couples from Australia, Britain and Canada. Consequently we visited cemetaries and memorials for those nationalities and were taken to locations where those troops were involved. I'm not going to attempt to describe all the things we saw (or spoil it - see it yourself) but just to say that I haven't stopped thinking about it since. Without lapsing into communism it has certainly made me think more about;  how violence isn't a great way to resolve a problem, and when I think things are bad (like the fact our water main has collapsed and we've got dodgy water) people managed to live (if they were lucky) through years of unimaginable horror - so perhaps I should just smile and be more thankful.

I must admit that after the visit I have become a bit of WWI bore and have read 'World War 1' by David Shermer which amazed me about just how many counties were fighting all over the globe. It's also very interesting to see how it affected 'modern' politics. I thought I'd add a litte wikipedia style facts from the book;
Toll of lives (my approximations):
Civilian (not including a huge flu outbreak)  9-12 million
Military:
Germany  1.7-2 million
Russia 1.7 million
France 1.36 million
Austria-Hungary 1.2 million
Great Britain 0.76 million
British Empire 0.25 million
Italy 0.65 million
Turkey 0.37 million
United States 0.12 million

Total Casulaties 37,500,000 - imagine the potential of all those people
Economic cost £75,077,000,000 - and that's nearly a century ago
E.g of physical damage - France; forests lost 1,875 sq.miles, 8000 sq.miles farm land, 0.25 million buildings
Quote from the book, 'These are cold statistics...the disillusionment...ordinary poeple realised...the horrendous price for reordering the world's affairs'.
Mine and the books parting quote;
'I have given orders to my Death Units to exterminate without mercy or pity men, women and children belonging to the Polish-speaking race. It is only in this manner that we can aquire the vital territory which we need. After all, who remembers today the extermination of the Armenians?' Adolf Hitler, 22 Aug 1939



10 de setembro

How to stop the CLR optimizing your variables during a debug session

Finally decided to see if there was something I could do to stop the CLR optimizing away all the variables when I want to remote debug an application. This seems to have the answer, http://blogs.msdn.com/tom/archive/2008/05/09/getting-more-information-from-clrstack.aspx
Essentially, create an myfile.ini for your dll/exe and put the following in it;
[.NET Framework Debugging Control]
GenerateTrackingInfo=1
AllowOptimize=0
 
 
28 de agosto

iE6 + default Silverlight + https = unsecure prompt

IE6 (ah bless) is oddly paranoid when rendering https sites. This can be seen when it attempts to use a page that contains a Silverlight application. The problem stems from the default template Visual Studio generates for hosting the application. It contains a invisible iFrame element, apparently to support Safari. However, if you attempt follow the links to explain why Safari needs such a hack you hit a dead-end. Assuming that was because Safari 4 has since been released I tested the previous problem, that you can't correctly browser-back to a page with SL content. It seems to work fine. However, Ken Tucker pointed out that Silverlight Navigation now requires the use of this iFrame. So the simplest solutions is to add a src="#' attribute to the iFrame - this doesn't seem to cause any problems to "modern" browsers and IE6 now understands that the src is secure.

27 de agosto

Upgrading from 5.3.1 to 5.3.4

For some strange reason when my existing projects referenced Type Mock and Type Mock Isolator it would mark Type Mock as copy local true and Isolator as false. However, after upgrading to 5.3.4 when I add a reference the opposite occurs. This causes a problem when upgrading a project and the project continues to use Type Mock as the local copy (5.3.1) and Isolator and the new version (5.3.4). This leads to some strange behaviour. So double check your references after upgrading.
 
22 de agosto

Using Blend to set the colour of the text in a button

Silverlight & Blend try and encourage you to separate styles and structure in much the same way as you should with HTML and CSS. However, Blend can be confusing as it will offer up some properties to be changed but “hide” others. One example of this is the seemingly simple task of changing the colour of the text in a button. You’d be forgiven for thinking you can select the button and directly edit the foreground colour since the background is available. You must ignore this temptation, if you don’t attempt to make style changes directly to the structure (control) then you’ll avoid a lot of confusion. I’ve created a little tutorial to show one way of solving this;

  1. Create a new project in Blend and accept the defaults.
    image
  2. Add a button
    image
  3. Select the button, hint using the control tree is often more reliable, right-click and choose Edit Templatate->Edit a Copy. To promote separation I recommend saving the style to the Application. You should give the style a good name, but I’ll be naughty and leave it at ButtonStyle1
    image
  4. You’ll now find yourself in the Template for the button. Ignore this and return the MainPage.xaml (there is a quicker way but lets keep things simple). Now you want to change the colour of the button, so you need to edit the buttons style. Select the Resources tab and click the button to edit ButtonStyle1
    image
  5. Now switch back to the Properties tab and you can change the Foreground (remember to drag the little colour select from the bottom left of the selector).
    image
  6. All done.

So the “take home” from this is don’t make style changes directly to your controls always look at changing the separate style xaml, not only will you have better separation but you’ll avoid a lot of frustration when trying to find the property you want to change.


17 de agosto

Update Service Reference not working?

The integration provided by Visual Studio between Silverlight and and WCF Service is good but can be frustrating. Here are a couple of simple things to try when things don't appear to be working;
1. I've created/changed my service but when I update the reference or attempt to discover the new sevice it can't be found - make sure the service has built by rebuilding the service
2. I've changed the service and ran 'update the service reference' but my Silverlight code cannot see the changes, in fact it seems to have lost all references to the proxy code - rebuild (not compile) the Silverlight project.
 

15 de agosto

Windows 7 64bit, sharing Canon printer with 32bit clients

My trusty Canon MP800 printer was shared to my home network via it's Vista 32-bit host, however I've now installed Windows 7 64-bit. The problem is that although you can share the printer easily enough you have to allow the "server" to have the 32bit drivers available to the clients. The problem is that when you tick the 32bit architecture and try and search for the drivers it won't detect them, I'm guessing the downloaded 32bit driver package hides the actual drivers until you do a normal install. You can't do a normal 32bit on a 64bit OS. Luckily I discovered this post that I've duplicated (in case it gets losts);
 
 
To share printers across a network between Vista x64 and any other operating
> system do the following.
>
> Vista
> ------
> Click Start >>
Control Panel >> Hardware and Sound >> Printers
> Click on Add a printer
> Select Add a local printer
> Create a new port >> Local Port >> Click on Next
> Enter the port name for the network printer (i.e. \\
Computer Name\Printer
> Name)
> Select the printer from the list
> Continue until the printer is installed.
>
> Other operating systems
> ----------------------------
> Find the Add printer wizard and do exactly the same method as for Vista.
>
> With any luck your printer will already have printer
drivers included with
> Vista and obtaining drivers for other operating systems if they are missing
> should not be a problem.
>

13 de agosto

Windows 7, where has my DVD Drive gone?

Just had a problem burning a file to disc, when I rebooted and checked "my computer" the drive had vanished. After checking the Device Manager el al I couldn't find any problems. Then I realised what was happening, it now only shows the drive if there is something in it to read! Gotcha!
 
12 de agosto

Digitally code signing Office VBA macro

Had some fun today with code signing some macro's in Excel. Applying a code signing certificate is very easy, simply go to the visual basic editor, tools->Signing and you're away. The problem is creating the correct type of certificate in the first place.

My sys admins provided with a p7b certificate. So I installed that, but it didn't show in VBs available certificates. So I thought I'd better try and understand what was going on. In turns out that I need a pfx certificate and a p7b is just part of formula for creating such a beast. You need the private key used to create the original certificate together with the p7b;

pvk2pfx -pvk privateKey.pvk -spc codeSignCert.p7b -pfx actualCodeSign.pfx -po myPassword -f

That will challenge you for the password used to create the original certificate but will produce required pfx file. Now just install that and it should be available for signing

09 de agosto

Windows 7 on Parallels

Vista on Parallels 3 was good, Vista on Parallels 4 was terrible. So I wasn't too bothered in ditching my Vista VM and installing Windows 7, even though it's only marked as 'experimental'. Well so far it's been as good as P3, so I'm very happy with it. Don't know where the blame falls for P4+Vista but P4+Win7 is worth having.

How to install BT Netprotect on Windows 7

After installing Windows 7 I realised I needed to install my antivirus software so off to BT to download Netprotect. However, the download page incorrectly assumes that if the OS isn't XP or Vista then it must be a really old version of Windows - Bzzzt. I first tried to persuade IE to launch in compatibility mode but to no avail. So I donwloaded Firefox, went to the properties, switched compatbiblity mode to run as Vista and downloaded NetProtect - fooled it.
 
 
02 de agosto

Sharing ASP Session state with Silverlight

I’ve been working on a Silverlight project that where the SL application is used within an authenticated ASP.net site. During my testing I found a problem where using Silverlight 3’s Out-Of-Browser feature seem to lose the session token between calls to the site, i.e. I could logon but the next call would fail as if the user had not logged on. After a couple of Twitter conversations it became apparent that it should work. So I decided to take my testing back to basics, so first off can a Silverlight application use ASP session state?

  1. Create a basic Silverlight application – create a Silverlight application with a web project to host it
  2. Create a basic web service – with the web project selected add a new Silverlight WCF service, called SessionTest.svc
    image
  3. Implement some very simple interactions with the Session State

    [ServiceContract(Namespace = "")]

        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

        public class SessionTest

        {

            [OperationContract]

            public void SetState(string value)

            {

                // Add your operation implementation here

                HttpContext.Current.Session["TestState"] = value;

                return;

            }

     

            [OperationContract]

            public string GetState()

            {

                // Add your operation implementation here

                return (string)HttpContext.Current.Session["TestState"];

            }

        }

  4. Add a Service Reference from your Silverlight application to your service, add appropriate using statements to your code-behind.

  5. Create some simple controls in your Silverlight application

    <StackPanel>

        <StackPanel Orientation="Horizontal">

            <Button x:Name="ButtonGetState"  Content="Get State" Click="ButtonGetState_Click" Width="60" ></Button>

            <TextBlock x:Name="TextBlockCurrentState" Width="100"></TextBlock>               

        </StackPanel>

        <StackPanel Orientation="Horizontal">

            <TextBox x:Name="TextBoxNewState" Text="" Width="100"></TextBox>

            <Button x:Name="ButtonSetState" Content="Set State" Click="ButtonSetState_Click" Width="60"></Button>

        </StackPanel>

    </StackPanel>

  6. Add code to the Silverlight application to communicate with the Service

    private void ButtonGetState_Click(object sender, RoutedEventArgs e)

            {

                SessionTestClient client = new SessionTestClient();

                client.GetStateCompleted += (object completedSender, GetStateCompletedEventArgs completedE) =>

                    {

                        if (completedE.Error == null)

                        {

                            TextBlockCurrentState.Text = completedE.Result;

                        }

                    };

                client.GetStateAsync();

            }

     

            private void ButtonSetState_Click(object sender, RoutedEventArgs e)

            {

                SessionTestClient client = new SessionTestClient();

                client.SetStateCompleted += (object completedSender, AsyncCompletedEventArgs completedE) =>

                    {

                        if (completedE.Error == null)

                        {

                            TextBlockCurrentState.Text = "";

                        }

                    };

                client.SetStateAsync(TextBoxNewState.Text);

            }

  7. Run the code, you should see that after you set a value you can retrieve the same value.

So we now know for sure that we can communicate with ASP.net and share the session state with the page. If you make the Silverlight application OOB (select project properties and check the OOB box) you’ll see that it continues to work without any problems. So this is good news, all I have to do now is track down why it isn’t working in my real application.

27 de julho

Remote debugging - value as being optimized

Surley one of the most annoying problems with remote debugging is after finally getting a connection, the correct pdb's, the correct source and a breakpoint hit you examing the values to be faced with a big red cross saying the value has probably being optimized and you cannot view it. I'm not absolutley sure of the reason but I guessed that CLR had optimised it because the code had run before the debugger was attached. So my tip is to try and attach the debugger before the code is run. Obviously not the easiest thing to do every time but if you can do this then the CLR will not optimize the values aways. Hopefully someone out there will provide a better answer.
 
 
24 de julho

Listing the files in a Changeset

I've been trying to do this off an on for a while and finally tracked it down...
 
To list the files in a changeset;

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE>tf changeset /i 27880

 

To show the dialog in a separate process so you can carry on using Visual Studio just omit the /i