.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

System.IO.FileNotFoundException in System.Windows.Forms.dll

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
3738 Views, 6 Replies

System.IO.FileNotFoundException in System.Windows.Forms.dll

When I run the B3 event I encounter the exception. If I remove the Using statement it will run through the listbox items printing them to the screen. As far as I can tell all of the necassary refernces have been added acmgd.dll, acdbmg.dll, 2010 18.0 type lib., and I have included these Imports..
Imports ADOX
Imports Autodesk
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports System
Imports System.Collections.Generic
Imports System.Data.OleDb
Imports System.Diagnostics
Imports System.Diagnostics.Stopwatch
Imports System.IO
Imports System.MarshalByRefObject
Imports System.Runtime.InteropServices
Imports System.String
Imports System.Text
Imports System.Threading
Imports System.Windows.Forms
Imports System.Windows.Forms.Application

Private Sub B3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B3.Click
Dim i As Integer

stopWatch.Start()
Timer1.Enabled = True
For i = 0 To ListBox1.Items.Count - 1
ListBox1.TopIndex = i
ListBox1.SetSelected(i, True)
'Debug.Print(MyAppPath & "\" & ListBox1.Items(i).ToString)
DoEvents()
Using acDb As Database = New Database(False, True)
acDb.ReadDwgFile(MyAppPath & "\" & ListBox1.Items(i).ToString, System.IO.FileShare.Read, False, "")
End Using
ListBox1.SetSelected(i, False)
DoEvents()
Next i
Timer1.Enabled = False
stopWatch.Stop()

End Sub

Throws this exception..
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Windows.Forms.dll
Additional information: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I have been searching the Groups with little success, I have a VB6 app. that I am working on getting into .NET and this is the basic step to cycle through each file and extract the data stored within the EED out to an Access database.

Thanks
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

> {quote:title=Strut78 wrote:}{quote}
> acDb.ReadDwgFile(MyAppPath & "\" & ListBox1.Items(i).ToString, System.IO.FileShare.Read, False, "")

I believe that is the line that causes the error. Make sure you check that the file exists before trying to open it. If that doesn't fix your error, could you do a step by step debugging and post which line causes the error?
Message 3 of 7
Anonymous
in reply to: Anonymous

Like I said I take the Using statement out it runs fine. The files are there because without the Using statement they will all print to the screen and the Listbox moves through the list like the code indicates. Something with the Using statement..I don't know what..but I cannot figure it out. I am at a total loss here. If I put a breakpoint on stopwatch.start() and run it, it never gets to the breakpoint. The error is thrown when the event is triggered with the Using statement in the code. If I take the Using statement out it runs fine and it stops at the breakpoint. This runs so much smoother and cleaner in VB6.
Thanks
Message 4 of 7
Anonymous
in reply to: Anonymous

Also I am getting this in the immediate window..
SNACNP Attached! "D:\Projects.Net\Extract\Extract\Extract\bin\Debug\Extract.exe" SNACNP::NPGetCaps::WNNC_NET_TYPE
SNACNP::NPGetCaps::WNNC_USER
SNACNP::NPGetCaps::WNNC_CONNECTION
SNACNP::NPGetCaps::WNNC_ENUMERATION
SNACNP::NPGetCaps::WNNC_ADMIN
SNACNP::NPGetCaps::WNNC_DIALOG
SNACNP::NPGetCaps::WNNC_START
First-chance exception at 0x7c812afb in Extract.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x7c812afb in Extract.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x7c812afb in Extract.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..

Thanks again..
Message 5 of 7
Anonymous
in reply to: Anonymous

Try instantiating the database rather than using the using statement.
Message 6 of 7
_gile
in reply to: Anonymous

Hi

doing:
{code}Using acDb As Database = New Database(False, True)
acDb.ReadDwgFile(MyAppPath & "\" & ListBox1.Items(i).ToString, System.IO.FileShare.Read, False, "")
End Using{code}
you call acDB.Dispose() at the end of the Using block, so you can't use acDB anymore...


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 7 of 7
Anonymous
in reply to: Anonymous

Do you undertstand what 'Using...End Using' is?

When you use it, the object is only usable within the Using block, and
once you reach End Using, the object is Disposed and can no longer
be used.

What point is there to wrapping a call to ReadDwgFile() in a Using
block, and doing nothing else with the Database?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6337067@discussion.autodesk.com...
Like I said I take the Using statement out it runs fine. The files are there
because without the Using statement they will all print to the screen and the
Listbox moves through the list like the code indicates. Something with the Using
statement..I don't know what..but I cannot figure it out. I am at a total loss
here. If I put a breakpoint on stopwatch.start() and run it, it never gets to
the breakpoint. The error is thrown when the event is triggered with the Using
statement in the code. If I take the Using statement out it runs fine and it
stops at the breakpoint. This runs so much smoother and cleaner in VB6.
Thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost