- Fanuc VB.NET app
-
Fanuc VB.NET app
Hello,
I am trying to build a vb.net based application, that allows me to send and retrieve programs from the machine.
When I try to alloccate the library I get the error "System.AccessViolationException". Can check the code on the attached image.
Does anyone knows why this happens?
Attachment 377077
Best regards
-
-
Member
Re: Fanuc VB.NET app
Maybe this webpage will help, specifically the 2nd solution at the bottom of the page that mentions the Fanuc 64-bit DLL If you're on a 64-bit PC.
-
Re: Fanuc VB.NET app
The System.AccessViolationException error occurs when you try to access memory that is not allocated or that you do not have permission to access. In your code, you are trying to allocate a library using the statement: try below solution.
Dim lib As New Marshal.LoadLibrary(dllPath)
However, the dllPath variable is not initialized, so it is not pointing to a valid file. This is why you are getting the error.
To fix this error, you need to initialize the dllPath variable to the path of the library file that you want to load. For example:
Dim dllPath As String = "C:\MyLibrary.dll"
Dim lib As New Marshal.LoadLibrary(dllPath)
Once the dllPath variable is initialized, the code should be able to allocate the library without any errors.
Here are some other possible reasons why you might be getting the System.AccessViolationException error:
You are trying to access a memory address that is outside of the bounds of the allocated memory.
You are trying to write to a memory address that is read-only.
You are trying to access a memory address that is already in use by another process.
If you are still getting the error after fixing the above mentioned issues, you can try the following:
Use a debugger to step through the code and see where the error is occurring.
Check the documentation for the library that you are trying to load to make sure that you are using it correctly.
Contact the library's author for help.
Last edited by RaderSidetrack; 08-31-2023 at 11:56 AM.
- Fanuc VB.NET app
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules