Newsgroup: it.comp.lang.visual-basic
Titolo: Compilazione e errori.

Salve,
questo sorgente prelevato dal sito comune :
http://www.it-lang-vb.net/download.asp?file=http://www.it-lang-vb.net/Archivio/Sorgenti/waveOut.zip&ID=612
 
mi funziona nell'ide di VB ma non compilato, a qualcuno fa la stessa cosa? 
Da cosa potrebbe dipendere?
Grazie a tutti, Emiliano.
 

 ...
Probabilmente questo progetto usa "Callback" con AddressOf.
Ho avuto lo stesso problema, con un generatore di segnali, ed
ho infine scoperto (vedi documento Microsoft Q198607) che il
progetto deve essere compilato in P-Code e che nella routine
di "Callback" e' necessario evitare l' uso di molte APIs e di
alcune funzioni intrinseche di VB (e.g. Rnd).
Ciao, sperando che quanto sopra possa servirti.
Franco
Web: 
http://www.flanguasco.org
----------------------------------------------------------------------
Q198607 - PRB: Access Violation in VB Run-Time Using AddressOf
PRB: Access Violation in VB Run-Time Using
AddressOf
ID: Q198607
The information in this article applies to:
l Microsoft Visual Basic Learning, Professional, and Enterprise Editions 
for Windows,
version 6.0
SYMPTOMS
When running your Visual Basic application, you may encounter an error 
similar to the
following:
The instruction at 0x660bd3b1 referenced memory at 0x0000009c. The
memory could not be written.
This error may occur immediately following a declared API function call 
within a Visual
Basic callback function.
CAUSE
When the error occurs, the callback function is called by a thread that 
was not created
by Visual Basic.
For instance, certain API calls such as CreateThread() and 
RegisterServiceCtrlHandler()
create an additional thread before invoking the callback function that 
was previously
setup by using the AddressOf operator. Although the same code may have 
worked in
previous versions of Visual Basic, calling API's of this nature are 
currently unsupported
in Visual Basic.
RESOLUTION
If the crash is occurring at the specified instruction and address 
described in the
Symptoms section, then two possible work arounds may help:
l Try running the application after compiling the project to P-Code.
-or-
l Call the API functions through the use of a type library.
MORE INFORMATION
These API functions use a Free threading model, but Visual Basic only 
supports
Apartment-model threading. Furthermore, additional care must be taken 
with regards to
what code can be executed within the callback function. Any use of the 
following within
the callback function may cause undesirable results:
l File I/O.
l Error handling.
l Fixed size arrays.
l Set statements.
l COM method calls that return HRESULTs (such as any Visual Basic 
ActiveX object).
l Declare calls.
l Global objects such as the Application object.
l Most of the Visual Basic run-time files.
REFERENCES
For more information on using threads in Visual Basic, please see the 
following: Visual
Basic Books Online, "Apartment-Model Threading in Visual Basic"
Pattison, Ted, Programming Distributed Applications with COM and 
Microsoft Visual Basic
6.0. Microsoft Press, 1999, Chapter 7, "Exploring Apartments and 
Multithreading".
McKinney, Bruce, HardCore Visual Basic. Microsoft Press, 1997 Chapter 
11, "Threads and
Synchronization"
Appleman, Daniel, A Thread to Visual Basic article located at the 
following Web URL:
http://www.desaware.com
For additional information, please see the following articles in the 
Microsoft Knowledge
Base:
Q189133 Make C DLL More Accessible to VB with a Type Library
Q143258 How to Create Constants and DLL Declarations in a Type Library
Additional query words:
Keywords : kbAPI kbThread kbVBp kbVBp600
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 19, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.
Send feedback to MSDN.Look here for MSDN Online resources.

Effettivamente compilando in P-Code il problema si risolve, peccato che si 
perda gran parte della velocità dovuta al codice nativo....
Cmq grazie mille,
Emiliano.
