Getting an error in visualbasic.dll

  • Thread starter Thread starter Cybert
  • Start date Start date
C

Cybert

I just installed Microsoft Visual Basic .NET and wrote a very simple program
that references a .tlb file called "Wilbur". The first time I ran the
program below everything worked fine. But subsequent attempts to run it are
causing the following error:

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in microsoft.visualbasic.dll

I've contacted the author of Wilbur and he said that he's never tested his
program within the .NET framework. His program works fine under older
versions of VB so I'm wondering how the .NET framework is different. I know
it's not much to go on, but based on the code below (which has a few very
obvious problems that I'll correct tomorrow) is there ANYTHING that sticks
out as a potential .NET issue? Maybe I'm starting the search too soon after
the Update... I'll try adding in a small delay. Thanks for any
suggestions.

NOTE: I'm a game designer and I'm trying to use Wilbur to write a little
search program. I'm obviously NOT a programmer, but this is a very simple
tool that will save me a TON of time every day if I can get it working.

------------------ (BUTTON CLICK EVENT ------------------

Dim Wilbur As Object
Dim bIndexLoaded
'wilbur and bIndexLoaded are global
'if an index is already open, then close it
If bIndexLoaded Then
Wilbur.Quit()
bIndexLoaded = False
End If
Wilbur = CreateObject("Wilbur.FileIndex")
bIndexLoaded = True
If Not Wilbur.OpenIndex("C:\TestWilburIndex.Wil") Then
MsgBox("Could not load index")
End If

Wilbur.Update(900000)

Dim searchResults As Object
Dim search2 As Object
' get the list of files containing the phrase entered
' in the Text1 field
searchResults = Wilbur.SearchFor("test")
' Extract the names from the list and use them
' to fill a list box
Dim bResult As Boolean
Dim nCount As Integer
nCount = 0
bResult = searchResults.setToStart
While bResult
Dim lastMod As Date
lastMod = searchResults.getModifiedDate
List1.Items.Add(searchResults.getPath)
bResult = searchResults.setToNext
nCount = nCount + 1
End While

---------------------------------------------------------------
 
Hi Cybert,

Are you including this at the top of the class code (above everything in the
class):
Imports System.Runtime.InteropServices

HTH,

Bernie Yaeger
 
Bernie Yaeger said:
Are you including this at the top of the class code (above everything in the
class):
Imports System.Runtime.InteropServices

I thought the OP reported about a runtime exception.
 
No, I didn't include that in the class code. Until yesterday I wasn't even
sure what .NET was... though I have a bit of experience with VBA and VB5.

Do you think this would help fix my error? (Or are you suggesting that this
is what might be CAUSING my error?)

-- John

Bernie Yaeger said:
Hi Cybert,

Are you including this at the top of the class code (above everything in the
class):
Imports System.Runtime.InteropServices

HTH,

Bernie Yaeger
 
Hi Cybert,

Well, it might be causing at least part of the error. You have to include
certain 'imports' statements in order to utilize certain services, and you
are using interop services when you use 'create object'.

Add it, as I indicated, and then let us know if you encounter additional
errors.

Bernie

Cybert said:
No, I didn't include that in the class code. Until yesterday I wasn't
even
sure what .NET was... though I have a bit of experience with VBA and VB5.

Do you think this would help fix my error? (Or are you suggesting that
this
is what might be CAUSING my error?)

-- John
 
Hi Herfried,

Well, it did, but he should have the import statement in his code, so let's
start the correction there.

Bernie
 
Well, it might be causing at least part of the error. You have to include
certain 'imports' statements in order to utilize certain services, and you
are using interop services when you use 'create object'.

Well - that's not entirely true. Although the interop services come into
play, everything is handled by the framework itself. The CreateObject
Function is part of the Microsoft.VisualBasic namespace and that's the only
one required - the System.Runtime.InteropServices namespace is not required
and I don't think that's the reason for the error mentioned by the OP.


Imran.
 
Hi Imran,

I stand corrected - you are right. Then, Cybert, I don't know what is
causing your error. Wilbur may be an activex control or a standard vb .exe;
it should be tested by the developer in the .net environment.

Bernie
 
Cybert,
What is the complete text of the COMException?

Which line specifically is the COMException happening on?

You can put a Try/Catch around your routine to answer the above two
questions:

Try
Dim Wilbur As Object
Dim bIndexLoaded ....
nCount = nCount + 1
End While
Catch ex As Exception
Debug.WriteLine("--- the exception begins ---")
Debug.WriteLine(ex)
Debug.WriteLine("--- the exception ends ---")
MessageBox.Show(ex, Application.ProductName)
End Catch

Within your output window you should see the text of the exception, so you
don't need to type what the Message Box is showing you...

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top