in

Community Blogs

Blogs of different SQL/Developers Community Members

This Blog

Syndication

DamirDobric

siječanj 2010 - Posts

  • Error while MergingDictionaries in Silverlight

    In my SIlverlight application I used following code to perform the merge of Resources which are stored in some dedicated assembly designed for this purpose. For this reason I used following code:

    ResourceDictionary dict = new ResourceDictionary();

    string src = “/MySilverlightControls;component/themes/MyDictionary.xaml”

    dict.Source = new Uri(src, UriKind.RelativeOrAbsolute);

    Application.Current.Resources.MergedDictionaries.Add(dict);


    This code usually works perfect. However sometimes it fails with following exception:

    Error HRESULT E_FAIL has been returned from a call to a COM component.

    This nothing saying exception does not help and do not try do decrypt the hidden information. I figured out that following code does a bit better job.

    string src = “/MySilverlightControls;component/themes/MyDictionary.xaml”.

    StreamResourceInfo resourceInfo =
    Application.GetResourceStream(new Uri(src, UriKind.RelativeOrAbsolute));

    StreamReader resourceReader = new StreamReader(resourceInfo.Stream);

    string xaml = resourceReader.ReadToEnd();

    ResourceDictionary resourceTheme = XamlReader.Load(xaml) as ResourceDictionary;

    Application.Current.Resources.MergedDictionaries.Add(resourceTheme);

    When using this code you will get the real error description. In my case this was indication that I had some error in XAML, which designer didn’t discover:

    Invalid attribute value Daenet_Silverlight_Controls:WindowControl for property TargetType. [Line: 377 Position: 54]

    To solve this specifi problem I added missing declaration:

    xmlns:Daenet_Silverlight_Controls="clr-namespace:Daenet.Silverlight.Controls;assembly=Daenet.Silverlight"

    Posted sij 26 2010, 02:25 by anonymous
    Filed under:
  • DataServices 0x80070006 error

    When working with Ado.Net data services you may get following error.

    Could not load file or assembly 'System.Data.Services.Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))

    This error can indicate anything related to JIT-er. In my case there is directly nothing to do with JIT-er.
    I have a service which talks to database by using of ADO.NET services (like described in this post).

    However my DataService overrides the method OnStartProcessingRequest. Within this method I invoke sometimes another service to check the caller’s permissions. If this fails the error shown above will appear.

    In fact, this error is shown (at least) if the method like OnStartProcessingRequest fails during execution.

    protected override void OnStartProcessingRequest(ProcessRequestArgs args)
    {

      throw Exception(“Any error here causes the error described aabove”)

    }

    Posted sij 26 2010, 01:59 by anonymous
    Filed under: ,
  • Difficulties Virtual PC on Windows 7

    In my daily working I use used a number of virtual images, with different configurations. After I installed Virtual PC for Windows 7 x64 I figured out that no one of my images can be used.

    Problem I

    When you start the image created on Release Candidate of Windows 7 following error appear:
    “Could not register the virtual machine.
    The virtual machine configuration could not be added. User does not have sufficient access rights.

    I was like “uupss”?! Really no time for such stupid thinks.

    To workaround this create the fresh new image with Virtual PC for “Windows 7 RTM” and bind existing VHD drive.
    Then you can jump to the next problem.

    Problem II

    After I started the new image following erroro apered:

    Virtual PC bla, blla "was unable to write to one of its virtual hard disks"

    Now I was like “arggsh” (read and feel frustrated).
    To slve the proble I figured out, that the external VHD drive has to be bound by using of share name.

    For example: c:\Machines\MyDrive.vhd will fail with error shown above.
    So, to make it working use share name: \\MyMachineName:\Machines\MyDrive.vhd

    Now I’m asking myself ”why do we like to make things to complex?”

    Just forget it and be lucky.

    :)

  • Configuration Simplification in WCF (in German)

    Few weeks ago I wrote an Article for Compute World in Swiss, which covers WCF 4.0 configuration simplification.

    Intro:

    Die kommende Version 4.0 des .NET Framework bringt auch für die Windows Communication Foundation (WCF) einige Änderungen mit sich. Im Vergleich zur Workflow Foundation 4.0 fallen die Änderungen im WCF-Stack nicht so dramatisch aus. Alles was bisher funktioniert hat, wird auch weiterhin funktionieren. Es gibt allerdings einige Neuigkeiten, die Entwicklern das Leben mit der WCF in manchen Szenarien in der Tat leichter machen werden (wer hätte damit gerechnet? :) ).”

    For all of you interested enterprise developers article can be found online here.

  • Workflow Services: How to setup namespace and contract name

    If you want to use the custom namespace of your WorkflowService which is in fact different than the default one “http://tempuri.org”, you have two ways to do that:

    1. Brute Force method by using of XAML
    2. Setting of namespace in property window.

    Setting of Namespace in XAML

    image

    Setting of Namespace in property window

    image

  • More WCF Stack in SIlverlight 4.0

    More WCF services

    .NET RIA Services  and ADO.NET Data Services will be rebranded as WCF Data Services and WCF RIA Services. That seems to be an interesting marketing move, but in fact it express that WCF was and is major base technology for communication.

    RIA Services and Data Services are a bit different than their base WCF. If you will they totally hide away the complexity of using WCF directly. The power of WCF is still there for you under the covers, if you need to modify some setting to your liking.

    New Binding in Silverlight

    Silverlight 4 will provide a new high-performance binding NetTcp.with duplex support.In Silverlight, the binding is built on top of the sockets support that’s already there since Silverlight 2.
    Because of this the security requirements inherit security requirements of the Silverlight sockets API. That means, services need to be hosted in a given port range 4502 – 4534 and needs to expose a policy responder on port 943.

    Note that streamed programming model for NetTcp in SIlverlight is not supportel like in desktop framework.

    Posted sij 14 2010, 11:45 by anonymous
    Filed under: ,
  • Truncation is not Shrinking

    While working with transaction logs SQL Server is recording every operation in the log file. If log records were never deleted, it would fill all the disk space. Log truncation is process which automatically frees space in the logical log for reuse by the transaction log. Many developers and admins expect that truncation also frees the physical disc space. This is a fatal mistake. Truncation frees the space inside of the transaction log file, but the file remains in its physical size unchanged. The transaction log file is so called Wrapped-Up logical file, which contains a number of virtual

    Usually truncation automatically frees space in the logical log except when it is delayed. Moreover one part of the transaction log file will be truncated only if its content is backed up in the transaction log backup. Note that truncate is not done in a case of WITH COPY_ONLY backup!

    Truncation occurs automatically under the simple recovery model when database is backed up. Under the full recovery model truncation is done when the transaction log is backed up.

    To reduce the physical size of the transaction log file you need to perform shrinking operation. Shrinking can occur if the database is online and, at least one virtual log file inside of logical transaction log file is free. In some cases, shrinking the log may not be possible until after the next log truncation.
    To shrink the database do as shown at the next figure.

    image

    This brings you to selection what to shrink. Two options are possible: Data or Log. The first one means shrink database and the second one shrink of the transaction log.

    image

    The UI shown above and at the next figure shows exactly the status of logical file and the status of virtually used space inside of the logical file.
    For example, next figure shows the physical log file whose virtual logs take  89% of physically allocated 2,25MB.

    image
    To get the feeling how shrinking work, let’s perform the shrink operation by reorganizing of unused space to zero (set “shrink file” to to 0).

    image 
    As you see the log file is not reduced to zero size, because the backup has not been done. The used data remains in the transaction log and unused data of 11% (0.25MB) has been thrown away.

    If you now perform the log backup and then perform shrink following is the result.
    image
    You will see that the log file now contains 76% of unused space with the same physical size of 2 MB.
    Now you can choose to reduce the size for example to zero.
    This is the way how to reduce the size of log file. Unfortunately I have experienced, that shrink in some cases does not really reduce the size to the size have have chosen.

    There are two workarounds

    Before you perform these steps make FULL BACKUP!

    Attaching to MDF without of LOG file:

    -Detach the database which you need to truncate the transaction log.

    -Open the folder containing transaction log file like "\Microsoft SQL Server1\MSSQL\Data\"

    -Rename the transaction log file to a different name.

    -Attach the database again by attaching to MDF file like \Microsoft SQL Server1\MSSQL\Data\MyDb.MDF'

    Attaching to MDF when LOG file does not exist will cause creating of the new empty log file.

     

    Temporary Using of Simple Recovery model

    Additionally you can set the database to use Simple Recovery Model. This will create log file with zero size.

    After that you can switch back to Full Recovery Model.

  • Working with Backups in SQL Server

    When working with SQL Backups there are in general two types of backup: Full, Differential and Transaction-Log (to be explained later in this post). Additionally, it is important to know that the   recovery model (Database Options) plays also an important role has an impact to backup strategy.
    In this post  I’m not going to explain all these in detail, but just to give a short practical overview.
    If the database is setup for Simple recovery model (Fig. 1), you can make following backups: Full and Differential. If the database is setup for Full Recovery, there additionally is possibility to make Transaction Log backup (See Fig. 5).

    Recovery Model Comparison:

    Simple

    No transaction log backups
    Saves transaction Log space
    Changes since the most recent backup are unprotected
    Can NOT recover to a specific point in time

    Full

    Requires transaction log backups
    Can recover to a specific point in time
    Takes a lot of space for transaction log
    If the tail of the log is damaged, changes since the most recent log backup must be redone

     

    Bulk Logged

    Requires transaction log backups
    Enables fast performance for bulk-operations.
    Can NOT recover to a specific point in time

    Backup Comparison

    Full backup
    A full backup is backup which contains all the data in database (or filegroups or files), and enough of transaction log to make total recovering possible.
    To make this backup right mouse click on Backup and select Full as shown in Fig. 1.

    image 
    Fig 1.

    To recover from FullBackup simply choose the FullBackup and device.

    Differential Backup

    A differential backup contains only the data that has changed since the differential base. Differential backups can speed up the process of making frequent backups to decrease the risk of data loss. If they are taken soon after the Full-backup are smaller and faster to create than the base of a full backup. To make this backup do the same as shown in Fig. 1, but choose Differential instead of Full.

     

    image
    Fig 2

    To recover from Fifferential Backup you must first recover from FullBackup with “RESTORE WITH NO RECOVERY” as shown in the Figure 2. This will restore full backup. and the database (in fig 5 TestDb) will remain in recovering mode. That means it is not usable and it is awaiting to be fully recovered.
    If the previous restore from FullBackup or even Differential Backup was not don with optoin NO RECOVERY, following error will appear:

    “The log or differential backup cannot be restored because no files are ready to rollforward.”

    Now, select Task | Restore | From File or Database and select Differential Backup to be restores. Usually you will use restore from database. However sometimes you might want to keep your backups in separated files. If you do that be sure that you know in which order backups have been stored in certain files!

    image
    Fig 3.

     

    Transaction Log Backup

    Under the full recovery model or bulk-logged recovery model, regular transaction log backups (or log backups) are required. Each log backup covers the part of the transaction log that was active when the backup was created, and it includes all log records that were not backed up in a previous log backup. An uninterrupted sequence of log backups contains the complete log chain of the database, which is said to be unbroken.

    To limit the number of required log backups, it is recommended to routinely back up your data. For example, you might schedule a weekly full database backup and daily differential database backups.

    Fig. 4 shows how to do transaction log backup. Select backup Type “Transaction Log”.
    image
    Fig 4.

    Restoring of Transaction Log can only be done if previously Full Backup and all differential backups (if there are some) have been recovered in NO RECOVERY mode (See fig 3.).
    Figure 5 shows how to perform transaction log backup.

    image

    Fig 5.

    While restoring the backup be sure that you have all backups (especially if shared across different files) and that you know the exact order of backups. One example is in fig 6.

    image 

    Fig 6.
    Last but not least, while restoring the last backup, be sure that you restore it with option WITH RECOVERY (default one) shown in fig. 2.

Copyright of SQL/Developers Community
Powered by Community Server (Commercial Edition), by Telligent Systems