Hello I am making a PInvoke call from VB layer to the c++ DLL and getting the below erro?
A callback was made on a garbage collected delegate of type 'EPSS06!EPSS32.ErrorUtilities+delbpeErrCB::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.
Does anyone have any idea what the problem is?
As explained in the error message, if you call some unmanaged code that access memory from managed memory, you have to ensure that the pointer is properly pined so that is won't be garbage collected neither moved while being used by unmanaged code.

I don't know how you do that in VB (and if it can be done) but you have to read documentation and ensure that you understand what you are doing if you make callback from C++ code to managed VB code.
We have asked for code as this may help explain where your going wrong. If you do not participate then how do you expect to get help?
It could be a scope problem.
Local:
Public Class FooForm Private Sub Foo() Dim obj As Object = {something} End Sub ' obj now does not exist and gets collected End Class
Class:
Public Class FooForm Private obj As Object Private Sub Foo() obj = New Object End Sub ' obj still exist since the class holds the variable til it is collected End Class
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •