Category: Web

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.

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

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

The best data structures to manipulate data manually = DataTable + DataRow + DataView

Here is a simple class that populates GridView control.
This is the best method for doing MANUAL data manipulations.
Code is in C# and VB.NET formats

C#
<%@ Import Namespace="System.Data" %>
<html>
<script language="C#" runat="server">

 string SortField;

 ICollection CreateDataSource() {
 DataTable dt = new DataTable();
 DataRow dr;

 dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
 dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
 dt.Columns.Add(new DataColumn("DateTimeValue", typeof(DateTime)));
 dt.Columns.Add(new DataColumn("BoolValue", typeof(bool)));
 dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));

 for (int i = 0; i < 9; i++) {
 dr = dt.NewRow();

 dr[0] = 9-i;
 dr[1] = "Item " + i.ToString();
 dr[2] = DateTime.Now;
 dr[3] = (i % 2 != 0) ? true : false;
 dr[4] = 1.23 * (i+1);

 dt.Rows.Add(dr);
 }

 DataView dv = new DataView(dt);
 dv.Sort = SortField;
 return dv;
 }

 void Page_Load(Object sender, EventArgs e) {
 if (!IsPostBack) {
 if (SortField == "") {
 SortField = "IntegerValue";
 }    
 BindGrid();
 }    
 }

 void MyDataGrid_Sort(Object sender, DataGridSortCommandEventArgs e) {
 SortField = (string)e.SortExpression;
 BindGrid();
 }

 void BindGrid() {
 MyDataGrid.DataSource = CreateDataSource();
 MyDataGrid.DataBind();
 }

</script>

<body>

 <h3><font face="Verdana">Basic Sorting in DataGrid</font></h3>

 <form runat=server>

 <ASP:DataGrid id="MyDataGrid" runat="server"
 AllowSorting="true"
 OnSortCommand="MyDataGrid_Sort"
 BorderColor="black"
 BorderWidth="1"
 CellPadding="3"
 Font-Name="Verdana"
 Font-Size="8pt"
 HeaderStyle-BackColor="#ccccff"
 HeaderStyle-ForeColor="black"
 />

</form>

</body>
</html>

VB.NET
<%@ Import Namespace="System.Data" %>

<html>
<script language="VB" runat="server">

 Dim SortField As String

 Function CreateDataSource() As ICollection

 Dim dt As DataTable
 Dim dr As DataRow
 Dim i As Integer

 'create a DataTable
 dt = New DataTable
 dt.Columns.Add(New DataColumn("IntegerValue", GetType(Integer)))
 dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
 dt.Columns.Add(New DataColumn("DateTimeValue", GetType(DateTime)))
 dt.Columns.Add(New DataColumn("BoolValue", GetType(Boolean)))
 dt.Columns.Add(new DataColumn("CurrencyValue", GetType(Double)))

 'Make some rows and put some sample data in
 For i = 1 To 9
 dr = dt.NewRow()
 dr(0) = 9-i
 dr(1) = "Item " & i.ToString()
 dr(2) = DateTime.Now.ToShortTimeString
 If (i Mod 2 <> 0) Then
 dr(3) = True
 Else
 dr(3) = False
 End If
 dr(4) = 1.23 * (i + 1)
 'add the row to the datatable
 dt.Rows.Add(dr)
 Next

 'return a DataView to the DataTable
 Dim dv as DataView = New DataView(dt)
 dv.Sort = SortField
 CreateDataSource = dv
 End Function        

 Sub Page_Load(sender As Object, e As EventArgs)
 If Not IsPostBack Then
 If SortField = "" Then
 SortField = "IntegerValue"
 End If   
 BindGrid
 End If
 End Sub

 Sub MyDataGrid_Sort(sender As Object, e As DataGridSortCommandEventArgs)
 SortField = e.SortExpression
 BindGrid
 End Sub

 Sub BindGrid()
 MyDataGrid.DataSource = CreateDataSource()
 MyDataGrid.DataBind
 End Sub

</script>

<body>

 <h3><font face="Verdana">Basic Sorting in DataGrid</font></h3>

 <form runat=server>

 <ASP:DataGrid id="MyDataGrid" runat="server"
 AllowSorting="true"
 OnSortCommand="MyDataGrid_Sort"
 BorderColor="black"
 BorderWidth="1"
 CellPadding="3"
 Font-Name="Verdana"
 Font-Size="8pt"
 HeaderStyle-BackColor="#ccccff"
 HeaderStyle-ForeColor="black"
 />

</form>

</body>
</html>