473,395 Members | 1,969 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.

DllImport and Windows 2000

Hello, Newsgroupians:

I have created an unmanaged DLL using Visual Studio 2005, which was created
in Visual C++. I have some functions in the DLL that I am trying to call.
When I "dumpbin -exports ManipLib.dll" I can see all of my exported
functions, which I have defined in my definition file. They are not name
mangled or decorated.

Now, when I call the function in my C# program, I have the following
definition...

[System.Runtime.InteropServices.DllImport(@".\Manip Lib.dll", CharSet =
System.Runtime.InteropServices.CharSet.Unicode)]
public static extern IntPtr UserFindWindowW(string lpszWndClass);

All UserFindWindowW does is call FindWindowEx(). Now, I know I can import
the user32.dll instead of this, but I have some other methods later that wrap
functionality of what I am going to do to the window, so this is just my base
case, and it doesn't work in Windows 2000.

When I run the program in WindowsXP, the function succeeds and returns an
IntPtr, or handle, to the window I'm looking for. However, when I run the
program in Windows2000, I am constantly receiving a
System.DllNotFoundException: "Unable to load DLL '.\ManipLib.dll': The
specified procedure could not be found. (Exception from HRESULT: 0x8007007F)."

Now, I know the working directory contains the DLL that I have created, for
just prior to making my extern-call, I do a
MessageBox.Show(System.IO.Directory.GetCurrentDire ctory()); This shows my
current working directory correctly, which the directory also contains my
ManipLib.dll. As soon as I hit "OK," the exception is thrown as it tries to
call my DLL method.

What would make this program work for all versions of XP that I have tried,
but continually fail for every Windows 2000 version? I've tried 4 computers
with Windows 2000, each has SP4. Thank you for your help.
Trecius
Oct 31 '08 #1
1 2997
Not sure what's the issue here. Seems that there is difference in the
way the files are searched.

Try to use this (Remove ".\" before the dll's name)

[System.Runtime.InteropServices.DllImport(@"ManipLi b.dll", CharSet =
System.Runtime.InteropServices.CharSet.Unicode)]

-
Ashutosh

Trecius wrote:
Hello, Newsgroupians:

I have created an unmanaged DLL using Visual Studio 2005, which was created
in Visual C++. I have some functions in the DLL that I am trying to call.
When I "dumpbin -exports ManipLib.dll" I can see all of my exported
functions, which I have defined in my definition file. They are not name
mangled or decorated.

Now, when I call the function in my C# program, I have the following
definition...

[System.Runtime.InteropServices.DllImport(@".\Manip Lib.dll", CharSet =
System.Runtime.InteropServices.CharSet.Unicode)]
public static extern IntPtr UserFindWindowW(string lpszWndClass);

All UserFindWindowW does is call FindWindowEx(). Now, I know I can import
the user32.dll instead of this, but I have some other methods later that wrap
functionality of what I am going to do to the window, so this is just my base
case, and it doesn't work in Windows 2000.

When I run the program in WindowsXP, the function succeeds and returns an
IntPtr, or handle, to the window I'm looking for. However, when I run the
program in Windows2000, I am constantly receiving a
System.DllNotFoundException: "Unable to load DLL '.\ManipLib.dll': The
specified procedure could not be found. (Exception from HRESULT: 0x8007007F)."

Now, I know the working directory contains the DLL that I have created, for
just prior to making my extern-call, I do a
MessageBox.Show(System.IO.Directory.GetCurrentDire ctory()); This shows my
current working directory correctly, which the directory also contains my
ManipLib.dll. As soon as I hit "OK," the exception is thrown as it tries to
call my DLL method.

What would make this program work for all versions of XP that I have tried,
but continually fail for every Windows 2000 version? I've tried 4 computers
with Windows 2000, each has SP4. Thank you for your help.
Trecius
Nov 2 '08 #2

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

Similar topics

2
by: Paul Duncan | last post by:
diggityduncs (Programmer) Nov 13, 2003 Hello, I'm tring to use a win32/api dll in c# The vendor I received the dll from doesn't know anything about .net I received two files ACGAPI.DLL +
15
by: Jim | last post by:
I am extremely frustrated. I am building c# application for a call center and am using a third party API to access some hardware. When develop and test my class using the windows console the...
2
by: pnp | last post by:
Hi all, i'm having a problem using DllImport with Win98. It works just fine with XP & 2000 but in 98 it prompts: "Unable to find xxxxx.dll". Any ideas? error is: System.DllNotFoundException:...
1
by: Whidbey Wave | last post by:
Hi , Of course sometimes, some of us have these weird DLLImport issues. I am using Net-snmp library from http://www.net-snmp.org. While creating a prototype as console application it worked fine,...
2
by: | last post by:
Hi everyone, Can you have a quick look and tell me why the caret is not shown , any help will be greatly appreicated thank you. using System; using System.Drawing; using System.Collections;...
2
by: Brian Anderson | last post by:
Hello, is it possible to use DllImport to call a DLL in ASP.NET ? Or is it necessarry that my DLL has to be copied into \System32 ? My DLL is a native C++ 7.1 DLL (not managed, no COM, no...
0
by: Nelson R. | last post by:
Greetings, I've already posted this message on aspnet.security group (think its related to security issues), but since didn't get any response, I post it here. -- I have a problem, and been...
1
by: kardon33 | last post by:
Let me explain my problem, Im currently trying to use a Perl module that was built for a Windows OS that uses a .dll and .lib file. I have obtained the c header files that the modules were built...
0
by: tomb | last post by:
Can anybody help me by checking if I have correct call signatures? In my C# Windows Form project (VS2008) I am using dll which has been written for Visual C++ 6.0: This function code is used to...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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.