473,410 Members | 1,852 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,410 software developers and data experts.

Adding dll to my project

I've no experience with C# infoking functions from external unmanaged
dll.
I have to do an interface driving a set of hw device using their
propetary dll.
Is there some simple tutorial explaining how to do it using VS2005?
The technology to use is pinvoke?

Thanks,
Matteo

Feb 8 '07 #1
2 1607
Hello Beorne,

See there http://quickstart.developerfusion.co...ke_Simple.aspx

I recommend to intall .NET SDK to have all quickstarts local

BI've no experience with C# infoking functions from external unmanaged
Bdll.
BI have to do an interface driving a set of hw device using their
Bpropetary dll.
BIs there some simple tutorial explaining how to do it using VS2005?
BThe technology to use is pinvoke?
BThanks,
BMatteo
---
WBR, Michael Nemtsev [C# MVP]. Blog: http://spaces.live.com/laflour
team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Feb 8 '07 #2
I have run my C# program importing MessageBox functions and other
win32 functions and it's all ok.

Now I want to create from VS2005 a dll in C++ that can be imported
from C#.
I've created an empty Win32 C++ project with dll target type.
These are my source files:

-------------- START ProvaDll2.cpp--------------
#include "stdafx.h"
#ifdef _MANAGED
#pragma managed(push, off)
#endif

BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call,
LPVOID lpReserved)
{ return TRUE; }

extern int fnProvaDll(void)
{ return 17; /* rhis is the only row I edit from template */ }

#ifdef _MANAGED
#pragma managed(pop)
#endif
-------------- END ProvaDll2.cpp--------------

-------------- START stdafx.h--------------
....
// TODO: reference additional headers your program requires here
extern int fnProvaDll(void);
-------------- END stdafx.h--------------

I build it and it is all ok (obviously, it is empty ...)
Then I build my C# project, after having copied the compiled dll in
the debug dir

-------------- START Program.h --------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace ConsoleApplicationDll
{
class Program
{
[DllImport("ProvaDll2")]
public static extern int fnProvaDll();

static void Main(string[] args)
{
int k = fnProvaDll(); // <-EntryPointNotFoundException
}
}
}
-------------- END Program.h --------------

and it gives me an EntryPointNotFoundException.
The dll has been succesfully loaded (it is not a path problem) but the
entry point is not found.

What I'm missing?

Thanks,
Matteo

On Feb 8, 10:42 am, Michael Nemtsev <nemt...@msn.comwrote:
Hello Beorne,

See therehttp://quickstart.developerfusion.co.uk/QuickStart/howto/doc/Interop/...

I recommend to intall .NET SDK to have all quickstarts local

BI've no experience with C# infoking functions from external unmanaged
Bdll.
BI have to do an interface driving a set of hw device using their
Bpropetary dll.
BIs there some simple tutorial explaining how to do it using VS2005?
BThe technology to use is pinvoke?
BThanks,
BMatteo
---
WBR, Michael Nemtsev [C# MVP]. Blog:http://spaces.live.com/laflour
team blog:http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Feb 12 '07 #3

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

Similar topics

1
by: hzgt9b | last post by:
When adding my VB .NET solution (with two sub-projects) the folder structure in VSS gets an extra level of folders... For example, here's the structure of the solution on my C:\...
7
by: Wysiwyg | last post by:
Is there any way to add an embedded resource to a project without copying it to the project's directory? I have shared resources and don't want each project using the images, xml files, etc. to...
26
by: Simon Jefferies | last post by:
Hello, I am trying to add an item to a checked list box, like: clbList.Items.add("Hello",true) I get an error back: Run-time exception thrown: System.ArgumentOutOfRangeException -...
6
by: UJ | last post by:
I have a couple of files (type definitions, constants, ...) that I want to use in multiple projects. How do I make it so that I have only one copy of the file for multiple projects? If I do add...
3
by: _DS | last post by:
The two obvious methods for ref'ing assemblies are: Add a reference and 'Browse' for the actual DLL OR Add existing project to the solution, then add a ref to 'Project'. 1: I'd like to...
0
by: sukeshchand | last post by:
How to create an event object in a dll without adding the dll into the project ie.; i use CreateObject() to create an instance of an object in a dll without adding the dll into the project. it is ok...
1
by: =?Utf-8?B?TGVvbiBNYXluZQ==?= | last post by:
In a database project in VS2005 (not a datadude project), I need to add about 3,000 stored procedure scripts to my 'Stored Procedures' folder. I've dropped the scripts into the folder in my...
1
damonreid
by: damonreid | last post by:
Access 2003 Microsoft Windows XP Pro Hey, I am currently pulling my hair out here. I have a Form for adding new projects to a database, the only problem is that when I close the form it doesn't...
8
by: Jason | last post by:
Hello, I am trying to utilitze the AJAX Control toolkit in my asp.net project. I have added a reference to AjaxControlToolkit.dll, and in my page, added these lines of code: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.