an unmanaged type cannot derive from a managed type

  • Thread starter andy6 via DotNetMonster.com
  • Start date
A

andy6 via DotNetMonster.com

I took a c++ 6.0 project and converted it to c++ .net 2005 project. I want to
make a web service out of it. One of the new files I created was a cpp where
I have the webmethod pointing to a function in the previously 6.0 code and I
get the error noted below. What I don't understand is since I created this
cpp as a new file in .net and inherited from a .net base class then why would
I get this error? Both the class and base class to me should be managed.
Below is the code, can you help me resolve the error?

error C3625: 'HCFAWebService::HCFAWebServiceEntryPoint': an unmanaged type
cannot derive from a managed type 'System::Web::Services::WebService' - line
12

HCFAWebServiceEntryPoint.h
============================
#using <System.Web.Services.dll>
#using <System.dll>

using namespace System;
using namespace System::Web;
using namespace System::Web::Services;

namespace HCFAWebService
{

public class HCFAWebServiceEntryPoint : public WebService
{ // Visual Studio points to line 12 as being here

public:
[System::Web::Services::WebMethod]
int CallHCFA( int editno, LPSTR inbuf, LPSTR inSV, LPSTR inDB, LPSTR
inUI, LPSTR inPW, LPSTR inPCA, LPSTR inDSN, LPSTR inFl);
};
}


// HCFAWebServiceEntryPoint.cpp : main project file.
//
#include "stdafx.h"
#include "HCFAWebServiceEntryPoint.h"
#include "Ecghcfa.h"
#include "Global.asax.h"

namespace HCFAWebService
{
int CallHCFA(int a, LPSTR b, LPSTR c, LPSTR d, LPSTR e, LPSTR f, LPSTR g,
LPSTR h, LPSTR k)
{
CEcghcfaApp *pValidateClaim = new CEcghcfaApp();

int ab = pValidateClaim->ValidateClaim(a,b,c,d,e,f,g,h,k);

delete pValidateClaim;

return ab;
}
}
 
D

Doug Harrison [MVP]

I took a c++ 6.0 project and converted it to c++ .net 2005 project. I want to
make a web service out of it. One of the new files I created was a cpp where
I have the webmethod pointing to a function in the previously 6.0 code and I
get the error noted below. What I don't understand is since I created this
cpp as a new file in .net and inherited from a .net base class then why would
I get this error? Both the class and base class to me should be managed.
Below is the code, can you help me resolve the error?

error C3625: 'HCFAWebService::HCFAWebServiceEntryPoint': an unmanaged type
cannot derive from a managed type 'System::Web::Services::WebService' - line
12

HCFAWebServiceEntryPoint.h
============================
#using <System.Web.Services.dll>
#using <System.dll>

using namespace System;
using namespace System::Web;
using namespace System::Web::Services;

namespace HCFAWebService
{

public class HCFAWebServiceEntryPoint : public WebService
{ // Visual Studio points to line 12 as being here

public:
[System::Web::Services::WebMethod]
int CallHCFA( int editno, LPSTR inbuf, LPSTR inSV, LPSTR inDB, LPSTR
inUI, LPSTR inPW, LPSTR inPCA, LPSTR inDSN, LPSTR inFl);
};
}

Use the "ref" keyword when you declare the class:

public ref class HCFAWebServiceEntryPoint : public WebService
 
A

andy6 via DotNetMonster.com

Doug said:
I took a c++ 6.0 project and converted it to c++ .net 2005 project. I want to
make a web service out of it. One of the new files I created was a cpp where
[quoted text clipped - 29 lines]

Use the "ref" keyword when you declare the class:

public ref class HCFAWebServiceEntryPoint : public WebService


Beautiful! Thank you!

I had to look it up in VS2005 documentation...here's what it said:

Declaration of a Managed Class Type

The way to declare a reference class type changed from Managed Extensions for
C++ to Visual C++ 2005.

In Managed Extensions, a reference class type is prefaced with the __gc
keyword. In the new syntax, the __gc keyword is replaced by one of two spaced
keywords: ref class or ref struct. The choice of struct or class simply
indicates the public (for struct) or private (for class) default access level
of its members declared within an initial unlabeled portion of the body of
the type.

Similarly, in Managed Extensions, a value class type is prefaced with the
__value keyword. In the new syntax, the __value keyword is replaced by one of
two spaced keywords: value class or value struct.

An interface type, in Managed Extensions, was indicated with the keyword
__interface. In the new syntax, this is replaced with interface class.

Thanks Doug!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top