HELP: webservice ASP.net (c++) using unmanaged c++: Link problem

KristofThys

Newcomer
Joined
Sep 20, 2004
Messages
1
webservice ASP.net (c++) using unmanaged c++: Link problem

Hello,

I've been struggling for weeks with this problem, I hope I find some help here...

To start, in our company, we have a large existing c++ project (native code, unmanaged c++)

The objective is to write a webservice for some of the functionalities from this project.
The best way to do this in Visual Studio .NET 2003 seems to me by creating an ASP.NET Web service in c++.
I create the default template, wich works just fine.
Now I want to use some unmanaged c++ code, so I write a managed wrapperclass and delegate the old routines from identical

methods. When I test this with an unmanaged c++ class in the same project, this works fine.
But when I include an header from the old project, and call some old routines, I get link problems for every implemented

routine.

e.g.:
error LNK2001: unresolved external symbol "public: __thiscall test::~test(void)" (??1test@*****FQAE@XZ)
error LNK2001: unresolved external symbol "public: char * __thiscall test::function(int,int)" (?function@test@*****FQAEPADHH@Z)
...

I've read http://msdn.microsoft.com/library/d...stechart/html/vcconMixedDLLLoadingProblem.asp

concerning mixed dll problems, and figured out this could be my problem, and tried the solution at :
http://support.microsoft.com/?id=814472
But here rises another problem for me, none of the given solutions seems applicable to my particular problem,

I don't think my DLL isn't entered using DLL exports (__declspec(dllexport)),
not it seems to be a COM-based DLL.
and "Consumers of your DLL can use managed code, and your DLL contains either DLL exports or managed entry points." doesnt

work for my project neither...

So I'm pretty stuck...

I need some help, if you wish you can simulate my problem:

just create a default ASP.NET webservice : called e.g. Webservice

add managedwrapper.h :

Code:
  #pragma once

  #include "test.h"

  #pragma managed

  __gc class ManagedWrapperClass{
  private:
   test * t;
  public:
   ManagedWrapperClass() {t = new test;}
   ~ManagedWrapperClass() {delete t;}
   const char* function() {return t->function();}
  };

in webserviceclass.cpp, include "managedwrapper.h" and rewrite the helloworld routine :

Code:
  String* webserviceClass::HelloWorld()
  {
    ManagedWrapperClass *m = new ManagedWrapperClass();
    return m->function();
  }

and now create a console application (.NET) (c++) e.g. testconsole

add a file test.h :
Code:
 class test{
 public:
   test() {}
   ~test() {}
   char* function();
 };

and a file test.cpp :
Code:
#include "test.h"
char* test::function()
{
  return "Wow you really did it...";
}

in webservice -> project settings -> c/c++ -> General -> Additional include Directories : add ../testconsole



I want to thank everyone who tries to help me with this one!
I've just started working and after 3 years of studying in VC6.0.. .NET and webservices are pretty new...



Thanks in Advance,




Kristof Thys
 
Last edited:
Back
Top