Tag: ASP.NET

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.

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>