How to use third party dll in arcobject tool?

2196
3
04-03-2013 12:38 AM
TruongPham
New Contributor
I use arcobject to build custom tool for working with arcmap or arcgis server like a geoprocessing tool. Is there any way to use third party dll in my case?
I have try test app as an arcengine application. It work fine when i copy 3nd dll to debug/bin folder and call:
[DllImport("Shp2Dgn.dll")]
public static extern int shp2dgn(string InputShp, string outputDGN, string seedFile);

But when i try this code in geoprocessing app. Nothing occur.
0 Kudos
3 Replies
RichardWatson
Frequent Contributor
My suggestion is to either debug your code or modify it such that it does logging.  For example, add a try/catch around the call to the unmanaged code and log any errors.

The problem might be that the logic is not finding your DLL.  Did you put in in the same directory as the executable image which is running, e.g. ArcMap.exe?  You should be able to modify the System PATH environment variable and put it in whatever directory that you choose.  Just note that existing process will not see the updated environment variable unless they are restarted, e.g. services.
0 Kudos
TruongPham
New Contributor
My suggestion is to either debug your code or modify it such that it does logging.  For example, add a try/catch around the call to the unmanaged code and log any errors.

The problem might be that the logic is not finding your DLL.  Did you put in in the same directory as the executable image which is running, e.g. ArcMap.exe?  You should be able to modify the System PATH environment variable and put it in whatever directory that you choose.  Just note that existing process will not see the updated environment variable unless they are restarted, e.g. services.


I used try - catch but is just run throw the code with out catch. I had try put Shp2Dgn dll to Arcgis.exe (C:\Program Files\ArcGIS\Bin) folder also but it seem can not see this library. Shp2Dgn is library in C++ to convert from Shape file to DGN file.
I show here test code in arcengine which work fine. [ATTACH=CONFIG]23188[/ATTACH]
And other code in arcobject geoprocessing that didn't call C++ library. [ATTACH=CONFIG]23189[/ATTACH]

I wondering that in geoprocessing code, i have to register dll with arcgis (by code or manually). I had try register Shp2Dgn dll manually but not success. Because of it isn't com dll.

Please help me! Thanks for your time.
0 Kudos
TruongPham
New Contributor
Sorry. It's my mistake. I done with this job. Tks
0 Kudos