in

mscommunity.net

Interactive mscommunity.net online activities

DamirDobric

  • Windows Server AppFabric Customer Advisory Site

    MSDN launched recently a new blog as part of putting some of best people in the Microsoft application middleware space under a common “virtual” roof which we proudly call Windows Server AppFabric Customer Advisory Team or AppFabric CAT for short.

    The new team blog is Microsoft’s commitment to deliver the most wanted technical guidance and share best practices with the rest of the world-wide community. This blog is  a brand-new web site that will serve the purpose of the “one-stop shop” for all the great deliverables that the team will be producing for the community going forward.

    I you follow my blog all my posts tagged with AppFabric will be aggregated there.

    http://blogs.msdn.com/b/appfabriccat/

  • Windows Phone URI-mapping

    Windows Phone provides an UriMapper object. That object defines a mapping that will be used through the entire application for all navigation process. URI mapping are used to “hide” real navigation structure and provide query string parameters to the pages.

    Following picture shows a sample mapping process. When user press “P2/123” it will be navigated to relative address “/P2/123” which is a fake address. That fake address is mapped by “/P2/{number}” to “/Page2.xaml?id={number}”.

    image

    When you are in the page use NavigationContext to get query arguments.

  • SIlverlight Animation Rendering

    Some developers know and some do not know that Silverlight has by default one Main thread. Depending on you application many other threads can be span. But there is always only one main thread which is responsible to render the UI objects on the page. This thread is called UI-thread and similar even the same thread model can be found in any UI platform.
    So, in typical scenario which includes invoking of a Web Service operation there is UI thread and a web service operation invoking thread. This ensures that UI elements like animations (storyboards) are smoothly rendered while other threads in the application are doing their job. 

    All this sound trivial, but there are some hidden details here which could be very, very useful and interesting for every developer.

    After the service operation returns, the result is dispatched on the UI-thread. Fortunately you need to evaluate this result and perform some bindings to update the UI. This moment of time is exactly the critical one. When binding process starts everything you do in converters and everything Silverlight controls are doing is done on UI-thread.
    Imagine now, you have some animation running at the moment when binding starts. If the binding implements some heavy calculations the animation will, you probably assume, not run smooth as expected.

    Here is one example:

    image

    The picture above shows application which has running a storyboard and binds some data to the list by using of one converter.

    public class MyConverter : IValueConverter
    {

            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
           {
                if (MainPage.IsSlowModeEnabled)
                {
                    double res = 12.334;
                    for (int n = 0; n < 3000000; n++)
                    {
                        res*= res;
                    }
                }

                return value;
            }
    }

    The converter does nothing if IsSlowModeEnabled set on false, what is by default. When the user press a button this variable is set on true and binding start a heavy calculation. If you compare how smooth the animation works in this two cases, you will notice that animation stops totally while converter is running.

    Today, industry applications looks in average very bad and almost nobody think bout this issue. But, soon applications will look better, for sure. One could ask question now: If such rendering is that bad on a desktop, what can we expect on platforms like Windows Phone?
    Windows Phone has by default two threads: Main (UI) thread and Renderer. Renderer thread cannot be seen in debugger and it is in play when some animation (storyboard) is running.

    That means (simplified), as long your binding is running in UI-thread in even heavy converter, all active animations will be rendered in Renderer-thread.

    image

    This Silverlight feature is on Windows Phone different than in the Silverlight desktop version. It is build on top of Direct X 10 and WDDM 1.1. Note that this feature will not work in emulator on WDDM 1.0 and lower. In this case animation will be rendered just as in desktop Silverlight on UI-thread.

  • AppFabric error “not able to activate any of the hosts”

    When working with long running processes (workflows) in AppFabric you will probably from time to tome get following errors:

    image

    Error 1:

    WMS was not able to activate any of the hosts - backing off. Store name 'yourStoreName ('Root).

    Error 2:

    Failed to invoke service management endpoint at 'net.pipe://dado-nb1/TestServices/ServiceManagement.svc' to activate service '/YourAppVirtualPath/YourService.xamlx'.\rException: 'The message could not be dispatched because the service at the endpoint address 'net.pipe://yourhostname/YourAppVirtualPath/ServiceManagement.svc' is unavailable for the protocol of the address.'

     

    Both errors appear in pairs after the application pool has been stopped for any reason and persisted workflow instance is still in run able state. Because Workflow Management Service which is responsible to reload persisted instance has no knowledge of ApplicationPool i tries to reload the Workflow Instance. If the AppFabric is installed din cluster this will happen at all nodes. If no any of nodes (hosts) is able to reload instance this error will happen.

    In common system log you will notice following two entries:

    Error:

    Application pool 'yourpoolname' is being automatically disabled due to a series of failures in the process(es) serving that application pool.

    Warning:

    A process serving application pool 'yourpoolname' suffered a fatal communication error with the Windows Process Activation Service. The process id was '1216'. The data field contains the error number.

    image

    Posted kol 28 2010, 03:14 by anonymous
    Filed under: ,
  • AppFabric 'Cancel' command failure

    If you see this error in AppFabric dashboard you might be suprised, because the error is cause by some workflow activity, which is not a part of your workflow.

    (1) 'Cancel' command failure:
    The message could not be dispatched because the service at the endpoint address 'net.pipe://dado-nb1/TestServices/yourservicename.xamlx/System.ServiceModel.Activities_IWorkflowInstanceManagement' is unavailable for the protocol of the address.

    This error is caused by stopped application pool. If you try to suspend or terminate the workflow instance and the pool is in the mean time stopped, the management endpoint (implicitly added by AppFabric) will not be able to communicate with your service.

  • InstancePersistenceCommand error in AppFabric

    If you get following error in AppFabric dashboard, you will probably have no idea what the problem could be.

    An error processing the current work item has caused the workflow to abort.  See the inner exception for details. InnerException Message: The execution of the InstancePersistenceCommand named {urn:schemas-microsoft-com:System.Activities.Persistence/command}SaveWorkflow was interrupted by an error.


    The problem with this exception is that you miss a real error description which is not tracked in the dashboard. Unfortunately when one exception is tracked in the AppFabric dashboard it is unlikely that you will find any other error in event log.

    This problem is caused by using of custom tracking participant while property promoting. In this case there is probably some peace of code (class) which has to be persisted, but it is not serializable by DataContractSerializer. To find this out catch the exception by overwriting of Activity.Abort method. The value in context.Reason will contain fabulous InnerException (see error text above) with full description.

    In my specific case, I used the class which implements IReceiveMessageCallback:

    public class ReceiveInstanceCallback : IReceiveMessageCallback

    This interface is used when you need to get access to WCF’s butty of Service Model within you workflow. It might be surprising, but the solution is to add data contract attribute to the class:

     

    [DataContract(Namespace=WfSchedulerPromoterParticipant.PromotedPropertyXNamespace)]
    public class ReceiveInstanceCallback : IReceiveMessageCallback
    Posted kol 27 2010, 12:17 by anonymous
    Filed under:
  • Task programming model on Windows Phone

    Windows Phone provides several out of the box dialogs/pages which helps a user to compose some task like camera capturing or sending of an email.
    Such actions are called tasks in WP programming model. Because applications are not able to directly access common stores of information, such as the contacts list, and to directly invoke other applications, such as the phone or messaging. To enable scenarios that require common tasks such as these, Windows Phone exposes a set of so called launcher and chooser APIs.
    One chooser is an action of type fire and forget. For example Send SMS or Open some Web Page. In contract one launcher is an action which returns some information like select contact.

    Supported Launchers

    · EmailComposeTask 
      Use this to allow users to send email from your application

    · MarketplaceLauncher
      Allows an application to launch the Marketplace application

    · MediaPlayerLauncher
      Allows an application to launch the media player

    · PhoneCallTask
      Allows an application to launch the Phone application; use this to allow users to make a phone call from your application

    · SearchTask
      Allows an application to launch the Web Search application

    · SmsComposeTask
      Allows and application to launch the SMS application

    · WebBrowserTask
      Allows an application to launch the Web Browser application

    Supported Choosers

    · SaveEmailAddressTask 
      Use this to allow users to save an email address from your application to a new or existing contact.
    · SavePhoneNumberTask 
      Use this to allow users to save a phone number from your application to a new or existing contact

    · EmailAddressChooserTask - Allows an application to launch the Contacts application; use this to obtain the email address of a contact selected by the user

    · CaptureCameraTask - Allows an application to launch the Camera application; use this to allow users to take a photo from your application

    · PhoneNumberChooserTask - Allows an application to launch the Contacts application; use this to obtain the phone number of a contact selected by the user

    · PhotoChooserTask - Allows an application to launch the Photo Chooser application; use this to allow users to select a photo


    Technically, one task on Windows Phone is a class which derives from ChooserBase<TTaskEventArgs>.

    public abstract class ChooserBase<TTaskEventArgs> where TTaskEventArgs
    : global::Microsoft.Phone.Tasks.TaskEventArgs
    {
            //     Occurs when a chooser task is completed.
            public event EventHandler<TTaskEventArgs> Completed;

     

           //     Call this method to raise the Completed event.
            protected void FireCompleted(object sender, TTaskEventArgs e, Delegate fireThisHandlerOnly);

            //     Launches and displays the chooser.
            public virtual void Show();

    }

    In fact, one task can be “Shown” and finally completed. So, if you want the user take a picture call CameraCaptureTask.Show(). After the user is finished, you can be notified by subscribing of event Completed.

    In contrast Launchers do not have a base class. They all provide static method named Show().

    All choosers and launchers are implemented in assembly Microsoft.Phone, Version=7.0.0.0:.
    Personally I think that naming of choosers and launchers is inconsistent. Moreover Launchers do not derive from some base class, some of them have instance Show() method and some static Show() method.
    I would regard more consistent model for Choosers and Launchers. This would give as ability in the future to build distributable Choosers and Launchers in the marketplace and to reuse them across applications. Imagine TVChanelLauncher or GeoLocationChooser.

  • Host WCF Services with Service Bus Endpoints in IIS and Windows Server AppFabric

    If you know how *RelyBindings of Service Bus works or have at least an idea how they could work, it is clear, why service hosted with these family of bindings “cannot” be hosted in IIS.
    The original design of IIS relies on almost philosophical assumption that there is some client out there which request some resource by sending a message. IIS receives the request/message, locates requested resource, performs some action in pipeline chain and returns the response.
    If you understand why this topic is an issue and you have IIS 7.5 and AppFabric installed just jump over to topic Echo Service Sample.

    What is the problem at all?

    This concept has been existing for a while, as WCF came into IIS for first time. By using of WebServiceHostFactory, which is defined in SVC-files all seemed to be fine. The client sent the request to SVC-file, and WebServiceHostFactory has initialized the service.

    The problem with *RelayBindings of Service Bus is, that they do not listen for incoming messages as typical service listeners do. Rely bindings in fact send message to Service Bus and wait on response.
    So, and what is wrong with this? 
    The problem is that the client who sends the message will never send the message to SVC file. As a result of this design, the WCF service hosted on Rely Bindings will never be initialized.
    If you like here is one interesting discussion about this.

    Fortunately since IIS 7.5 (delivered with Windows 7 and Win Srv 2008 R2), there is a feature called Auto-Start. This is ability of a pool to be in so called mode Always-Running. More about this here.
    This feature is very powerful and in context of WCF activates channels before any message arrives.

    For all of you who do not exactly know what this does mean, here is a short explanation.
    When you have a console application which should host the service you will typically call Open to activate the channel.

    {
      . . .
      host.Open();
    }

    In typical IIS scenario this is done with help of WebServiceHostFactory, but when the message arrives.
    If your service is hosted in IIS 7.5 and its pool is set on always-running the method Open() is called immediately after the pool is initialized. In other words, you do not need to wait on message to get the service initialized.

    This is exactly the feature which *RelyBindings need.

    How Windows Server AppFabric can help?

    To make usage of Always-Running feature of IIS 7.5 you have to implement so called Service Auto Start Provider. This is in case of WCF services not very easy task. The good thing is that WIndows Server AppFabric has such provider out of the box. More over, AppFabric provides a powerful GUI, which can be used for configuration.

    The ultimate solution with AppFabric looks very simple:

    1. Implement the service and setup a site for it in IIS.
    2. Enable Auto-Start by using of AppFabric

    You will probably not believe me, but this is all (more or less). Otherwise it would be too boring. :)

    Prerequisites

    To make this working be sure that you have to have IIS 7.5.
    image

    Be also sure that you have installed Windows Server AppFabric
    image
    And finally install following two patches: Patch 1 and Patch 2. First patch will allows you to use Service Bus configuration elements (transportClientEndpointBehavior and serviceRegistrySettings), because they are not defined by IIS set of schemas stored in C:\Windows\System32\inetsrv\config\schema. Without of this patch you cannot use AppFabric UI in this demo. The second one fixes one bug with auto-starting in multiple pools.

    I took the existing ExchoSample solution and converted it in VS 2010. During conversion I set up both projects in solution (client and service) to .NET Framework 4.0. Thanks to Wade Wagner I just jumped in folder C:\Program Files (x86)\Windows Azure platform AppFabric SDK\V1.0\Assemblies\NET4.0 and executed RelayConfigurationInstaller.exe without of any change in config file.

    image

    This simple program just append few entries in machine.config file in folder C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config:

    image

    Echo Service Sample

    To demonstrate this I used EchoService found in WindowsAzureAppFabricSDKSamples. I took the existing ExchoSample solution and converted it in VS 2010. The goal here is to prepare this solution to be hosted in IIS/AppFabric.

    Now, I added the new project of type Asp.Net Empty Application and added EchoContarct.cs and EchoService.cs as linked files. I added them as linked files to demonstrate that I didn’t perform any change in the service. Following picture shows the solution.

    image

    The project with name “Service” will not be used in this demo.
    Finally I setup hosting in IIS (in project properties panel of VS-IDE):
    image

    The ServiceIis will be hosted in IIS and Client will play a role of consumer. All we need to do is to prepare the configuration. This is the whole configuration of service model you need.

    <system.serviceModel>

     <serviceHostingEnvironment multipleSiteBindingsEnabled="false">
          <serviceActivations>       
            <add relativeAddress="ExchoService.svc"
                 service="Microsoft.ServiceBus.Samples.EchoService, ServiceInIis,
                 Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          </serviceActivations>
        </serviceHostingEnvironment>
                                      
        <services>
          <service name="Microsoft.ServiceBus.Samples.EchoService">
            <endpoint address="sb://dobric.servicebus.windows.net/EchoService/"
                      contract="Microsoft.ServiceBus.Samples.IEchoContract"
                      binding="netTcpRelayBinding" behaviorConfiguration="myBehavior" />
          </service>
        </services>

        <behaviors>
          <endpointBehaviors>
            <behavior name="myBehavior">
              <transportClientEndpointBehavior credentialType="SharedSecret">
                <clientCredentials>
                  <sharedSecret issuerName="******" issuerSecret="******" />
                </clientCredentials>
              </transportClientEndpointBehavior>
              <serviceRegistrySettings
                 
    displayName="Damir's Echo Service hosted in IIS with
                               Windows Server AppFabric
    "
                  discoveryMode="Public">           
              </serviceRegistrySettings>
            </behavior>                                     
          </endpointBehaviors>
        </behaviors>
    </
    system.serviceModel>

    First, under serviceHostingEnvironment I used file-less activation. Because the project does not contain the SVC file, I added service activation element, which would allows me to send request like: http://localhost/EchoService.svc . One could ask now, why do we need this service at all if the activation is not performed my sending of the message to that service?
    The answer the client does not need it, but AppFabric. If you want to be able to set the service for message-less activation AppFabric has to know that the service exist.
    In AppFabric dashboard click on Services as shown at picture below:
    image

    At this point I could select Configuration (right mouse click on service) and set up Auto-Start:
    image
    In my picture Auto-Start is disabled, because I enabled  Auto-Start on Application level for all services which I will possibly host in this application. Here is where I did it. I selected my Application (ServiceInIis) and opened configuration dialog whown at the next picture:
    image

    Enable means Auto-Start for all services. Custom means, you will need to select a wanted service (like in previous picture). This is useful if not all services in application have to be Always-Running.
    After you apply this change, AppFabric UI will setup the pool of the application to Always-Running.
    In application host config file C:\Windows\System32\inetsrv\config\applicationHost.config this looks like:

    <add name="MyPool" autoStart="true" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />

    After you apply changes open the following address in browser: https://dobric.servicebus.windows.net/

    This is the address where your service will be hosted. If all worked fine you will see following in browser:

    image

    Hope this helps.

    Damir



  • Error by hosting of Win Azure Service Bus service in IIS

    When hosting WCF Services based on Microsoft Windows Azure Service Bus technology in Internet Information Server you will need to set the absolute address of service (i.e.: sb://mynamespace.servicebuse.net). Additionally, if your service is defined with file-less activation you must not enable multiple site bindings:

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
          <serviceActivations>
            <add relativeAddress="ExchoService.svc" 
                
    service="Microsoft.ServiceBus.Samples.EchoService, ServiceInIis,
                
    Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />

     

         </serviceActivations>
    </serviceHostingEnvironment>

    The value of attribute multipleSiteBindings must be set on FALSE. Otherwise following exception will be thrown. The exception can be found in EventLog.

    WebHost failed to process a request.
    Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/62163723
    Exception: System.ServiceModel.ServiceActivationException: The service '/ServiceInIis/ExchoService.svc' cannot be activated due to an exception during compilation.  The exception message is: When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true in configuration, the endpoints are required to specify a relative address. If you are specifying a relative listen URI on the endpoint, then the address can be absolute. To fix this problem, specify a relative uri for endpoint '
    https://dobric.servicebus.windows.net/EchoService/'.. ---> System.InvalidOperationException: When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true in configuration, the endpoints are required to specify a relative address. If you are specifying a relative listen URI on the endpoint, then the address can be absolute. To fix this problem, specify a relative uri for endpoint 'https://dobric.servicebus.windows.net/EchoService/'.
       at System.ServiceModel.Activation.ApplyHostConfigurationBehavior.ThrowIfAbsolute(Uri uri)
       at System.ServiceModel.Activation.ApplyHostConfigurationBehavior.FailActivationIfEndpointsHaveAbsoluteAddress(ServiceHostBase service)
       at System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost)
       at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
       at System.ServiceModel.ServiceHostBase.InitializeRuntime()
       at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
       at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
       --- End of inner exception stack trace ---
       at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
       at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
    Process Name: w3wp
    Process ID: 5368

  • Preventing of Security Warnings in Outlook Part 2 of 2

    Since release of Outlook 2010, developers have no more possibility to use use CDO and related libraries. For long time, these libraries have been smart simplification of MAPI, which is known as very complex and developer unfriendly. More over since release of Exchange 2010, support for WebDav has also been deprecated.
    The new way of programming of server components is now Exchange Web Service EWS and Outlook Object Model (the same name as in past) which is now quite simplified in Visual Studio 2010.

    Problems and one possible solution related to this feature are described in my previous post.

    In this post I will describe how to prevent security warning popups by using of a much smoother way.
    Before one do this, be sure, that I recommend it for advanced users only, because changes described in this post will allow potential viruses to access you private data in the address book!!!

    1. Go to Outlook Options
    image

    2. Select Customize Ribbon and add Developer Command Item in ribbon.

    image

    3. Select Developer Command Item and click “Macro Security”

    image

    4. Select “Programmatic Access” and choose “Never warn me about …”

    image

  • Preventing of Security Warnings in Outlook

    Since release of Outlook 2010, developers have no more possibility to use use CDO and related libraries. For long time, these libraries have been smart simplification of MAPI, which is known as very complex and developer unfriendly. More over since release of Exchange 2010, support for WebDav has also been deprecated.
    The new way of programming of server components is now Exchange Web Service EWS and Outlook Object Model (the same name as in past) which is now quite simplified in Visual Studio 2010.

    Unfortunately, when programming against this model you might notice security alerts (warnings) in form of popup window, when your code is trying to access protected objects like email address of one user.

    Here is one example:



    This is a good security model, but not really good development practice. The problem is that disabling of this protection seems to be very complex task described in many, many posts and articles in internet.
    Here are just few examples:http://www.outlookcode.com/article.aspx?id=52http://www.add-in-express.com/outlook-security/, http://msdn.microsoft.com/en-us/library/aa209964(office.11).aspx, http://technet.microsoft.com/de-de/library/ff657852.aspx

    The good thing is that Microsoft since Outlook 2007 provides one very simple solution for this. You do not need to use neither group policy or security templates. All you need is Vista or Windows 7 and one functioning Virus Scanner.

    New security model in Outlook 2007 and 2010 takes advantage of the status of antivirus software installed on a machine where you component is running. This change represents a major departure from the way the Object Model Guard worked in the past. If Outlook is able to detect that antivirus software is running with an acceptable status, Outlook disables security warnings for the user.

    More about this here: http://msdn.microsoft.com/en-us/bb226709(office.12).aspx

    When virus scanner reports acceptable status, you can notice that with marked icon below and can be checked by (Windows Security Centar API)

    image
    It is important, that hen Outlook is not running and your application creates the Outlook Application Object in background following icon appears:

    image

    Which means:

    image

    Here is a set of possible actions hen you click on icon:

    image

    Conclusion: To prevent Outlook of showing of security warnings install and run properly some virus scanner.

  • How to create and mount virtual drive?

    In this post I will chow how to create and mount a virtual drive. Virtual drive is a file Virtual Hard Drive. That means you can use it as any other NTF drive within System.IO namespace. In some scenarios it can be very helpful to write data to virtual drive and then to do something with the VHD drive. For example, when working with Windows Azure you can mount to this drive, write to it (by using System.IO namespace) and finally download a copy of that file (disc) for analyzing purposes.

    Interesting in this scenario is that the data in this drive is in fact Windows Azure blob storage data, which can also be accessed by standard blob storage API.

    Create Disk and Attach
    Save following script in some file like creatediskscript.txt. This will create the fixed disk of 50 MB, formatted as NTFS and mount it as drive V.

    create vdisk file="c:\temp\mydrive.vhd" maximum=50 type=fixed
    select vdisk file="c:\temp\mydrive.vhd"
    attach vdisk
    create partition primary
    assign letter=v
    format fs=ntfs label=vhd quick
    exit

    Open a command line console and execute the script:

    diskpart /s c:\temp\discscript.txt

    after executing of the script you will experience well known dialog, which is initiated by Virtual Disk Service:

    image

    After that you can use the disk as any other drive. Finally to disconnect do following:

    image

    Attach to Disk
    Following script shows how to attach to an existing disk:

    select vdisk file="c:\temp\mydrive.vhd"
    attach vdisk
    exit

    Detach Disk

    select vdisk file="c:\temp\mydrive.vhd"
    detach vdisk
    exit

  • Encryption with Key Container

    When encrypting some data in your application, you can use various already proven algorithms, which are integrated in .NET.
    However, one thing remains mostly unclear. When talking about encryption most people focus on algorithms. This is reasonable, but one algorithm is at least secure as the key is secured.
    In other words, if you have strong key and best algorithm in universe, but your key is insecurely stored, all is unsecured.

    For this reason I post very short sample, which shows how easy key store can be incorporated in your application. If you try in this example to change CspParameters all will work fine as long both methods EncryptByContainer and DecryptByContainer
    use exactly the same settings.


            private static void Start()
            {
                byte[] decryptedData = EncryptByContainer("Daenet is award winner");
               
                string txt = DecryptByContainer(decryptedData);
            }

            private static byte[] EncryptByContainer(string txt)
            {
                byte[] binData = Encoding.Unicode.GetBytes(txt);

                CspParameters cspPrms = new CspParameters();
                cspPrms.Flags = CspProviderFlags.UseMachineKeyStore;
                cspPrms.KeyContainerName = "TestKey";
               
                RSACryptoServiceProvider rsaProv = new RSACryptoServiceProvider(cspPrms);

                byte[] encyptedData = rsaProv.Encrypt(binData, true);

                return encyptedData;
            }

            private static string DecryptByContainer(byte[] encryptedData)
            {
                string txt;
             
                CspParameters cspPrms = new CspParameters();
                cspPrms.Flags = CspProviderFlags.UseMachineKeyStore;
                cspPrms.KeyContainerName = "TestKey";

                RSACryptoServiceProvider rsaProv = new RSACryptoServiceProvider(cspPrms);

                byte[] decrypedData = rsaProv.Decrypt(encryptedData, true);

                txt = Encoding.Unicode.GetString(decrypedData);

                return txt;
            }



  • ICE Platz Reservierung

    When travelling by train in Germany, I never know what seat I should book. So I decided this time to write down all required information.
    Here it is in German:

    Alle ICE Züge in Frankfurt sind in Fahrtrichtung von 1 bis N eingeordnet. D.H. der erste Wagen ist Nummer „1“, ist an Lock angehängt und ist meistens im Bereich „F“ positioniert.
    Der letzte Wagen ist in der Regel im Bereich „A“ positioniert. Bereich „A“ ist gleich am Anfang von Gleis (schnell zu erreichen) und Bereich „F“ am weitesten vom Gleis-Eingang entfernt (ca. 100 m).
    Die Wägen Klasse „1“ sind meistens im Bereich „A“ positioniert, dann kommt Bord Restorant und dann die Wägen Klasse „2“.
    Die Wägen Klasse „2“ fangen meistens mit 6 oder 7 an. Somit ist Bord Restorant Wagen meistens Nummer 5.

    Die Sitznummern im Wägen fangen mit 10 an und enden mit 80. Die ersten Nummer (also ab 10) sind in der Fahrtrichtung positioniert und die letzteren (also 80) von Lock weiter entfernt.
    Wenn Sie z.B, an der Tür am Anfang des Wagens in der Fahrtrichtung sitzen möchten, nehmen Sie die kleinsten Nummer 10-18. Dies Plätze sind alle entgegen der Fahrtrichtung positioniert
    (Sie fahren Rückwerts).

    Dann kommen die Plätze 23-28. Das sind die Tischplätze mit Stromanschluss. Für Laptops über 19‘‘ nicht wirklich geeignet. Die Leistung der Steckdose ist mir nicht bekannt. Sicher ist es, dass die 140 VA vertragen können.

    Die Tischplätze mit ungerade Nummer (25, 27, 21 und 23) sind entgegen der Fahrtrichtung. Die restlichen (22, 24, 26 und 28) sind in der Fahrtrichtung.

    Manchmal fahren die Züge in umgekehrter Reihenfolge. Dann ist natürlich alles verkehrt rum.

  • Error while installing outlook 2010 or CDO

    While installing some of Outlook components you may get following error:

    “Outlook 2010 may not be installed with a newer version of outlook”

    This error is caused by at least two possible reasons:

    1. There is already an Outlook 2010 installed on the machine and you are trying to install CDO library.
    2. There is already CDO (Collaboration Data Objects) library installed on the machine and you are trying to install Outlook 2010.

    What ever the reason is, remove previously installed components. The error is caused by side by side installation of CDO and Outlook 2010, which is NOT supported. CDO and related components are deprecated since Outlook 14 (2010).

     

    If you need to implement client based peace of code, you will have to use either MAPI or Outlook Object model as an Add-In or any kind of other application type.

More Posts Next page »
Powered by Community Server (Commercial Edition), by Telligent Systems