# Having fun with c10 and .net

**URL:** <https://clarionhub.com/t/having-fun-with-c10-and-net/919>\
**Category:** Interop\
**Tags:** interop, net, clarion10\
**Created:** [January 3, 2017, 7:04pm UTC](https://clarionhub.com/t/having-fun-with-c10-and-net/919 "2017-01-03T19:04:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Vecchione](https://clarionhub.com/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Martin\_Vecchione](https://clarionhub.com/u/Martin_Vecchione)\
**Post date:** [January 3, 2017, 7:04pm UTC](https://clarionhub.com/t/having-fun-with-c10-and-net/919/1 "2017-01-03T19:04:49Z")

</div>

Yesterday i was wondering if a can use some clarion code in a new [ASP.NET](http://ASP.NET) MVC5 project..

I do some basic step from a simple test.

1. create a simple [asp.net](http://asp.net) mvc project.

2. Create a vanilla clarion exportable procedure with a few parameters (bstring, long) and pascal calling convention.

3. After that i prototype clarion procedure in .

4. load the clarion dll using kernel32 loadLibrary..

5. make a vanilla call to clarion code and it seems to work just fine.

6. unload clarion dll using freelibrary

Now i was trying to do something more complex and now instead of opening a tps file i was opening a sql table (using MSSQL driver), do some clarion magic code (for testing purpose i was only doing a count over de table) and then close file…

All was fine until i call freelibrary in the net side…the programs hangs nothing else happen..

(maybe is something with MSSQL driver but it seems unprobably)  
Dont know way and i am getting lost.

Any help? ideas?

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [January 3, 2017, 7:37pm UTC](https://clarionhub.com/t/having-fun-with-c10-and-net/919/2 "2017-01-03T19:37:52Z")

</div>

Martin,  
Take a look at AttachThreadToClarion procedure in the help.  
When you call into a Clarion DLL from external non-clarion program that created the execution thread you need to attach the thread to Clarion’s runtime.

Rick

---

<div class="post-metadata">

**Author:** ![Martin\_Vecchione](https://clarionhub.com/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Martin\_Vecchione](https://clarionhub.com/u/Martin_Vecchione)\
**Post date:** [January 3, 2017, 7:50pm UTC](https://clarionhub.com/t/having-fun-with-c10-and-net/919/3 "2017-01-03T19:50:38Z")

</div>

@Rick_UpperPark thanks,

yeah i know i was calling AttachThreadToClarion() before doing anythingelse, if i dont call it i get memory exception when the RTL is trying to open the files…

I copy the same code in C6.3 and its working just fine, really really strange .

Another idea?..

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [January 3, 2017, 9:29pm UTC](https://clarionhub.com/t/having-fun-with-c10-and-net/919/4 "2017-01-03T21:29:28Z")

</div>

Can’t think of anything else.  
Perhaps someone else will chime in.

Why not access SQL from the .Net side?

Rick

---

<div class="post-metadata">

**Author:** ![Martin\_Vecchione](https://clarionhub.com/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Martin\_Vecchione](https://clarionhub.com/u/Martin_Vecchione)\
**Post date:** [January 4, 2017, 1:40pm UTC](https://clarionhub.com/t/having-fun-with-c10-and-net/919/5 "2017-01-04T13:40:32Z")

</div>

I would like to reuse some old clarion abc code…without having to rewrite it from scratch…

think i got no choices…

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [January 4, 2017, 4:17pm UTC](https://clarionhub.com/t/having-fun-with-c10-and-net/919/6 "2017-01-04T16:17:59Z")

</div>

Perhaps @Mark_Sarson has an idea.  
I know he has done a fair amount of interop work between .Net and Clarion.

---

<div class="post-metadata">

**Author:** ![PurpleEdge2214](https://clarionhub.com/user_avatar/clarionhub.com/purpleedge2214/32/5109_2.png) [@PurpleEdge2214](https://clarionhub.com/u/PurpleEdge2214)\
**Post date:** [January 4, 2017, 10:52pm UTC](https://clarionhub.com/t/having-fun-with-c10-and-net/919/7 "2017-01-04T22:52:27Z")

</div>

Try prop:disconnect to make sure you have severed the connection between Clarion and the database.

---

<div class="post-metadata">

**Author:** ![Martin\_Vecchione](https://clarionhub.com/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Martin\_Vecchione](https://clarionhub.com/u/Martin_Vecchione)\
**Post date:** [January 5, 2017, 1:38pm UTC](https://clarionhub.com/t/having-fun-with-c10-and-net/919/8 "2017-01-05T13:38:51Z")

</div>

@PurpleEdge2214 yeap that did the trick…

It seems that de connection is still open when i try to freelibrary from the .net side

Thanks!
