Friday, November 23, 2012

Outlook Runtime Error -2147221233 The operation failed. An object cannot be found

This error comes out after my windows 7 get updated from microsoft, maybe some for outlook

in my VBA code ,I have following code to move a message to another folder.

 Msg.Move objNS.Folders(2).Folders("foldername")

is suddenly pop up the error messages,did some debug,find out that we need change to following code now

 Msg.Move objNS.Folders(1).Folders(13)

all index started with 1
objNS.Folders(1) is first folder in my outlook name space

objNS.Folders(1).Folders(13) is the 13th sub folder in previous folder,there is not method to get a sub folder by it's name,maybe a iteration will help to find the folder with specific name,but it is too heavy here,if we do not add new sub folder between first one and 13th,then we will be ok with previous code.




Wednesday, November 21, 2012

Installing the IDEA Module in GnuPG


(THIS INFORMATION COMES FROM http://www.spywarewarrior.com)

The "official" Win32 builds of GnuPG do not include support for the IDEA algorithm, which is patented.* This can prove to be a problem when exchanging messages and files with PGP users (esp. PGP 2.6.x users) or importing old PGP keys. This web page explains how to install the IDEA module for GnuPG so that GnuPG can use the IDEA algorithm.
The IDEA module has been distributed as both a source code file (IDEA.C) and a compiled .DLL (IDEA.DLL). Unless you plan to compile the source code yourself, you want the IDEA.DLL, which is placed somewhere in the GnuPG installation directory and loaded with the load-extension option.
Please note that the IDEA module, its location within the GnuPG installation directory, and the method for loading that module with the load-extension option have changed over successive versions of GnuPG:
Please consult the appropriate directions for your version of GnuPG. All of the versions of the IDEA module discussed on this page are available for download from this site -- see the Downloadssection below.
* The IDEA is patented in many countries, including the U.S., and may be used for non-commercial
   purposes. For commercial uses you'll need to buy a license from MediaCrypt. For the "official"
   explanation of why the IDEA algorithm is not supported in GnuPG by default see HERE.

GnuPG 1.2.0 and later

There were big changes in GnuPG 1.2.0 with respect to the IDEA module. There's a new IDEA.DLL as well as a change from previous versions in the way the IDEA.DLL is loaded.

From the GnuPG 1.2.0 Announcement
* All modules are now linked statically; the --load-extension
  option is in general not useful anymore.  The only exception is
  to specify the deprecated IDEA cipher plugin.

* The IDEA plugin has changed.  Previous versions of the IDEA
  plugin will no longer work with GnuPG.  However, the current
  version of the plugin will work with earlier GnuPG versions.

Files

For "official" versions of GnuPG  (from gnupg.org), a new set of IDEA files is available from ftp.gnupg.dk (idea.c.gz & ideadll.zip):
FileSize (kb)Notes
idea.c13815/13727new source (gnupg.org)
idea.dll8192new Win32 DLL (gnupg.org)
The Nullify builds use Disastry's IDEA module (ideadll.zip), the same as previous Nullify builds:
FileSize (kb)Notes
idea.dll45056Disastry's IDEA module
See the Downloads section below for links to these files.

To Install

1. Place the IDEA.DLL in \LIB sub-dir of the GnuPG installation dir. 
2. Add the following line to the GPG.CONF file (in previous GnuPG
    versions it was in the OPTIONS file):
load-extension Lib\idea
    You can also specify a full path to the IDEA.DLL file:
load-extension C:\GnuPG\Lib\idea.dll
    This GPG.CONF file option line works for both the "official" and  
    Nullify
 GnuPG builds.

Friday, September 21, 2012

Web Service in Windows .Net

I followed a Shiv Pal Singh's post in CodeGuru that create a web service with .net in windows without a studio tools,here is the steps and content that recorded to help me remember.

1) install the IIS from windows 7,after installation the server is up,default page(actually is a html with one picture 

embedded with lot of links) can be see in browser.

2) add a default html in server's newly created virtual directory can also be see in browser,but the asmx web service file 

can not be see in browser because of the script handler is not properly registered in system

go to c:\windows\Microsoft.NET\Framework64\v.2.0.50727,run following command

ASPNET_REGIIS.exe -I 

remember this is 64 bit,not 32,running 32 in 64 will get a error

then stop and start the server:

net stop w3svc

net start w3svc

3) copy following content in to virtual directory,name is as FirstService.asmx, language is CS,not C


 <%@ WebService language="CS" class="FirstService" %>

  using System;
  using System.Web.Services;
  using System.Xml.Serialization;

  [WebService(Namespace="http://localhost/WebService/")]
  public class FirstService : WebService
  {
      [WebMethod]
      public int Add(int a, int b)
      {
          return a + b;
      }

      [WebMethod]
      public String SayHello()
      {
          return "Hello World";
      }
  }


we will get list of operations,use link can test the service,url http://localhost/WebService/FirstService.asmx?WSDL can 

return the wsdl file of the web service

now web service serverside is done

following step will test web service from local or another machine by web and standalone windows app

1) create following asp.net web page to test the web service,name it  as WebApp.aspx



<%@ Page Language="C#" %>
  <script runat="server">
  void runSrvice_Click(Object sender, EventArgs e)
  {
      FirstService mySvc = new FirstService();
      Label1.Text = mySvc.SayHello();
      Label2.Text = mySvc.Add(Int32.Parse(txtNum1.Text),
                    Int32.Parse(txtNum2.Text)).ToString();
  }
  </script>
  <html>
  <head>
  </head>
  <body>
  <form runat="server">
    <p>
        <em>First Number to Add </em>:
        <asp:TextBox id="txtNum1" runat="server"
             Width="43px">4</asp:TextBox>
    </p>
    <p>
        <em>Second Number To Add </em>:
        <asp:TextBox id="txtNum2" runat="server"
             Width="44px">5</asp:TextBox>
    </p>
    <p>
        <strong><u>Web Service Result -</u></strong>
    </p>
    <p>
        <em>Hello world Service</em> :
        <asp:Label id="Label1" runat="server"
             Font-Underline="True">Label</asp:Label>
    </p>
    <p>
        <em>Add Service</em> :
        & <asp:Label id="Label2" runat="server"
               Font-Underline="True">Label</asp:Label>
    </p>
    <p align="left">
        <asp:Button id="runSrvice" onclick="runSrvice_Click"
             runat="server" Text="Execute"></asp:Button>
    </p>
  </form>
  </body>

  </html>



This client is some code running from server to test web service,then display result in client page

2) standalone windows app,net point to a server that web service stay,we need use WSDL file from server to create a 

dll, link this dll with client code will make client test code connect with server and successfully test the operation


use following step to create DLL

WSDL http://localhost/WebService/FirstService.asmx?WSDL

this will download the server's WSDl file and create a agent file(C#) called FirstService.cs,use following command to 

compile the source code to a DLL,then put this dll in virtual dir\bin folder,IIS looking for this agent at run time.

csc /t:library FirstService.cs

create source code of the WinApp.cs


 using System;
 using System.IO;

 namespace SvcConsumer{
 class SvcEater
 {
        public static void Main(String[] args)
        {
                FirstService mySvc = new FirstService();
                Console.WriteLine("Calling Hello World Service: " + mySvc.SayHello());
                Console.WriteLine("Calling Add(2, 3) Service: " +
                mySvc.Add(2, 3).ToString());
        }
 }
}

using following to compile the client

csc /r:FirstService.dll WinApp.cs

exe file created,it will test our  web service created in previous steps








Friday, September 14, 2012

easy way to remember the parts of wsdl file

Tags:
definations: Root WSDL element
types: What data types will be transmitted
message:What messages will be transmitted
portType: what operations(functions) will be supported
binding: how will the message be transmitted on the wire? what SOAP-specific details are there.
service: Where is the service located?

Thursday, September 13, 2012

change the cygwin terminal prompt

the prompt controlled by variable PS1,so put following code to .bash_profile or .bashrc sould works


function prompt {
local WHITE="\[\033[1;37m\]"
local GREEN="\[\033[0;32m\]"
local CYAN="\[\033[0;36m\]"
local GRAY="\[\033[0;37m\]"
local BLUE="\[\033[0;34m\]"
export PS1=" ${GREEN}\u${CYAN}@${BLUE}\h ${CYAN}\w${GRAY} $ "
}
prompt

see the sqlstatement been run in java code from ibatis

add following tag in log4j,all statement been run and their parameter,result column name and data will write into log file



       
       
     

Tuesday, September 11, 2012

ANT WINDOWS style path and POSIX style path in cygwin

while using ant in windows cygwin, we can not simplely pass a posix style path in ant script,because posix style path like "/cygdrive/c/test" or "/home/atc/" can not be recognized by ant,only recognized by cygwin shell.
so in order to use those posix style path in ant script, we need convert this string into a windows style path,then path to ant,utility cygpath will help to do this kind of converting.


<exec executable="cygpath" outputproperty="app.home.dir">
  <arg value="--windows"/>
  <arg value="/home/atc/chryslerds"/>
</exec>
<echo message="${app.home.dir}"/>

<exec executable="cygpath" outputproperty="ant.dir">
  <arg value="--windows"/>
  <arg value="/cygdrive/c/ant182"/>
</exec>

<echo message="${ant.dir}"/>