Author: usenkanov

Automating Office Applications on the Server Side

If the aim of the automation is to use a predefined template, then it is not a good idea.
Read article from microsoft:
http://support.microsoft.com/kb/257757/en-us

Hence, ASP.NET code used on the server side sometimes fails to execute due to internal “Interop” reasons.
Also, important to note that during debugging code works OK.
The problem arises only when website is published on the IIS.
Same occurs for both Vista and Windows Server 2003.

The workaround is to call EXE windows forms application from ASP.NET code and then use the file generated by EXE.

How to register COM DLL on the server

Issue:
When I was trying to run the application that used the reference, error occurred:
“System.Runtime.InteropServices.COMException (0x80040154). Retrieving the COM class factory for component xxxx failed due to the following error: 80040154”

1. The COM component needs to be registered on his laptop. Start + Run, regsvr32 c:\wavetracker\componentname.dll
DID NOT HELP, another error:
The module XXX was loaded but entry-point DllRegisterServer was not found.
Make sure that XXX is a valid DLL or OCX file and then try again.

2. http://technet.microsoft.com/en-us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx
download:
– Process Explorer (a GUI-based version of ListDLLs from sysinternals)
– Process Monitor (fully replaces “RegMon”(another suite from sysinternals) on windows vista )

3. Usually the root of the problem is difficult to identify.
In my case, the problem was the wrong usage of classes and functions of the library on hand.
Hence, sometimes when you use library functions/classes in the wrong way it might give this error.
So, this error NOT ALWAYS means the lack of DLL or its registration!!!

The specified module could not be found

If the new system is a 64-bit OS system, then during compilation “target platform” should be set to 64-bit (and not “Any Platform”).
more info here:
http://blogs.msdn.com/delay/archive/2006/03/23/559142.aspx

If the system is OK (32bit OS) then the following steps should help:

To find exact errors the following tools should be used.
1. Assembly Binding Log Viewer (Fuslogvw.exe). (part of SDK Tool v2.0) (http://msdn2.microsoft.com/en-us/library/e74a18c4(VS.80).aspx)
Just run the viewer, enable the “Log bind failures to disk” setting, run the tool again, then refresh the viewer and open the failed binding entry (open all entries one by one until you see failing entry)

2. Filemon for windows (http://www.microsoft.com/technet/sysinternals/utilities/Filemon.mspx)
Run Filemon, specify a filter of “*tool_name*” to limit the output, then run the program of interest. Filemon will capture a whole bunch of stuff, so save the output to a file where it can be searched more easily.

Ex:
In my case the problem was that PDFLIB was using 2 libraries:
– pdflib_dotnet.dll
– msvcr71.dll

In manual for using PDFLIB with ASP.NET it states that:
“Both pdflib_dotnet.dll and msvcr71.dll should be placed in bin folder”

ASP.NET compiler was looking for msvcr71.dll within the folder C:/windows/system32 (and many other folders).
Without going too deep in the details, i just copied one copy of msvcr71.dll from the bin folder to the system32.
Voila, everything started working.

Apparently system was set up some weird way and ASP.NET compiler was looking for msvcr71.dll in system32. Because the website works even without “msvcr71.dll” placed in a bin folder.

How to change root password in FreeBSD

1. Turn the system off.
2. Hit ESC when the OS boots up
3. Choose to boot into Single User Mode (option 4)
4. Select the default shell (/bin/sh)
5. When the machine is booted up and you see the prompt, enter:
* mount -u /
* mount -a
6. Type passwd to reset the password
7. Enter the new password and confirm it
8. Type reboot to reboot the machine (or press the shutdown button to reboot)

Web services server on PHP

The easiest and the most portable solution for a web service server is a NuSOAP library.
It’s VERY useful when one has nothing but an FTP access to a remote hosting website.
All you need is just copy-paste the library and it works.

So… let’s proceed to create the simplest web server script.
It will just accept String value and return String value (that is modified based on the accepted value).

1. Create a folder named “soap_test” (or whatever …) within your remote website.
Copy-paste “lib” into that folder and rename it to “soap_lib” (or whatever…).
“Lib” is taken from here:
http://sourceforge.net/project/showfiles.php?group_id=57663
(don’t worry, there is just one lib, so you shouldn’t miss it)

2. Within the “soap_test” folder create the file named server.php (again, or whatever you want) and start coding:

3. Include the library and a namespace:
require_once(“soap_lib/nusoap.php”);
$namespace=”http://www.examplesite.com/soap_test“;

4. Some settings:
$server = new soap_server();
$server->configureWSDL(“soap_test”, $namespace);
$server->wsdl->schemaTargetNamespace = $namespace;

5. Declare the function and describe what (arguments) it will accept and return:
$server->register(‘ReturnConfirmNumber’,
array(‘amount’ => ‘xsd:string’),
array(‘return’ => ‘xsd:string’),
$namespace);

6. Write the function itself:
function ReturnConfirmNumber($amount){
$result=$amount . “_this_was_appended_by_server!”;
return new soapval(‘return’,’xsd:string’,$result);
}

7. Finally make a lazy server do what it was born for:
$server->service($HTTP_RAW_POST_DATA);
?>

8. Now time to test it, go to:
http://www.examplesite.com/soap_test/server.php?wsdl

Here you should see some XML file guts… if you see them! You are done!
Congratulations! … let’s go further >>>

To accept more input parameters add value pairs within the first array and separate them by comma.
Ex:
array(‘name’ => ‘xsd:string’, ‘company’ => ‘xsd:string’, ‘initialname’ => ‘xsd:string’ ),

Sources used:
http://webservices.xml.com/lpt/a/1388

To consume web services in ASP.NET refer to “web programming” -> ASP (.NET) -> Web services client on VB.NET

How to install PHP on Windows

Installing PHP >= 4.3.1 & 4.1 on Windows 2000 IIS Server

Windows PHP Installation (from the WebSite)

1)       Download the full PHP windows binaries from http://www.php.net. Do NOT use the small installer. Extract the ZIP to c:\php\.
2)       Copy the php.ini-recommended to c:\winnt\php.ini.
3)       Copy php.exe, php4ts.dll, & php4ts.lib to c:\winnt\system32.
4)       Copy the entire contents of c:\php\dlls to c:\winnt\system32.
5)       In IIS, add PHP as an application mapping .php to “c:\php\php.exe %s %s” (minus the quotes, and note the double %s).
6)       Be sure your IIS user (I_USR_xxxxx) has read and execute privileges on c:\php\ and all subfolders.
7)       Edit your c:\winnt\php.ini and be sure the following line is in it.

cgi.force_redirect = 0

MY OWN METHOD:

1. Download binary… the bigger file
2. copy paste php.ini to C:/windows
– must change : extension_dir = “C:\php\extensions\”
– might change: include_path = “.;c:\php\includes”
– might change: extension=php_curl.dll (remove ; in front of line)
3. copy php4ts.lib, php4ts.dll, php.exe to windows\system32
4. copy all files withing dlls into windows\system32
5. make sure php directory has access to “I_USR xxx” enabled
6. in IIS, computer name->properties->Internet Information Services-> WWWService-> Edit
– home page-> settings->add .php (c:\php\isapi\php4isapi.dll)
– Isapi FIlters-> add-> PHP (c:\php\isapi\php4isapi.dll)
7. might do : make necessary directory Public Website..

8. test… <? phpinfo();?>

also check this:

How To Install PHP on IIS 6.0

http://www.webpronews.com/expertarticles/2006/06/19/installing-php-on-iis-windows-xp-pro
http://www.php.net/install.windows

Installing PHP >= 4.3.1 & 4.1 on Windows 2000 IIS Server

 

Windows PHP Installation (from the WebSite)

 

1)       Download the full PHP windows binaries from http://www.php.net. Do NOT use the small installer. Extract the ZIP to c:\php\.

2)       Copy the php.ini-recommended to c:\winnt\php.ini.

3)       Copy php.exe, php4ts.dll, & php4ts.lib to c:\winnt\system32.

4)       Copy the entire contents of c:\php\dlls to c:\winnt\system32.

5)       In IIS, add PHP as an application mapping .php to “c:\php\php.exe %s %s” (minus the quotes, and note the double %s).

6)       Be sure your IIS user (I_USR_xxxxx) has read and execute privileges on c:\php\ and all subfolders.

7)       Edit your c:\winnt\php.ini and be sure the following line is in it.

 

cgi.force_redirect = 0

 

MY OWN METHOD:

 

1. Download binary… the bigger file

2. copy paste php.ini to C:/windows

– must change : extension_dir = “C:\php\extensions\”

– might change: include_path = “.;c:\php\includes”

– might change: extension=php_curl.dll (remove ; in front of line)

3. copy php4ts.lib, php4ts.dll, php.exe to windows\system32

4. copy all files withing dlls into windows\system32

5. make sure php directory has access to “I_USR xxx” enabled

6. in IIS, computer name->properties->Internet Information Services-> WWWService-> Edit

– home page-> settings->add .php (c:\php\isapi\php4isapi.dll)

– Isapi FIlters-> add-> PHP (c:\php\isapi\php4isapi.dll)

7. might do : make necessary directory Public Website..

 

8. test… <? phpinfo();?>

 

also check this:

http://www.iisadmin.co.uk/?p=4

http://www.webpronews.com/expertarticles/2006/06/19/installing-php-on-iis-windows-xp-pro

http://www.php.net/install.windows

 

PHP does not connect to MSSQL 2005 (but mssql_connect works)

Error:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: NOMADS_TOSHIBA\MSSQL2005 in C:\WebServers\home\localhost\www\salarymanager\includes\system\db.inc.php on line 20

Solution:

Download file: how_to_make_PHP_work_with_MSSQL.rar (couldn’t upload file here, please email me, I will send them)

Microsoft SQL Server 2005 and Vista.

The following steps enabled MSSQL 2005 support on Vista Home Permium.
(native drivers, not odbc which works out-of-the-box)

1) Place ntwdblib.dll in C:\Windows\System32
2) Place php_mssql.dll in C:\Windows\System32
(I gave IUSR full access to these files, maybe read is enough)

3) uncomment php_mssql.dll in php.ini

4) Changed my default SQLSERVER 2005 install so it accepts named pipes.
start -> Sql server surface area configuration ->
surface area configuration for services and connections->
MSSQLXXX-> database engine -> remote connections -> using both TCP/IP and named pipes

5) reboot.

After that I could use the mssql_* functions.

Hope that helps. I guess same applies to Windows 7

PDFLib – Macro has odd number of elements

macro = { H1 {fontname=Helvetica-Condensed fontsize=5 leading=7 alignment=left horizscaling=100 encoding=winansi embedding=true
fillcolor={ spotname {PANTONE 423 CVU} 1 }}” & _
“H2 {fontname=Helvetica-Condensed fontsize=5 leading=7 alignment=left
horizscaling=100 encoding=winansi embedding=true
fillcolor={cmyk 1 1 1 1}}” & _
“H3 {fontname=Bembo fontsize=6 leading=8 alignment=left horizscaling=100
encoding=winansi embedding=true fillcolor={cmyk 1 1 1 1}}” & _
“H4 {fontname=Bembo fontsize=5 leading=7 alignment=left horizscaling=100
encoding=winansi embedding=true fillcolor={ spotname {PANTONE 423 CVU} 1 }} }”

should be converted to

macro = { H1 {fontname=Helvetica-Condensed fontsize=5 leading=7 alignment=left horizscaling=100 encoding=winansi embedding=true
fillcolor={ spotname {PANTONE 423 CVU} 1 }}” & _
” H2 {fontname=Helvetica-Condensed fontsize=5 leading=7 alignment=left
horizscaling=100 encoding=winansi embedding=true
fillcolor={cmyk 1 1 1 1}}” & _
” H3 {fontname=Bembo fontsize=6 leading=8 alignment=left horizscaling=100
encoding=winansi embedding=true fillcolor={cmyk 1 1 1 1}}” & _
” H4 {fontname=Bembo fontsize=5 leading=7 alignment=left horizscaling=100
encoding=winansi embedding=true fillcolor={ spotname {PANTONE 423 CVU} 1 }} }”

notice space between H and “