By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,118 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,118 IT Pros & Developers. It's quick & easy.

C#-WinCE5.0 - Creating a custom DLL for DLLIMPORT

Plater
Expert 5K+
P: 7,872
I am having trouble finding examples of creating your own .DLL for use with the DLLIMPORT function.
All I can find is an MFC dll which has so much overhead it's rediculous.
I just need two c++ functions to be available to me through the DLLIMPORT.

Here are my psuedo-code prototypes for the two functions:
Expand|Select|Wrap|Line Numbers
  1. bool WriteLocalBus(INT32 Address, UIN16 Data);
  2. UINT16 ReadLocalBus(INT32 Address);
  3.  
Now I need a .dll that implements them and allows me to import the functions into a C# project.

Anyone have any insight they can offer?
Apr 23 '07 #1
Share this Question
Share on Google+
3 Replies


Motoma
Expert 2.5K+
P: 3,235
Are you creating the C++ functions yourself? Is there a reason why you cannot write these in C#?

I believe that you will need to utilize the DllExport keyword in your DLL code in order to be able to import the functions using DllImport.

But if you are using VS2003/VS2005, I believe you can just include the C++ project in your solution, and add that project as a reference to your C# project. Then use the extern keyword in the declaration.

Hope this is a push in the right direction,
Motoma

I am having trouble finding examples of creating your own .DLL for use with the DLLIMPORT function.
All I can find is an MFC dll which has so much overhead it's rediculous.
I just need two c++ functions to be available to me through the DLLIMPORT.

Here are my psuedo-code prototypes for the two functions:
Expand|Select|Wrap|Line Numbers
  1. bool WriteLocalBus(INT32 Address, UIN16 Data);
  2. UINT16 ReadLocalBus(INT32 Address);
  3.  
Now I need a .dll that implements them and allows me to import the functions into a C# project.

Anyone have any insight they can offer?
Apr 23 '07 #2

Plater
Expert 5K+
P: 7,872
I was writing both the C# and C++ parts and ended up using the MFC DLL. Yes, I needed to use the DLLEXPORT, it is working now.
It's a hog, almost 2megs to run 3lines of code but I cannot do direct memory acces in C# in seems.
May 15 '07 #3

Motoma
Expert 2.5K+
P: 3,235
Yikes!

Glad you got it figured out though.

I was writing both the C# and C++ parts and ended up using the MFC DLL. Yes, I needed to use the DLLEXPORT, it is working now.
It's a hog, almost 2megs to run 3lines of code but I cannot do direct memory acces in C# in seems.
May 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.