Cant attach to dll error 126

B

bclegg

Hi,
This is a bit like a house of cards.
At the bottom is a 3rd Party dll which uses pointers to access its
functions.

The next layer up is a C++ dll wrapper that exposes a series of
functions that can be called in the dotnet Framework.

Wrapping this is my component written in vb.net.

In my test application if I create an instance of my component on the
main thread it works.
If I create a thread and attempt to instantiate and use the component on
the thread it fails with the above error message.
The dll that the error message points to is the third party one at the
bottom.

I think I must be making a general design error in my component.
How it hangs together is.
a) A module which declares all the library calls into the C++ Dll
b) A class with public functions that make the appropriate calls into
C++ Dll and return the appropriate values.


Is this an acceptable way of designing the component?
Any suggestions as to how to get fix this would be appreciated.
Thanks
Bob
 
P

Peter Huang

Hi Bob,

Thanks for posting in the community.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you have a C++ wrap for a
third-party dll, and you wants to P/Invoke the C++ wrap dll from DLL in
VB.NET, when called the dll in the MainThread it works, while it will get
error 126 when called in a working thread.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Is the VB.NET application a winform application?

Did the third-party dll have any requirements? e.g. if it needs a GUI
thread, a message queue and etc.
If so, it maynot work properly in the working thread.

What is it used for?

From your description, I think the design has no problem.
Please apply my suggestion above and let me know if it helps resolve your
problem.

Also, did you any cross-thread operation?e.g. you create an object in the
third-party dll from the Mainthread in the VB.NET and access it from the
working thread or vice versa.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Top