
brazilnut52
Members-
Posts
17 -
Joined
-
Last visited
Personal Information
-
.NET Preferred Language
Visual Basic
brazilnut52's Achievements
Newbie (1/14)
0
Reputation
-
.NET Interop for MSXML6 on IIS 6 - Error: COM not valid or registered
brazilnut52 replied to brazilnut52's topic in ASP.NET
Because I am loading an ADODB recordset from an XML string that was created with the following: Recordset.Save(adodbXML, ADODB.PersistFormatEnum.adPersistXML) Here is how I convert the XML string back to an ADODB.Recordset Dim oXML As New DOMDocument40 ' xml document object Dim rst As New ADODB.Recordset ' ADODB recordset Dim stream As New ADODB.Stream ' ADODB stream Call oXML.loadXML(adodbXML) ' load saved xml into DOM doc stream.Open() : oXML.save(stream) ' open a stream and load xml into stream stream.Position = 0 : rst.Open(stream) ' open recordset from xml stream stream.Close() rst.Close() oXML = Nothing stream = Nothing rst = Nothing If you can tell me how to avoid this, I would love it. -
I am having some difficulty deploying a web service I have created in VB .NET. The application works fine on my development PC and on Server1 (with IIS 5.0). However, the application gives an error when invoked on Server2 (IIS 6.0). After some investigation I have discovered that the error is related to the MSXML libraries. I have only one web method called �Hello World� in the web service. The �Hello World� service simply returns an XML string. Server1 correctly returns: <?xml version="1.0" encoding="utf-8" ?> <string xmlns="testObjects">Hello World</string> Server2 returns this error: COM object with CLSID {88D969C0-F192-11D4-A65F-0040963251E5} is either not valid or not registered. This is the entire code in the web service: Imports System.Web.Services <System.Web.Services.WebService(Namespace:="testObjects")> _ Public Class Service1 Inherits System.Web.Services.WebService Public Sub New() MyBase.New() InitializeComponent() End Sub Private components As System.ComponentModel.IContainer <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() components = New System.ComponentModel.Container End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub <WebMethod()> _ Public Function HelloWorld() As String Dim x As New Interop.CF.clsPort Dim y As New Interop.INC.MathActiveX Dim z As New Interop.MSXML6.DOMDocument40 Return "Hello World" End Function End Class Notice all I am doing in the WebMethod HelloWorld() is creating a series of objects. The first two are COM Interop libraries (a .NET Wrapper for COM objects) based off of two objects that on of my developers created in classic VB CF.dll and INC.dll. Both of these COM DLLs are registered on both Server1 and Server2. I know this because these two lines of code execute no problem, so all is good with the underlying DLLs that these wrappers are calling. However, when I go to create �z� I get the error I pasted above. Interop.MSXML6 is a wrapper created from MSXML6.DLL, the most recent version of MSXML from Microsoft. I installed this version on both servers yesterday. Also, all of these Interop assemblies are strong name assemblies, meaning when I used the TLBIMP utility to create them I specified a �Strong Name Key File�. I have tried using Interops based on MSXML3, MSXML4, MSXML5, and MSXML6. All three work fine on Server1 and none have worked on Server2. Also, I have been getting the exact same error since the beginning. Here�s the real kicker. As I moved down version after version, still the same result Server1, good, Server2, bad. HOWEVER, when I created an Interop from MSXML2.DLL the app ran correctly on Server2. GREAT! I thought, BUT when I tested it on Server1, same error I had been getting gone Server2. So this is where I am. Remember this app works great on my development server and Server1. So it seems to me that the question is �What�s the difference?�. I would say just about everything since one box has IIS 5 and the other IIS 6. I hope this information points you in the right direction. I have been working on this problem for over 2 weeks now. Any assistance would be greatly appreciated. Thank you.
-
I need help creating an Sql Server System DSN programmatically in VB .NET. I am writing a short install procedure for an app and it requires a few data sources to be setup. I would like to avoid having the clients setup the DSN themselves. I have found several code snippets on the net but none address a few configuration requirements I have. When I ADD the DSN manually I: Select Driver "SQL Server" Give Name Give Description Select Server Select "SQL Authentication" (given user name and password) Select "Client configuration" -> uncheck "dynamically determine port" and type a number. Is there anyway I can programmatically create and configure a DSN with these settings required? I need a little guidance. Thanks
-
Say I have a .NET project to compile to a class library (.DLL). Here is all the code in the library: Public Class GetString Public Function GetTestString() As String Return "Test String" End Function End Class In the build options, I have selected the library to be Registered for COM Interop. After compiling the project, I get both GetString.dll and GetString.tlb in the \bin folder. Now in Excel I open a new book. Go to the Vb Editor and add a reference to the GetString.tlb file in the \bin folder of my .NET solution. I then add VBA module and I put the following code: Public Sub getStr() Dim str As New GetString.GetString Dim ws As Worksheet Set ws = ActiveSheet ws.Range("A1").Value = str.GetTestString() End Sub Compile -> Save. When I run the macro, everything works perfect! The string is successfully placed in the appropriate cell. But NOW the part that has confused and frustrated me for a long time. I now take the Excel worksheet, the GetString.dll, and the GetString.tlb file and put them on another computer. The other computer does have .NET installed by the way. When I run the macro, I get the following error: Run-time error '429': ActiveX component can't create the object. This problem is a much more simplified version of what I am actually dealing with. But If someone could PLEASE tell me the exact steps to take to get this macro to work on a PC other than my own development PC, I would be very greatful. Thanks, brazilnut
-
Use COM object from Excel VBA - made in .NET "ActiveX component can't create object" I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better. I have created a simple COM DLL in .NET by using the COM class template and by setting output to a type library (DLL). All the object does is return a string value. At this point I have not checked the option to register for COM interop in Visual Studio. So I go into Excel (where I want to use the object). Go to VB Editor and Tools -> References and to Add Reference. I browse until I find the \bin directory of the project. Select the .dll file outputted by the program. Then click open -> I get the message "Can't add reference to the specified file." So here is my first question: Why not? So then I go to my project in Visual Studio. Highlight the project -> click properties ->go to Build -> and check "Register for COM interop" -> then I rebuild my solution. After this build there is another file in the \bin directory with the same name as the .dll but has the extension .tlb (Type Library). So I go back into Excel. Go to VB Editor -> Tools -> References and to Add Reference. I browse until I find the \bin directory of the project. This time however I select the .tlb file outputted by the program. Then click open -> I don�t get an error message so this is good. So here is my second question: Why does the .tlb work and not the .dll at this point? Now after this step. I create the object in VBA code. Compile and run the macro and sure enough it returns the string and puts in the right cell. Great! But wait. Now many more people need this object to work with Excel. So I copy the Excel Workbook and everything in the \bin directory from my project to another person�s computer. Then I open the Excel workbook -> then to VB Editor -> References to double check the path to the .tlb file -> (then compile and save for peace of mind). But here is the big problem... when I run the macro on another person's computer I get the message "ActiveX component can't create object." And I get this at the line where I say: Set testObj = New Object. My ideas... could it be that I am an Admin on my PC but not the other? If so, how do I get around this. Or is Visual Studio doing an extra step in the compile/build process that I�m not replicating on the other PC? Does it need to be an global assembly? Also, .NET is installed on the other PC and I have tried to register the .DLL, but this is unsuccessful as well? I guess that is another question: why? If someone could help me out here I would be very grateful. I have been trying to figure out a solution for a long time. I just don�t understand why everything works fine on my PC but won't run on another. Thanks for being patient. brazilnut
-
Hi. Let me explain the setup. I am using Visual Studio .NET to develop a sort of add-in (COM class) for Excel called SQLAddin. It basically queries a SQL server and pulls in data. Now within my Visual Studio Project, the SQLAddin references a compiled COM object built with Visual Studio 6.0 called SQLOld.dll. When I complie the project I get the following files in my \bin directory: SQLAddin.dll SQLAddin.pdb SQLAddin.tlb Interop.SQLOld.dll Within Visual Studio .NET I have set the project properties to "Register for COM Interop". The reason why I am mentioning the set up for the development for this project, is that this add-in works great on my computer. The VBA in Excel that accesses the object calls the functions correctly and correctly assigns the return values. BUT when I try to setup and run this Addin on another computer, it does not work. I get the error: Runtime error '429': ActiveX component can't create object. Let me explain my installation procedures for the other computer: To note, the computers I am installing the addin on all have the .NET Framework installed. First I copy over all the files in the \bin directory (as mentioned above) PLUS the actual SQLOld.dll. I also include the Excel file with the references and VBA code complied. So, if I go into Excel run the addin. I get the error. So then I think that perhaps the SQLOld.dll needs to be registered. So I run regsvr32 on the SQLOld.dll. The register succeeds, but when I run the addin again. I get the same error. So why does the addin work on my computer but not anyones else's? My hypothesis is that Visual Studio .NET is doing something behind the scenes when I compile. And I am not doing that on the other machine. Any ideas?? Thanks for you help, brazilnut
-
I am trying to create an array of 2D arrays and dont have the slightest idea of how to start. Does anyone have any code that utilizes an array of 2D arrays. It would be a big help. Thanks, brazilnut
-
Bad variable type in Excel object library
brazilnut52 replied to brazilnut52's topic in Interoperation / Office Integration
bump... -
This is odd I am getting Bad Variable Type exception in the line: oXL.WorksheetFunction.CountA(rng.Rows(i)) = 0 Then However, the line: oXL.WorksheetFunction.Sum(ws.Range(ws.Cells(i, colNumStart), ws.Cells(i, lastCol))) is executed before the first... and it works fine. here are the lines that call the class functions: Dim oSheet As Excel.Worksheet Dim oXL As Excel.Application ' Create Excel objects oXL = New Excel.Application() Dim oWB As Excel.Workbook ' Open file oWB = oXL.Workbooks.Open(fileToFormat) oSheet = oWB.ActiveSheet Dim oGenFuncs As New EAL_Format.generalFormatFunctions(oSheet, oXL) Call oGenFuncs.generalFormat() . . . Call oGenFuncs.GetUsedRange(lastRow, lastCol) the call to oXL.WorksheetFunction works fine in the first call....(though they are different functions one is Sum and the other is CountA...) Have any ideas of why Iam getting the Bad Variable Type error? Also if you have any suggestions for my code in general I would appreciate it. Here is my class: Public Class generalFormatFunctions Private ws As Excel.Worksheet Private oXL As Excel.Application Sub New(ByRef worksheet As Excel.Worksheet, ByRef excel As Excel.Application) ws = worksheet oXL = excel End Sub Public Function generalFormat() ' ' generalFormat Macro ' Macro recorded 1/31/2003 by Andre de Araujo Jorge ' performs general required formating to both income and market value files ' Delete left three and Up 50 and Down 50 cols ws.Columns("A:C").Delete() ws.Columns("E").Delete() ws.Columns("F").Delete() ' Divide all numerical cells by 1000 Dim cellType As Excel.XlCellType Dim pasteType As Excel.XlPasteSpecialOperation Dim pstVals As Excel.XlPasteType Dim numFormat As Excel.XlPasteSpecialOperation pasteType = Excel.XlPasteSpecialOperation.xlPasteSpecialOperationDivide pstVals = Excel.XlPasteType.xlPasteValues cellType = Excel.XlCellType.xlCellTypeConstants ws.Range("J9").Value = 1000 ws.Range("J9").Copy() ws.Range("B:H").SpecialCells(cellType).PasteSpecial(pstVals, pasteType) ws.Range("B:H").SpecialCells(cellType).NumberFormat() = 0 ws.Range("J9").Clear() Call DeleteInvalidRows() End Function Public Function DeleteInvalidRows() Dim colNumStart As Integer = 2 'Dim wsFuncs As Excel.WorksheetFunction 'wsFuncs = New Excel.WorksheetFunction() 'wsFuncs = oXL.WorksheetFunction 'Delete all rows that have 0 sum - assuming numbers start in col 2 Dim lastCol = ws.UsedRange.Columns.Count Dim i As Integer Dim sumTotal As Double For i = ws.UsedRange.Rows.Count To 1 Step -1 If oXL.WorksheetFunction.Sum(ws.Range(ws.Cells(i, colNumStart), ws.Cells(i, lastCol))) = 0 Then ws.Cells(i, 1).EntireRow.Delete() End If Next i End Function Public Function inArray(ByRef stringArray() As String, ByVal searchString As String) As Boolean Dim upperBound As Integer upperBound = UBound(stringArray) Dim i As Integer For i = 0 To upperBound Step 1 If stringArray(i) = searchString Then inArray = True Exit Function End If Next inArray = False End Function Public Function GetUsedRange(ByRef lastRow As Integer, ByRef lastCol As Integer) As Boolean ' ' GetUsedRange Macro ' Macro recorded 3/5/2003 by dearaan ' ' Keyboard Shortcut: Ctrl+u ' 'Assumes that Excel's UsedRange gives at least a superset of the "real" non-null data ' then get the effective range of non-null data Dim s As String, x As Long Dim rng As Excel.Range Dim newUsedRange As Excel.Range Dim r1fixed As Long, c1Fixed As Long Dim r2Fixed As Long, c2Fixed As Long Dim i As Long Dim r1 As Long, c1 As Long Dim r2 As Long, c2 As Long 'Start with Excel's faulty used range rng = ws.UsedRange 'Get bounding cells for Excel's UsedRange 'That is, Cells(r1,c1) to Cells(r2,c2) r1 = rng.Row r2 = rng.Rows.Count + r1 - 1 c1 = rng.Column c2 = rng.Columns.Count + c1 - 1 'Save existing values r1fixed = r1 r2Fixed = r2 c1Fixed = c1 c2Fixed = c2 'Check rows from top down for all blank rows 'if found, shrink rows For i = 1 To r2Fixed - r1fixed + 1 If oXL.WorksheetFunction.CountA(rng.Rows(i)) = 0 Then 'empty row -- reduce r1 = r1 + 1 Else 'nonempty row, get out Exit For End If Next 'Repeat for columns from left to right For i = 1 To c2Fixed - c1Fixed + 1 If oXL.WorksheetFunction.CountA(rng.Columns(i)) = 0 Then c1 = c1 + 1 Else Exit For End If Next 'reset the range rng = ws.Range(ws.Cells(r1, c1), ws.Cells(r2, c2)) 'Start again r1fixed = r1 c1Fixed = c1 r2Fixed = r2 c2Fixed = c2 'do rows from bottom up For i = r2Fixed - r1fixed + 1 To 1 Step -1 If oXL.WorksheetFunction.CountA(rng.Rows(i)) = 0 Then r2 = r2 - 1 Else Exit For End If Next 'repeat for columns fro right to left For i = c2Fixed - c1Fixed + 1 To 1 Step -1 If oXL.WorksheetFunction.CountA(rng.Columns(i)) = 0 Then c2 = c2 - 1 Else Exit For End If Next lastRow = r2 lastCol = c2 End Function End Class [edit]Please use tags [/vb ][/edit][/color]
-
I am trying to envoke the Sum function on a range in VB .NET. I am getting an exception: Object Reference not set to an instance of an object. here is my class: Public Class generalFormatFunctions Private ws As Excel.Worksheet Sub New(ByVal worksheet As Excel.Worksheet) ws = worksheet End Sub Public Function DeleteInvalidRows() Dim colNumStart As Integer = 2 Dim wsFuncs As Excel.WorksheetFunction 'Delete all rows that have 0 sum - assuming numbers start in col 2 Dim lastCol = ws.UsedRange.Columns.Count Dim i As Integer For i = ws.UsedRange.Rows.Count To 1 Step -1 If wsFuncs.Sum(ws.Range(ws.Cells(i, colNumStart), ws.Cells(i, lastCol))) = 0 Then ws.Cells(i, 1).EntireRow.Delete() End If Next i End Function End Class another class invokes this class and passes in a worksheet object. The exception occurs in this line: If wsFuncs.Sum(ws.Range(ws.Cells(i, colNumStart), ws.Cells(i, lastCol))) = 0 Then Any ideas thanks brazilnut
-
when i compile my code i get the name TestingClasses.exe -- this is an old solution name. I have since changed the name but the program still compiles to testingclasses.exe instead of newSolutionName.exe what should i do brazilnut
-
Hello. I am writing an application that has several hardcoded directory paths. I would like to write a configuration utility to write an XML based INI file. This file would be read at the execution of the program and the variables initialized. Does anyone have a link to a good reference or thread. I would really benefit from seeing some code of an actual variable being initialized with data from an external file. Thanks brazilnut
-
I am working on a Windows service that will check my inbox every 15-30min... It will only process certain email. The program will ditinguish these emails by who sent the email. Also some email will have .zip attachments that need to be unzipped and the files moved around. So in a nutshell: How can you program VB .NET to download certain emails to a local drive... and then process attachments. thanks brazilnut
-
Good question. Ideally, this service will run at all times.. even when the user is not logged in. Therefore anytime the service is on and my inbox receives an email, the service is triggered. So I guess I stated my question incorrectly earlier. I actually need the program to interact with the email server. It should be triggered when an email comes to my inbox on the email server. Once I get this figured out I can do more with the actual mail: 1) I will need to unzip attachments 2) parse certain data out of the txt body of the email. Here is the run down.... I get two emails from a company. One email has a zip file that I need to download... extract... then rename and move files on the local system. The other email contains a link to a downloadable pdf file. Normally I would cut and paste the link in a browser window then save the pdf to my local disk. I would like this process to be performed by the application as well. If I could get this done with the service, it would be awesome. I could save about 2+ hrs of work a day. thanks for the reply, brazilnut