?
Solved

Get 32bit asp.net to work with 64bit

Posted on 2010-01-12
9
Medium Priority
?
701 Views
Last Modified: 2012-05-08
I have an application that reads excel files, and after an upgrade from 32bit to 64bit I get these errors when trying to get the excel file.

Diagnostic Data Retrieving the COM class factory for component with CLSID {0002E559-0000-0000-C000-000000000046} failed due to the following error: 80040154.

And

The "SendUsing" configuration value is invalid
Private Sub btnFull_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFull.Click
            Dim sFormat As String
            Try
                sFormat = rblReportType.SelectedValue() 'check to see whether its CSV or Excel. If Empty we default to excel
                If sFormat = "" Then
                    sFormat = "Excel"
                End If

                PopReport("Full", sFormat)
                trDownload.Visible = True   'make download row visible
                trSep1.Visible = True
                '        btnFull.Enabled = False 'do not allow creation of another report until the one generated is downloaded.
            Catch excException As Exception

                If Not TypeOf excException.GetBaseException Is System.Threading.ThreadAbortException Then

                    Me.cvGeneral.ErrorMessage = Session("GenErrorText") ' Errors.UserFriendlyMessage(excException, "EN")
                    Errors.EmailDiagnostics(excException, "RegisterforEvent Admin Preview IntroPage")

                    Me.cvGeneral.IsValid = False
                End If

            End Try
        End Sub


Private Sub PopReport(ByVal sType As String, Optional ByVal sFormat As String = "")
            'I get all the data for the current event
            'I format it into XML so I can deal easier with records
            'i create and xmlreader which holds the xml
            'the xml reader is then used to populate a dataset making the data easier to deal with.
            'if summary is choosen the dataset is
            'used  as datasource for a datagrid
            'if excel or csv is choosen the ds is passed to relevant function which processes it into the desired format.

            'sType determines if we want all data or only summary
            'I check the strXML if it has data each time
            'and proceed only if there is data

            Dim strXML As String 'holds the XML markup returned from function
            Dim xmlrder As XmlTextReader
            Dim ds As New DataSet
            '      Dim dt As New DataTable
            Try
                Select Case sType.ToUpper
                    Case "FULL"

                        Select Case sFormat.ToUpper
                            Case "EXCEL"
                                'get the event data in XML format
                                strXML = GetFullReport(Session("RegEventID"))
                                If strXML.Length > 0 Then
                                    xmlrder = New XmlTextReader(strXML, System.Xml.XmlNodeType.Document, Nothing)
                                    xmlrder.ReadOuterXml() 'xml in to xmlreader

                                    ds.ReadXml(xmlrder) 'put data in dataset

                                    CreateExcel(ds)


                                End If
                                'Case "EXCELCC"
                                'get the event data in XML format with CreditCard
                                'strXML = GetFullReportCC(Session("RegEventID"))
                                'If strXML.Length > 0 Then
                                'xmlrder = New XmlTextReader(strXML, System.Xml.XmlNodeType.Document, Nothing)
                                'xmlrder.ReadOuterXml() 'xml in to xmlreader

                                'ds.ReadXml(xmlrder) 'put data in dataset

                                'CreateExcel(ds)


                                'End If
                            Case "CSV"
                                strXML = GetFullReportCC(Session("RegEventID"))
                                If strXML.Length > 0 Then
                                    xmlrder = New XmlTextReader(strXML, System.Xml.XmlNodeType.Document, Nothing)
                                    xmlrder.ReadOuterXml()

                                    ds.ReadXml(xmlrder)  'put data in dataset
                                    CreateCSVFile(ds)
                                    ' TextBox1.Text = strXML 'testing only
                                End If
                        End Select
                        'no longer in use but i leave it here in case
                    Case "SUMMARY"
                        Select Case sFormat.ToUpper
                            Case "EXCEL"
                                strXML = GetSummaryReport(Session("RegEventID"))
                                If strXML.Length > 0 Then
                                    xmlrder = New XmlTextReader(strXML, System.Xml.XmlNodeType.Document, Nothing)
                                    xmlrder.ReadOuterXml()

                                    ds.ReadXml(xmlrder)  'put data in dataset
                                    CreateExcel(ds)
                                End If
                                'Case "EXCELCC"
                                'strXML = GetSummaryReport(Session("RegEventID"))
                                'If strXML.Length > 0 Then
                                'xmlrder = New XmlTextReader(strXML, System.Xml.XmlNodeType.Document, Nothing)
                                'xmlrder.ReadOuterXml()

                                'ds.ReadXml(xmlrder)  'put data in dataset
                                'CreateExcel(ds)
                                'End If
                            Case "CSV"
                                strXML = GetSummaryReport(Session("RegEventID"))
                                If strXML.Length > 0 Then
                                    xmlrder = New XmlTextReader(strXML, System.Xml.XmlNodeType.Document, Nothing)
                                    xmlrder.ReadOuterXml()

                                    ds.ReadXml(xmlrder)  'put data in dataset
                                    CreateCSVFile(ds)
                                End If
                        End Select

                End Select

                '    ds.Clear()
                '    ds.Dispose()
                'ds = Nothing
            Catch excException As Exception
                If Not TypeOf excException.GetBaseException Is System.Threading.ThreadAbortException Then

                    Me.cvGeneral.ErrorMessage = Errors.UserFriendlyMessage(excException, "EN") 'Session("GenErrorText") ' 
                    Errors.EmailDiagnostics(excException, "RegisterforEvent Admin Preview IntroPage")

                    Me.cvGeneral.IsValid = False
                End If

            Finally
                xmlrder.Close()
                ds.Clear()
                ds.Dispose()
                ds = Nothing
            End Try


        End Sub



Public Sub CreateExcel(ByVal ds As DataSet)

            Dim xlsExport As OWC11.SpreadsheetClass = New OWC11.SpreadsheetClass

            Dim numbercols As Integer
            Dim myRow As DataRow
            Dim myCol As DataColumn
            Dim intRowCounter As Integer = 1
            Dim intColCounter As Integer
            Dim strOtherPath As String
            Dim strFilename As String
            Dim strDateTime As String
            Dim sEventPath As String

            Try



                strDateTime = Format(Date.Now, "yyyyMMMddhhmm") 'used in excel file name

                sEventPath = "Ev" & Session("RegEventid")
                strOtherPath = Request.ServerVariables.Item("APPL_PHYSICAL_PATH")
                strOtherPath = strOtherPath & "EventImages\" & sEventPath & "\"


                'handle of the directory to save report file in
                'if don't exist I need to create it.

                Dim di As DirectoryInfo
                di = New DirectoryInfo(strOtherPath)
                If Not di.Exists Then
                    di.Create()
                End If

                Dim dtExcel As DataTable = ds.Tables(0)

                Dim currRows() As DataRow = dtExcel.Select(Nothing, Nothing, DataViewRowState.CurrentRows)

                If (currRows.Length < 1) Then
                    'No Current Rows Found
                Else
                    'rows found
                    'write the column names to the spreadsheet
                    intColCounter = 1
                    intRowCounter = 1


                    For Each myCol In dtExcel.Columns
                        xlsExport.ActiveSheet.Cells(intRowCounter, intColCounter) = myCol.ColumnName.ToString
                        intColCounter = intColCounter + 1
                    Next

                    intRowCounter = intRowCounter + 1 'go to second row for writing data
                    Dim s As String
                    'iterate through the columns in each row and write the contents to a table cell
                    For Each myRow In dtExcel.Rows
                        intColCounter = 1
                        For Each myCol In dtExcel.Columns
                            s = myRow(myCol).ToString()
                            xlsExport.ActiveSheet.Cells(intRowCounter, intColCounter) = "'" & s.Replace(vbCrLf, " ")
                            intColCounter = intColCounter + 1
                        Next
                        intRowCounter = intRowCounter + 1
                    Next
                End If


                strFilename = Session("RegeventName")
                strFilename = strFilename & strDateTime.ToUpper & ".xls"
                lblFileName.Text = strFilename

                'Export the spreadsheet
                ' xlsExport.ActiveSheet.Application.Export(strOtherPath & strFilename, OWC11.SheetExportActionEnum.ssExportActionNone)
                xlsExport.ActiveSheet.Application.Export(strOtherPath & strFilename, OWC11.SheetExportActionEnum.ssExportActionNone, OWC11.SheetExportFormat.ssExportXMLSpreadsheet)

            Catch excException As Exception
                If Not TypeOf excException.GetBaseException Is System.Threading.ThreadAbortException Then


                    Me.cvGeneral.ErrorMessage = Session("GenErrorText") ' Errors.UserFriendlyMessage(excException, "EN")
                    Errors.EmailDiagnostics(excException, "RegisterforEvent Admin Preview IntroPage")

                    Me.cvGeneral.IsValid = False
                End If

            Finally
                myRow = Nothing
                myCol = Nothing

            End Try
        End Sub

Open in new window

0
Comment
Question by:mattegol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 13

Expert Comment

by:zadeveloper
ID: 26293152
This is because the com object you are using is 32 bit.
 
So whats happening is: You have compiled to "Any CPU " or to x64 - this compiles ok, because VS does not know that the com object is 32 bit. When your app runs on a 64bit box it runs in 64 bit mode. Then when you try and call your com object the com trys to run at 32 bit - the architecture does not allow this.
 
You have a few options:
1. Get a 64 bit or "Any CPU" version of your com object (in my case this was not possible as the developers have not yet released one)
2. Right click your project file in vs - > properties and in the build tab change the config to x86 ( This will not affect running on a 64 bit box - it will still run - unless your app uses more than 4gb of ram)
 
What you need to do is right click on your po
0
 
LVL 11

Expert Comment

by:princeatapi
ID: 26293161
Have you Enabled the "Enable 32 Bit Application " in your Application Pool ?
0
 
LVL 13

Expert Comment

by:zadeveloper
ID: 26293204
BTW:
if you are running this on IIS7 - you will need to select : enable 32-bit application in the application pool.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mattegol
ID: 26293779
Am I at the right place for option 2?
untitled.bmp
0
 
LVL 13

Expert Comment

by:zadeveloper
ID: 26294010
Go to iis7 above websites is a application pool node. Select deafault app pool and right click for advanced properties. Then locate the setting : enable 32-bit applications
0
 
LVL 11

Expert Comment

by:princeatapi
ID: 26294151
Open the IIS Manager by executing 'inetmgr' command in run window
Expand the Node (Computer Name )
you will get "Application Pool" where you can get the information about all the pools

Locate your Application from the WebSites list there you can find the "Application Pool" for your Application select it and enable the Property as given in this link
http://blog.davidyack.com/journal/2008/5/19/iis7-and-32bit-applications.html
0
 

Author Comment

by:mattegol
ID: 26294170
That one is already fixed, I meant for option 2

2. Right click your project file in vs - > properties and in the build tab change the config to x86 ( This will not affect running on a 64 bit box - it will still run - unless your app uses more than 4gb of ram)

0
 
LVL 11

Expert Comment

by:princeatapi
ID: 26294241
Have you enabled the 32 bit Applicaion ?
0
 
LVL 11

Accepted Solution

by:
princeatapi earned 2000 total points
ID: 26294287
If Still not working then you must ensure essential Permission to that COM Object .
Still If It doesn't work then go to the properties of the COM Object -> Identity -> Try With Either Interactive User / Launching User ..
Sure your issues will be fixed
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question