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

Connect to C DLL

2 REPLIES 2
Reply
Message 1 of 3
GTVic
260 Views, 2 Replies

Connect to C DLL

I have created a vanilla C DLL using VS2008 that connects to a 3rd party C DLL This DLL works fine and I went this route because I could not connect to the 3rd party DLLs using C# or VB.NET.

 

I have created a small VB.NET text EXE application to connect to my C DLL. This works fine and returns the required values. So my VB.NET test EXE > my C DLL > 3rd Party C DLL works.

 

I have pasted the 18 lines of code from my VB.NET standalone EXE test application into a very simple AutoCAD VB.NET class library DLL which I netload into AutoCAD. Those 18 lines of code no longer work. I can debug up to the DLL call  but then it throws an exception and says it can't find the procedure. It gives the same error if I completely delete my C DLL.

 

If I copy my standalone EXE into the debug folder where all the DLLs are located it is able to access my C DLL no problem. The debug folder is in the AutoCAD path so AutoCAD can find my C DLL no problem.

2 REPLIES 2
Message 2 of 3
Alfred.NESWADBA
in reply to: GTVic

Hi,

 

without seeing these 18 lines and not knowing what type of DLL the 3rd party DLL is I can only guess, but nor more.

 

I assume that the 3rd party DLL is also a Framework-based DLL and then I would look to :

  • your AutoCAD DLL has not set the reference to the 3rd party DLL?
  • 32bit-/64bit-conflicts ==> sample: your test-EXE runs 32bit, your AutoCAD runs 64bit and your 3rd party DLL only runs 32bit. Then your EXE would run fine with references, but not the AutoCAD-loaded DLL
  • your 3rd party DLL itself needs other libraries to include ... but does not find it when the parent EXE (in this case ACAD.EXE) runs in another directory

A few ideas for now (to start), other ideas may follow by others 😉

 

Good luck, - alfred -

 

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 3
GTVic
in reply to: Alfred.NESWADBA

Thanks for the tips.

 

I believe the 3rd party DLL is straight C or C++. It is definitely not .NET otherwise I wouldn't need a C DLL to interface to it.

 

Everything is 32-bit but I do compile the .NET test EXE and AutoCAD DLL to AnyCPU.

 

My AutoCAD DLL never talks to the 3rd party DLL it goes through my own C DLL. I tried setting my C DLL as a reference but that didn't affect anything.

 

I like the idea that the DLLs can't find each other. My one test of putting them all in the AutoCAD path wouldn't have helped. Maybe I could try setting the working path just before calling the DLL.

 

There is one benefit to my final solution is that the DLLs don't stay loaded in memory. When you call a DLL from .NET it doesn't release it until you shut down AutoCAD, whereas by having a small EXE access the DLL, it frees up the memory right away.

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