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

problem adding reference

Hi someone plz help me. I have made a dll in VC++ .NET using following
specifications

extern "C"
{
__declspec(dllexport) void Probe_Interfaces_Local()
{
//some code
}
}

i compiled it successfully and add the dll formed to another C# project
directory. The c# code looks like this...

using System;
using System.Runtime.InteropServices;

namespace read
{
class Capture
{
[DllImport("mod2.dll")]
public static extern void Probe_Interfaces_Local();
//some code
}
}
The C# project compiles successfully but when i run it it breaks with
dll exception and says unable to load dll(mod2.dll)

Dec 29 '05 #1
3 988
I am not very familiar with C# syntax, but have you investigated the
error code ? Also, is it possible that some dependent DLLs of mod2.dll
are not present and the loadlib of the mod2.dll is failing.
just my 2 cents worth..

sh***************@gmail.com wrote:
Hi someone plz help me. I have made a dll in VC++ .NET using following
specifications

extern "C"
{
__declspec(dllexport) void Probe_Interfaces_Local()
{
//some code
}
}

i compiled it successfully and add the dll formed to another C# project
directory. The c# code looks like this...

using System;
using System.Runtime.InteropServices;

namespace read
{
class Capture
{
[DllImport("mod2.dll")]
public static extern void Probe_Interfaces_Local();
//some code
}
}
The C# project compiles successfully but when i run it it breaks with
dll exception and says unable to load dll(mod2.dll)

Dec 30 '05 #2

<sh***************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi someone plz help me. I have made a dll in VC++ .NET using following
specifications

extern "C"
{
__declspec(dllexport) void Probe_Interfaces_Local()
{
//some code
}
}

i compiled it successfully and add the dll formed to another C# project
directory. The c# code looks like this...

using System;
using System.Runtime.InteropServices;

namespace read
{
class Capture
{
[DllImport("mod2.dll")]
public static extern void Probe_Interfaces_Local();
//some code
}
}
The C# project compiles successfully but when i run it it breaks with
dll exception and says unable to load dll(mod2.dll)


You must have the DLL in the path of the caller, that is the same directory
or in a directory which is in the path environment.
DllImport uses LoadLibrary to load the DLL, so the same search rules apply
here.

Willy.
Dec 30 '05 #3
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote
You must have the DLL in the path of the caller, that is the same
directory or in a directory which is in the path environment.
DllImport uses LoadLibrary to load the DLL, so the same search rules apply
here.

And in case the C++ DLL is compiled with /MD(d) and Visual C++
2005 you also need an embedded manifest to bind to the correct CRT
DLL. See the /MANIFESTDEPENDENCY linker switch.

Depends.exe, NT LDR (gflags.exe, "Show Loader Snaps" or _ShowSnaps
variable) are your friends.

-hg
Jan 1 '06 #4

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

Similar topics

3
by: Saradhi | last post by:
Hi All, Here I am facing a performance problem with the TreeView Node renaming. I am displaying a hierarchy Data in a treeview in my Windows C# Application. My tree view represents an...
13
by: Tom Bean | last post by:
I developed a C# application to automate input to elements of a web page displayed in an AxWebBrowser control. The app calls GetEnumerator() on the HTMLDocument's HTMLElementCollection (i.e....
0
by: Nikhil Patel | last post by:
Hi all, I am having a problem adding a reference in an ASP.Net project. I have written a custom control using a Web Control Library project. I compiled this project and generated a dll. Now...
8
by: Rob Edwards | last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message: "A reference to 'Microsoft CDO for Exchange Management Library' could not be...
3
by: f1racing24 | last post by:
I am trying to compile this class in the command-line and this error comes up 'Start -> C:\Inetpub\wwwroot\DCReview_Brinkster\code>vbc /t:library /verbose...
13
by: Lee Newson | last post by:
Hi, I have just written my first application using VB.NET. The app works fine when i am running it within .NET for debugging purposes, however when i try to run the app from the .exe file that...
8
by: Harry Strybos | last post by:
Visual Studio 2005 - SP1 - VB.Net on WinXP SP2 I add a typed dataset to my solution and get the following errors : Error 1 sub 'ReadXmlSerializable' cannot be declared 'Overrides' because it...
1
by: vinodkreddy1 | last post by:
hi good morning every body... i have a problem in adding Reference of any dll to asp.net 2005. i am trying to add dlls reference to asp.net application. but they r not adding to the reference...
4
by: Clive Lumb | last post by:
Hi, I'm having a problem while adding objects to a collection. (VB.net 2005) I am reading data in from a file to a temporary variable (eg MyClass) and then adding it to a collection. When I...
2
by: thebenb | last post by:
I've got this very frustrating problem that I can't seem to nail. Hopefully someone out there can help me. I've got a toolkit class library project that has some handy helper classes in. I add...
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.