Archived

This topic is now archived and is closed to further replies.

ANY IDEA ???? Whats wrong with my web service??

This topic is 5010 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am creating a web service using vc++.net I am Loading an MFC DLL in my solution at Load time, by including lib file and dll in Linker settings and using the directive: _declspec(dllimport) int fnExport(void); "fnExport" is the method exported from my MFC DLL, i want to access this method in my web service. My application got built...but when i am debugging(running it)the XML web page which should open and display XML result is showing "Page cannot be displayed" error. The web method from where I am calling the C++ exported method is coded as follows: int TestClassExportClass::GetSum() { int n = fnExport(); return 1; } the exported method "fnExport()" simply returns integer 42. The debugger does not even come to return statement of my web method...it gets lost somewhere after calling the exported method.. is it not able to find the exported method??? why ??? I have done necessary includes...and more over i have tested calling same method from Console Application(.NET) project and i got the result... whats wrong with my web service???? ANY IDEA ?????

Share this post


Link to post
Share on other sites
yup...my DLL is not loading...quite clear from what is happening and also i confirmed from
Debug->Windows->Modules in my project....my DLL dosent load..

but why

1. I have copied the library and the DLL to my web service project folder.
(i have also copied MFC header file to my project folder)

2.then in my code i use

_declspec(dllimport) int fnExport(void);

cos my function is exported from MFC DLL using __declspec(dllexport)


Share this post


Link to post
Share on other sites
Get rid of the capital letters in the topic title and all the question marks. It''ll help people take you more seriously. You can do it by editting the original post.

Or call it "Web Service - trouble with export".

Other than that, I''ve got nothing helpful to say.

Pete

Share this post


Link to post
Share on other sites
I remember having troubles with the __declspec(dllexport) with VC6. The solution was to write a .DEF file for the dll:

dll_name.def:

EXPORTS
fnExport

Share this post


Link to post
Share on other sites
Look into the MSDN docs, you import dll's and functions differently in managed code than unmanaged code.

from the .NET framework docs:
To consume exported DLL functions 

1.Identify functions in DLLs.
Minimally, you must specify the name of the function and name of the DLL that contains it.

2.Create a class to hold DLL functions.
You can use an existing class, create an individual class for each unmanaged function, or create one class that contains a set of related unmanaged functions.

3.Create prototypes in managed code.
[Visual Basic] Use the Declare statement with the Function and Lib keywords. In some rare cases, you can use the DllImportAttribute with the Shared Function keywords. These cases are explained later in this section.

[C#] Use the DllImportAttribute to identify the DLL and function. Mark the method with the static and extern modifiers.

[C++] Use the DllImportAttribute to identify the DLL and function. Mark the wrapper method or function with extern "C".

4.Call a DLL function.
Call the method on your managed class as you would any other managed method. Passing Structures and Implementing Callback Functions are special cases.



[edited by - deathtrap on March 26, 2004 4:33:39 PM]

Share this post


Link to post
Share on other sites
forgot to add:

I have specified lib file name in
Project->Configuration Properties->Linker->Input->Additional Dependencies
and specified DLL name in
Project->Configuration Properties->Linker->Input->Delay Loaded Dlls

along with #include of Dll''s header file and _declspec(dllimport) of the exported function..







Share this post


Link to post
Share on other sites
There is a constraint cos of which i cant use DLLimport...p/Invoke for importing...so i need to link the DLL at Load time only and not at execut time...


--as far as Pete''s advice goes about formating the title...i wud say keep it for urself ...i am pretty happy with what i have given...




Share this post


Link to post
Share on other sites
quote:
Original post by Jell
--as far as Pete''s advice goes about formating the title...i wud say keep it for urself ...i am pretty happy with what i have given...



It looks like you''re shouting. And people have to open the post to find what the gist of the problem is as the title doesn''t communicate it. You''re more likely to get people to even bother to look at this question if you change the title. This is serious advice and if you want me to keep it to myself then I think you haven''t understood that it is for your good that I am saying this.

Share this post


Link to post
Share on other sites
i did consider ur advice...

guess like u have come to forum after a long time...
i have been posting my queries almost regularly from last 1 month, the query i posted is another one in the series...
so i was calling out for those set of people who have been consistently replying to my queries...

it was not my first post..neither am i ignorant of how to call attention elegantly



Share this post


Link to post
Share on other sites
Agreed, you should have picked a more elegant topic title.

Anyway, did you set the project properties for the build type you''re trying to make(There''s at least two: debug and release) and you have to set the right properties for them all.

Share this post


Link to post
Share on other sites