0

i´ve downloaded a BACnet-Stack from http://sourceforge.net/projects/bacnet/ but it is written in c and i want to use it in c#.

I´ve been reading for 4 hours now about how to get it done but i´m not any further. Most answers are to write the code anew in c# but i have no clue of c . I opened a workspace in Code::Blocks to look into the code and compiled a library into a a.-file. But how can i use it?

Greetings,

Stefan

6
  • There appears to be a C# version of BACnet Stack - bacsharp.sourceforge.net Commented Jul 19, 2013 at 11:49
  • Check this qsns ans I think it is useful for you. [stackoverflow.com/questions/9093292/… [1]: stackoverflow.com/questions/9093292/… Commented Jul 19, 2013 at 11:50
  • @jmk the site and files were edited last in feb-2008...i dont think theire accurate anymore Commented Jul 19, 2013 at 13:33
  • @typ1804 The last update to the code is September 2012 - sourceforge.net/projects/bacsharp Commented Jul 19, 2013 at 14:08
  • what is your toolchain? Visual studio on Windows / Cygwin on Windows / Mono on linux, etc? Commented Jul 19, 2013 at 15:02

1 Answer 1

1

To address alike situation, Microsoft provides attributes, assembly, and marshaling to offer interoperability between managed-unmanaged code(not .net aware/running outside the clr boundaries) and managed-legacy COM.
Investigate the use of dynamics and the (Dynamic language runtime- DLR) which should be more than fine.
code example (using kernel32.dll) as an example of calling unmanaged code from a managed context

[DllImport("kernel32.dll", EntryPoint="MoveFile", ExactSpelling=false, CharSet=CharSet.Unicode, SetLastError=true)] static extern bool MoveFile(string sourceFile, string destinationFile); //calling the function static void Main() { MoveFile("sheet.xls", @"c:\sheet.xls"); } 

check this pdf also: http://www.nag.com/IndustryArticles/Calling_C_Library_DLLs_from_C_Sharp.pdf

Sign up to request clarification or add additional context in comments.

2 Comments

-1: Only "marshaling" is at all relevant to the OP, and even that's not really useful content.
But how can i convert a a.-file into a .dll?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.