473,662 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting an error that entry point can not be located from my pinvo

I'm trying to pinvoke a function in a C++ dll but I'm getting an error that
entry point can not be located from my pinvoke code. Do I need to add any
code to the C++ DLL to make the pinvoke? The following is what I have in my
C# code:

[DllImport("Prop SheetHost.dll")]
public static extern void ShowAdProp(
[MarshalAs(Unman agedType.LPStr)]
String m);

//This is where I invoke the function
private void propertyToolStr ipMenuItem_Clic k(object sender,
EventArgs e)
{

ShowAdProp("'CN =1608,CN=Users, CN=Accounting,C N=Contexts,CN=U nity,CN=Symark, CN=Program Data,DC=unity,D C=windev,DC=sym ark,DC=com");
}

//This is start of the C++ dll
using namespace std;

void ShowAdProp(wstr ing adPath)
{

CoInitialize(NU LL);

HRESULT hr;

HINSTANCE hInstance = NULL;
HWND hwndConsole = GetConsoleWindo w();
if(hwndConsole)
{
hInstance = (HINSTANCE)(LON G_PTR)GetWindow LongPtr(hwndCon sole,
GWLP_HINSTANCE) ;
}

CPropSheetHost *pHost = new CPropSheetHost( hInstance);

// Hold a reference count for the CPropSheetHost object.
pHost->AddRef();

hr = pHost->SetObject(adPa th.c_str());

--
Thanks.
Jul 12 '06 #1
5 3569
>Do I need to add any
>code to the C++ DLL to make the pinvoke?
Not add but change. The parameter type can't be a wstring, it must be
a library neutral type such as a char*. You must also ensure you're
using the right calling convention and check under which name the
function is exported (it may be mangled).
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 12 '06 #2
Thank you for the reply. Here is what I've modified but I'm still getting
the same error message.
//The header file
public:
HRESULT SetObject(LPCWS TR pwszADsPath);
HRESULT SetObject(IADs *pads);
__declspec(dlle xport) void ShowAdProp(WCHA R* inPath);
void Run();
//The function I'm exporting
void ShowAdProp(WCHA R* inPath)
{
wstring adPath = inPath;

CoInitialize(NU LL);

HRESULT hr;

HINSTANCE hInstance = NULL;
HWND hwndConsole = GetConsoleWindo w();
if(hwndConsole)
{
hInstance = (HINSTANCE)(LON G_PTR)GetWindow LongPtr(hwndCon sole,
GWLP_HINSTANCE) ;
}

CPropSheetHost *pHost = new CPropSheetHost( hInstance);

// Hold a reference count for the CPropSheetHost object.
pHost->AddRef();

hr = pHost->SetObject(adPa th.c_str());
if(FAILED(hr))
{
goto ExitMain;
}

pHost->Run();

/*
Release the CPropSheetHost object. Other components may still hold a
reference to the object, so this cannot just be deleted here. Let
the object delete itself when all references are released.
*/
pHost->Release();
ExitMain:

CoUninitialize( );
}

//My import statement
namespace ppGlobal
{
public partial class FormMain : Form
{
[DllImport("Prop SheetHost.dll")]
public static extern void ShowAdProp(
[MarshalAs(Unman agedType.LPWStr )]
String m);

//Invoke statement
private void propertyToolStr ipMenuItem_Clic k(object sender,
EventArgs e)
{

ShowAdProp("'CN =1608,CN=Users, CN=Accounting,C N=Contexts,CN=U nity,CN=Symark, CN=Program Data,DC=unity,D C=windev,DC=sym ark,DC=com");
}

//Error Message
An unhandled exception of type 'System.EntryPo intNotFoundExce ption' occurred
in ppGlobal.exe

Additional information: Unable to find an entry point named 'ShowAdProp' in
DLL 'PropSheetHost. dll'.
--
Thanks.
"Mattias Sjögren" wrote:
Do I need to add any
code to the C++ DLL to make the pinvoke?

Not add but change. The parameter type can't be a wstring, it must be
a library neutral type such as a char*. You must also ensure you're
using the right calling convention and check under which name the
function is exported (it may be mangled).
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 12 '06 #3
The PInvoke marshaler cannot marshal a String to a std::wstring object.
Change your C++ code and make the argument a simple ascii string or a
wchar_t string.
Willy.

"Pucca" <Pu***@discussi ons.microsoft.c omwrote in message
news:20******** *************** ***********@mic rosoft.com...
| I'm trying to pinvoke a function in a C++ dll but I'm getting an error
that
| entry point can not be located from my pinvoke code. Do I need to add any
| code to the C++ DLL to make the pinvoke? The following is what I have in
my
| C# code:
|
| [DllImport("Prop SheetHost.dll")]
| public static extern void ShowAdProp(
| [MarshalAs(Unman agedType.LPStr)]
| String m);
|
| //This is where I invoke the function
| private void propertyToolStr ipMenuItem_Clic k(object sender,
| EventArgs e)
| {
|
|
ShowAdProp("'CN =1608,CN=Users, CN=Accounting,C N=Contexts,CN=U nity,CN=Symark, CN=Program
Data,DC=unity,D C=windev,DC=sym ark,DC=com");
| }
|
| //This is start of the C++ dll
| using namespace std;
|
| void ShowAdProp(wstr ing adPath)
| {
|
| CoInitialize(NU LL);
|
| HRESULT hr;
|
| HINSTANCE hInstance = NULL;
| HWND hwndConsole = GetConsoleWindo w();
| if(hwndConsole)
| {
| hInstance = (HINSTANCE)(LON G_PTR)GetWindow LongPtr(hwndCon sole,
| GWLP_HINSTANCE) ;
| }
|
| CPropSheetHost *pHost = new CPropSheetHost( hInstance);
|
| // Hold a reference count for the CPropSheetHost object.
| pHost->AddRef();
|
| hr = pHost->SetObject(adPa th.c_str());
|
| --
| Thanks.
Jul 14 '06 #4
Thank you and I did that as follow but I'm still getting the same error
message.
__declspec(dlle xport) void ShowAdProp(WCHA R* inPath)
--
Thanks.
"Willy Denoyette [MVP]" wrote:
The PInvoke marshaler cannot marshal a String to a std::wstring object.
Change your C++ code and make the argument a simple ascii string or a
wchar_t string.
Willy.

"Pucca" <Pu***@discussi ons.microsoft.c omwrote in message
news:20******** *************** ***********@mic rosoft.com...
| I'm trying to pinvoke a function in a C++ dll but I'm getting an error
that
| entry point can not be located from my pinvoke code. Do I need to add any
| code to the C++ DLL to make the pinvoke? The following is what I have in
my
| C# code:
|
| [DllImport("Prop SheetHost.dll")]
| public static extern void ShowAdProp(
| [MarshalAs(Unman agedType.LPStr)]
| String m);
|
| //This is where I invoke the function
| private void propertyToolStr ipMenuItem_Clic k(object sender,
| EventArgs e)
| {
|
|
ShowAdProp("'CN =1608,CN=Users, CN=Accounting,C N=Contexts,CN=U nity,CN=Symark, CN=Program
Data,DC=unity,D C=windev,DC=sym ark,DC=com");
| }
|
| //This is start of the C++ dll
| using namespace std;
|
| void ShowAdProp(wstr ing adPath)
| {
|
| CoInitialize(NU LL);
|
| HRESULT hr;
|
| HINSTANCE hInstance = NULL;
| HWND hwndConsole = GetConsoleWindo w();
| if(hwndConsole)
| {
| hInstance = (HINSTANCE)(LON G_PTR)GetWindow LongPtr(hwndCon sole,
| GWLP_HINSTANCE) ;
| }
|
| CPropSheetHost *pHost = new CPropSheetHost( hInstance);
|
| // Hold a reference count for the CPropSheetHost object.
| pHost->AddRef();
|
| hr = pHost->SetObject(adPa th.c_str());
|
| --
| Thanks.
Jul 17 '06 #5
I'm guessing that the name gets mangled. Check to make sure that the
exported name is really ShowAdProc (by using depends.exe for instance). You
also need to change your MarshalAs statement in the DllImport to
UnmanagedTypes. LPWStr.

/claes
"Pucca" <Pu***@discussi ons.microsoft.c omwrote in message
news:FF******** *************** ***********@mic rosoft.com...
Thank you and I did that as follow but I'm still getting the same error
message.
__declspec(dlle xport) void ShowAdProp(WCHA R* inPath)
--
Thanks.
"Willy Denoyette [MVP]" wrote:
>The PInvoke marshaler cannot marshal a String to a std::wstring object.
Change your C++ code and make the argument a simple ascii string or a
wchar_t string.
Willy.

"Pucca" <Pu***@discussi ons.microsoft.c omwrote in message
news:20******* *************** ************@mi crosoft.com...
| I'm trying to pinvoke a function in a C++ dll but I'm getting an error
that
| entry point can not be located from my pinvoke code. Do I need to add
any
| code to the C++ DLL to make the pinvoke? The following is what I have
in
my
| C# code:
|
| [DllImport("Prop SheetHost.dll")]
| public static extern void ShowAdProp(
| [MarshalAs(Unman agedType.LPStr)]
| String m);
|
| //This is where I invoke the function
| private void propertyToolStr ipMenuItem_Clic k(object sender,
| EventArgs e)
| {
|
|
ShowAdProp("'C N=1608,CN=Users ,CN=Accounting, CN=Contexts,CN= Unity,CN=Symark ,CN=Program
Data,DC=unity, DC=windev,DC=sy mark,DC=com");
| }
|
| //This is start of the C++ dll
| using namespace std;
|
| void ShowAdProp(wstr ing adPath)
| {
|
| CoInitialize(NU LL);
|
| HRESULT hr;
|
| HINSTANCE hInstance = NULL;
| HWND hwndConsole = GetConsoleWindo w();
| if(hwndConsole)
| {
| hInstance = (HINSTANCE)(LON G_PTR)GetWindow LongPtr(hwndCon sole,
| GWLP_HINSTANCE) ;
| }
|
| CPropSheetHost *pHost = new CPropSheetHost( hInstance);
|
| // Hold a reference count for the CPropSheetHost object.
| pHost->AddRef();
|
| hr = pHost->SetObject(adPa th.c_str());
|
| --
| Thanks.

Jul 18 '06 #6

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

Similar topics

1
4469
by: Sanju | last post by:
Hi.. I have working on Windows XP Operating System.Installed J2sdk 1.4.07 and installed IBM DB2 UDB version 8.1 Then i got the following error.. The procedure entry point SQLPrepareW@12 could not be located in the dynamic link library DB2APP.dll java.exe Entry Point not found
8
10003
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'HTTP/1.1 500 Internal Server Error'."
4
9308
by: Allan M. Bruce | last post by:
I have a small implementation of a queue which I am trying to get to compile but cant figure out why it doesnt work. I have copied the minimum compilable code below. On gcc I get temp2.c: In function `pop': temp2.c:24: warning: initialization from incompatible pointer type temp2.c:25: warning: assignment from incompatible pointer type temp2.c: In function `destroy': temp2.c:38: error: dereferencing pointer to incomplete type
4
4115
by: martigras911 | last post by:
Hi, Every time I open 2003 Outlook, I get this error message "The procedure entry point LdrLockLoaderLock could not be located in the dynamic link library ntdll.dll" Please advise on how to fix this error. Thank you.
23
5090
by: deathtospam | last post by:
A day or two ago, I wrote a quick ASPX page with a CS codebehind using Visual Studio .NET 2005 -- it worked, I saved it and closed the project. Today, I came back to the project, reopened the solution, and was greeted with the following error: ======================================================================== It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error...
2
1634
by: Rymfax | last post by:
I have an application that will be used on both XP and Vista. One of the things this application needs to do is determine the exact operating system it is on. To get the correct "flavor" of Vista that might be running, there is a new function in Kernel32.dll called GetProductInfo(). The problem I'm running into is that if I include this function in my application, the app errors on XP at start up with the following message: The...
2
3305
by: =?Utf-8?B?U3RldmVTNjA=?= | last post by:
I apparently made an unknown error. Now when I attempt to install two software packages I receive error messages. One package results in the message "The procedure entry point CallWindowProMF could not be located in the dynamic link library user32.dll. Attempting to install the other package results in exactly the same error message, but the procedure entry point is DefWindowProMF. In Safe Mode I renamed user32.dll, then attempted to...
0
2206
banning
by: banning | last post by:
hi i've been trying all day to install soap and its getting really annoying... the extension_dir is set up correctly... i have written in my ini file extension=php_soap.dll and there is a file that is called php_soap.dll the problem comes when i restart my server it gives me this error "the procedure entry point zend_unmangle_property_name_ex could not be located in the dynamic link library php5ts.dll." now if i take out the...
2
5589
DonRayner
by: DonRayner | last post by:
This one has me stumped. I'm getting a "Type Mismatch" error on one of my forms when it's being opened. It's hapening before the forms "On Open" event, I stuck a msgbox in there to check and I'm getting the error before it opens. The line of code that calls the form from another form is. DoCmd.OpenForm "NonConformanceAdd",,,,acFormAdd,acDialog I get the error, click ok, then the form opens and works exactly how it's supposed to. I even...
1
8547
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6186
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5655
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.