Wednesday, August 08, 2012

Migrate Reporting Services to another machine–Reporting Services Scripter

Came across this nifty little tool called “Reporting Services Scripter” which can be used to migrate RDLs to a different machine. In addition, it can also move other settings like schedules, etc. Another cool feature is that you can use it to migrate RDLs from a 2005 machine to a 2008 machine.

Download it from: http://www.sqldbatips.com/showarticle.asp?ID=62

Saturday, August 04, 2012

Using Bing Maps in a Metro App

Step 1: Download the Bing Maps SDK.

This is easier now as its been made into a Visual Studio Extension.

image

Step 2: Create a blank Metro App

Step 3: Reference the SDK dlls:

You need to reference Bing Maps as well as the Visual C++ runtime (don’t worry, this is only a dependency and you will not have to write an C++ code)

image

Step 4: Get your access key

To get your access key you need to sign up for a developer account at the Bing Maps developer portal (https://www.bingmapsportal.com/). Once you have created your account, you need to create a key for your metro app. Remember to set up your app as a Metro app when creating your key.

Step 5: Drop your key into your app.

A good practice is to make your key an application resource. This will make it easy to use it on any page that uses the Maps control.

To do this, open your App.xaml page and add the following line right after the “</ResourceDictionary.MergedDictionaries>” line:

<x:String x:Key="BingMapsApiKey">Insert Your Api Key</x:String>

image

Step 6: Reference the Bing.Maps namespace in the page where you intend to use the map control. To do this add the following line to the page declaration:

xmlns:bing="using:Bing.Maps"

image

Step 7: Add the map control. To do this, just add the following line in your page (I added it to the default grid that gets created when you create a blank page).

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <bing:Map x:Name="MyFirstBingMap" Credentials="{StaticResource BingMapsApiKey}" />
</Grid>

Step 8: Run your app and admire your creation Smile

image

Doing more:

Step 9: Centering the map to your location:

First, you need to enable your app to use location data. To do that, double click the “Package.appmanifest” file and on the capabilities tab, select “location”.

image

In the designer for you page, add a MapLayer to your page:

<bing:Map x:Name="MyFirstBingMap" Credentials="{StaticResource BingMapsApiKey}">
            <bing:MapLayer x:Name="MyMapLayer">
            </bing:MapLayer>
</bing:Map>

Add the following code to the “OnNavigatedTo” event in the page containing your map:

async protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Geolocator geo = new Geolocator();
            geo.DesiredAccuracy = PositionAccuracy.Default;
            var currentPosition = await geo.GetGeopositionAsync();

            Location loc = new Location()
            {
                Latitude = currentPosition.Coordinate.Latitude,
                Longitude = currentPosition.Coordinate.Longitude
            };

            MyFirstBingMap.SetView(loc, 13, 0);

            Canvas pushPin = new Canvas();
            pushPin.Children.Add(new Ellipse() { Fill = new SolidColorBrush(Windows.UI.Colors.Red), Width = 22, Height = 22, Stroke = new SolidColorBrush(Windows.UI.Colors.Black), StrokeThickness = 2 });

            MapLayer.SetPosition(pushPin, loc);
            MyMapLayer.Children.Add(pushPin);

        }

Running the application will result in the following map:

image

Things to notice:

1. The method is labeled as “async” this is because we are using the “await” keyword on the GetGeopositionAsync method of the GeoLocator.

2. Instead of using “Pushpin” control, I am using a canvas and drawing a circle. The reason is the Pushpin control does not seem to allow changing of colors or size. (Don’t know if this is a bug in the release preview or by design). Which is why I am using a custom control as my pushpin.

Thursday, August 02, 2012

The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.Resolve(System.Type, string, params Microsoft.Practices.Unity.ResolverOverride[])' cannot be used with type arguments

If you get the “The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.Resolve(System.Type, string, params Microsoft.Practices.Unity.ResolverOverride[])' cannot be used with type arguments” compiler error while building a Prism application, remember to add a using statement for “Unity” (using Microsoft.Practices.Unity;)

CRM–Setting the default page for all users

Unfortunately there is no supported way to do this. The only way I have found to do this is by updating the “homepagearea” and “homepagesubarea” values in the usersettingbase table in the organization database of CRM.

update UserSettingsBase
    set Homepagearea='default pane’
    ,Homepagesubarea='default tab'

After running the above script, you need to reset IIS, otherwise for users already logged into the system, will now see the change.

And below are the values for some of the panes and tabs that you can use for the script above.

Pane (Homepagearea) Value
Tab (Homepagesubarea) Value

Workplace

Workplace

 
 

Activities

nav_activities

 

Dashboards

nav_dashboards

 

Queues

nav_queues

 

Calendar

nav_calendar

 

Reports

nav_reports

 

Imports

nav_import

 

Duplicate Detection

nav_duplicatedetectionjobs

Sales       

SFA

 
 

Accounts

nav_accts

 

Contacts

nav_conts

 

Opportunities

nav_oppts

 

Leads

nav_leads

 

Goals

nav_goals

 

Goal Metrics

nav_metric

 

Rollup Queries

nav_goalrollupqueries

Saturday, July 28, 2012

Software coding jargon

An interesting list of new coding jargon: http://umumble.com/blogs/Programming/321/ (or check out this page for the original content: http://www.stackprinter.com/questions/new-programming-jargon-you-coined.html)

(The page is originally from StackOverflow, but that question was deleted and hence the link to stack-printer).

One of my favorites:
"Yoda Conditions"— using if(constant == variable) instead of if(variable == constant), like if(4 == foo). Because it's like saying "if blue is the sky" or "if tall is the man".

A history of software failures....

Came across this interesting graphic from an old IEEE article: http://spectrum.ieee.org/computing/software/why-software-fails


And while you are still interested in the topic, read the following:
Some stories on failures of software: http://vu.bits-pilani.ac.in/ooad/Lesson2/topic3.htm
History's worst software bugs: http://www.wired.com/software/coolapps/news/2005/11/69355?currentPage=all
And if you are looking for some latest stories, then the "Risks Digest" is a great place to get them: http://catless.ncl.ac.uk/Risks/

Thursday, July 26, 2012

Using WCF with windows authentication with an intranet ASP.Net website

Scenario:
You want to use windows authentication to protect a WCF service and the client is an ASP.Net intranet website (and has Windows Authentication turned on).

Steps:
Create your WCF webservice website (I am assuming that the web-service website is different from the intranet website).

Enable Windows Authentication for the site.

image

For the purposes of testing create a service method that returns the user info:

public string GetUserInfo()         
{
             string userinfo = string.Empty;
             var windowsIdentity = ServiceSecurityContext.Current.WindowsIdentity;
             if (windowsIdentity != null)
                 userinfo = windowsIdentity.Name;
             return userinfo;        
}

Setup the web.config for the service so that the end point uses basicHttpBinding with a configuration where the security mode is set to “TransportCredentialOnly” and the Transport’s clientCredentialType is set to windows. Here is what it will look like:

<system.serviceModel>
     <services>
       <service name="WcfService1.Service1">
         <endpoint address="Service1.svc" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfiguration" contract="WcfService1.IService1" />
       </service>
     </services>
     <bindings>
       <basicHttpBinding>
         <binding name="basicHttpBindingConfiguration">
           <security mode="TransportCredentialOnly">
             <transport clientCredentialType="Windows" />
           </security>
         </binding>
       </basicHttpBinding>
     </bindings>
     <behaviors>
       <serviceBehaviors>
         <behavior>
           <serviceMetadata httpGetEnabled="true"/>
           <serviceDebug includeExceptionDetailInFaults="true"/>
         </behavior>
       </serviceBehaviors>
     </behaviors>
     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />   </system.serviceModel>

Create your ASP.Net website (which will act as a client to your web-service). Set its authentication mode to “Windows” and make sure that you set "identity impersonate” to true.

image

Now add a reference to your web-service.

In your web.config make sure that the security mode is set to “TransportCredentialOnly” and the Transport’s clientCredentialType is set to windows. Here is an example:

<system.serviceModel>
     <bindings>
       <basicHttpBinding>
         <binding name="BasicHttpBinding_IService1">
           <security mode="TransportCredentialOnly">
             <transport clientCredentialType="Windows"/>
           </security>
         </binding>
       </basicHttpBinding>
     </bindings>
     <client>
       <endpoint address="http://xxxxxx/Service1.svc/Service1.svc"         binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"         contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
     </client>
   </system.serviceModel>

That should be it. When you call “GetUserInfo”, you should get the name of the user that is accessing the asp.Net website.

Saturday, July 21, 2012

CRM 2011–error when upgrading a CRM 4 database

I recently got an error that stated “could not load file or assembly 'Microsoft.Crm.Sdk, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.” while I was importing a CRM 4 database into a CRM 2011 instance.

The way I managed to get around it was to add the following section right at the end of the CRMWeb’s web.config file (right before the ending configuration tag)

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Crm.Sdk" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="4.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding> 
</runtime>

Location of VPN settings in Windows 7 and Windows 8

I needed to copy the VPN settings from my Windows 7 machine to my test Windows 8 machine and wanted to figure out where the settings are stored. Here is the location:

%appdata%\Microsoft\Network\Connections\Pbk

In that folder you will find a file called “rasphone.pbk”. You can copy that file out and double clicking it, will open the “Network Connections” dialog and you will find all your VPN connections in that dialog!

Setting up Foscam FI8190W for remote access

Here is how you can setup your Foscam FI8190W for remote access (and this will work for almost all web-cams).

I am using a router which has the DD-WRT firmware installed on it. If you don’t have DD-WRT, your router setup will look different, but you should find pages on how to perform it for your specific router.

Step 1: Connect to your web-cam and perform setup

Install the software that came in the Foscam box. Run the “IP Camera tool” to figure out the IP address for the camera.

Connect to the IP camera using the IP address provided by the “IP Camera tool”. (The address will typically be of the form :198.168.1.xxx, where xxx is a 3 digit number that will be unique for you. This address is the internal IP address for your web-cam (as opposed to WAN IP address which we will learn about later)).

You will see the login screen:

image

The first time you connect to your web-cam, the user name is “admin” and password is blank (no password).

After logging into the web-cam, we need to do some house keeping steps:

1. Change the password. When changing the password, what you need to know is that the password is case-sensitive and can be only 12 characters long.
image

2. Change the port used by the web-cam:

The main reason we are changing the port is because the default port of 80 is blocked by many ISPs and so by changing it to a different value like 82, you get around that issue.

image

Note: once you change the port you will connect to the web-cam using the port number using the following format (http://192.168.1.xxx:pp, where xxx is a number unique to your web-cam setup and pp is the number you entered for the Http Port)

2. Setup your router

Login to your router. As I am using DD-WRT, the url for me is: http://192.168.1.1/

Setup port forwarding:

image

Click on “NAT/QoS”

Click on Port-Forwarding

Set the application name.

Set the “port from” to the same port number that you set in Step 1 above. Set the “IP address” to the IP address of your web-camera. Finally set the “Port to” value to the same port number that you used in “Port From”.

Click on “Save” and “Apply Changes”.

Now in the screen shot above, lookup the “WAN IP:” value (top left corner, red rectangle).

This is the IP address that you need to use to connect to your web-cam from outside your home’s network.

3. Make sure that all your settings are correct to enable remote connectivity:

From your home network, open a web-browser and browse to: http://canyouseeme.org/

The web-page should automatically detect your external IP address. This should correspond to your “WAN IP” address that you found in step 2.

Set the port value to the same value you chose in step 1.

image

Click on “Check your port”

If you see the following message, then your setup was unsuccessful and as a first step, I would go through all the above steps a 2nd time to make sure you didn’t miss anything:

image

But instead, if you see this message, then everything is good and you can go on to the next step:

image

4. Connect up to your web-cam

You should be able to connect to your web-cam using the external IP address (WAN IP) and the port number like so: http://201.192.1.345:92/ (where 201.192.1.345 is an example for what my WAN IP address and 92 is the port number I selected for step 1).

5. Setup Dynamic DNS (DDNS)

If you don’t have a static IP address (what that means is that your WAN IP address gets reset to a different address every few days), then keeping track of your external (WAN) IP address can become a real pain. Enter DDNS.

I used the free no-ip.org website to setup my account.

After you create your free account, click on Hosts/Redirects:

image

Click on “Add a host” and setup your host like so:

image

(The IP Address should be set to your WAN IP address).

Click on “Create Host”

Wait for about 5 minutes for the new host name setup to be completed by no-ip.com.

Open a browser and navigate to http://justAnExample.no-ip.org:92/ (where justAnExample and no-ip were values I selected above and 92 is the port number I chose in step 1).

You should be connected to your web-cam now.

Setup router to update your DDNS record automatically.

Again, I am using DD-WRT as my router, but your router (if different) should support a similar setup).

image

Click on “Setup” –> “DDNS”

Select “NO-IP.Com” as your service.

Enter the user name and password that you selected when you created your no-ip.org account.

Finally enter the host name you selected above (in my example that was: justAnExample.no-ip.org)

Click on Save and Apply Settings.

That’s it you are done!

And here is a screen shot of my web-cam as seen on my iPad:

photo

Note:

If you get an ActiveX error in Internet Explorer, check out these steps on FOSCAMs site for fixing it: http://foscam.us/blog/foscamipcameras/setting-up-ie-on-windows-7-to-view-the-foscam-fi8908w-wireless-camera-enabling-the-activex-control-module/