473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Calling C Code from C#

I am investigating the different ways in which one can call C functions from
inside a C# project. In particular, I need to do this in such a way as to
preserve the ability to debug the C code. It is difficult to debug a DLL,
so I'm trying to find a different approach from importing a DLL.

Ideally, I would like to be able to just include the C code in the C#
project. Does anyone have any ideas? I am using Visual Studio.NET.

Thanks,
Joey
Nov 15 '05 #1
6 2124
Debug the DLL seperately then use it
"Joey Harrison" <Jo**@AutonomousSolutions.com> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
I am investigating the different ways in which one can call C functions from inside a C# project. In particular, I need to do this in such a way as to
preserve the ability to debug the C code. It is difficult to debug a DLL,
so I'm trying to find a different approach from importing a DLL.

Ideally, I would like to be able to just include the C code in the C#
project. Does anyone have any ideas? I am using Visual Studio.NET.

Thanks,
Joey

Nov 15 '05 #2
you could use a Managed C++ project, that'll let you mix C and Managed C++
in a "mixed mode DLL" there are a couple of pitfalls though: static types
cant be initialized properly unless you build a few workarounds but other
than that its all good.

obviously PInvoke is used to call into C/C++ functions imported from native
DLLs

--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]
"Joey Harrison" <Jo**@AutonomousSolutions.com> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
I am investigating the different ways in which one can call C functions from inside a C# project. In particular, I need to do this in such a way as to
preserve the ability to debug the C code. It is difficult to debug a DLL,
so I'm trying to find a different approach from importing a DLL.

Ideally, I would like to be able to just include the C code in the C#
project. Does anyone have any ideas? I am using Visual Studio.NET.

Thanks,
Joey

Nov 15 '05 #3
Joey,
I am investigating the different ways in which one can call C functions from
inside a C# project. In particular, I need to do this in such a way as to
preserve the ability to debug the C code. It is difficult to debug a DLL,
so I'm trying to find a different approach from importing a DLL.
If you enable the "Enable Unmanaged Debugging" option in the project
properties, you should be able to step into the C code.

Ideally, I would like to be able to just include the C code in the C#
project. Does anyone have any ideas?


That wont work, you can only have C# source code in a C# project.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #4
Arnt they redoing the C++/CLI syntax to avoid all this __blah keyword mess?
"Eric Newton" <er**@cc.ensoft-software.com> wrote in message
news:OE**************@TK2MSFTNGP11.phx.gbl...
you could use a Managed C++ project, that'll let you mix C and Managed C++
in a "mixed mode DLL" there are a couple of pitfalls though: static types
cant be initialized properly unless you build a few workarounds but other
than that its all good.

obviously PInvoke is used to call into C/C++ functions imported from native DLLs

--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]
"Joey Harrison" <Jo**@AutonomousSolutions.com> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
I am investigating the different ways in which one can call C functions

from
inside a C# project. In particular, I need to do this in such a way as to preserve the ability to debug the C code. It is difficult to debug a DLL, so I'm trying to find a different approach from importing a DLL.

Ideally, I would like to be able to just include the C code in the C#
project. Does anyone have any ideas? I am using Visual Studio.NET.

Thanks,
Joey


Nov 15 '05 #5

<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Arnt they redoing the C++/CLI syntax to avoid all this __blah keyword mess? Yes, with talk of standardizing it with the ECMA, although I don't know the
state of it(I can't find the prelim spec on the ECMA site anymore, saw it
there some months back however)
"Eric Newton" <er**@cc.ensoft-software.com> wrote in message
news:OE**************@TK2MSFTNGP11.phx.gbl...
you could use a Managed C++ project, that'll let you mix C and Managed C++
in a "mixed mode DLL" there are a couple of pitfalls though: static types cant be initialized properly unless you build a few workarounds but other than that its all good.

obviously PInvoke is used to call into C/C++ functions imported from native
DLLs

--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]
"Joey Harrison" <Jo**@AutonomousSolutions.com> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
I am investigating the different ways in which one can call C
functions from
inside a C# project. In particular, I need to do this in such a way

as to preserve the ability to debug the C code. It is difficult to debug a DLL, so I'm trying to find a different approach from importing a DLL.

Ideally, I would like to be able to just include the C code in the C#
project. Does anyone have any ideas? I am using Visual Studio.NET.

Thanks,
Joey



Nov 15 '05 #6
(I can't find the prelim spec on the ECMA site anymore, saw it
there some months back however)


http://www.ecma-international.org/news/ecma-TG5-PR.htm

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Chris | last post by:
Hi I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have...
8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
7
by: Klaus Friese | last post by:
Hi, i'm currently working on a plugin for Adobe InDesign and i have some problems with that. I'm not really a c++ guru, maybe somebody here has an idea how to solve this. The plugin is...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
1
by: desmcc | last post by:
Hi, I am launching a modal dialog through the usual javascript (window.showmodaldialog). When the modal dialog is complete (ie user selects OK), the calling page then refreshes itself by setting...
3
by: Mike | last post by:
Timeout Calling Web Service I am calling a .NET 1.1 web service from an aspx page. The web service can take several minutes to complete its tasks before returning a message to the aspx page. ...
16
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.