Stupid Newbie Question?

  • Thread starter Thread starter Mike Marshall
  • Start date Start date
M

Mike Marshall

Hi all

I've got an Unmanaged C++ DLL that basically acts as a wrapper for some
classes, that then wrap up some C libraries (namely CLucene and SQLite)

I've now trying to make use of those classes within my C++ .NET Webservice

I've got some code like this

SearchResults RepositoryNETClass::SearchRepository(String* Query, int
Number)
{
SearchResults oResults;
oResults.NumberOfHits = Number;
oResults.Query = Query;
oResults.Test = 100;

//Create the session
KAppRepositorySession* pRepositorySession = new KAppRepositorySession();
if (pRepositorySession->OpenRepository("default") != 0)
{
//Can't connect to the db :(
MessageBox(NULL,"Unable to connect","KApp Repository Demo",MB_OK);
return FALSE;
}
else
{
HitArray data = new SearchHit __gc[Number];
if (Number > 0 && Number <= 10)
{
for (int i = 0; i < Number; i++)
{
data.Title = new String("Hit ");
data.Title->Concat(i.ToString());
data.ID = i;
}
}
oResults.Hits = data;
}
return oResults;
}

but I get all manner of linker errors when i compile this.

I had a hunt around and found out about consuming unmanaged code when its
just functions exported out of a DLL but couldn't find anything relating to
classes.

Any help would be greatly appreciated

Mike Marshall
 
Hi Mike,

The Help topic "Accessing C++ Code from .NET Framework Objects"
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/h
tml/vcmg_accessingcodefromframeworkobjects.asp) might be useful for you.
It describes how to write a managed wrapper class for unmanaged C++ classes.

-- Molly

---
Molly Bostic
..NET Developer Platform User Education

This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: "Mike Marshall" <[email protected]>
Subject: Stupid Newbie Question?
Date: Fri, 26 Sep 2003 15:23:10 +0100
Newsgroups: microsoft.public.dotnet.general
Hi all

I've got an Unmanaged C++ DLL that basically acts as a wrapper for some
classes, that then wrap up some C libraries (namely CLucene and SQLite)

I've now trying to make use of those classes within my C++ .NET Webservice

I've got some code like this

SearchResults RepositoryNETClass::SearchRepository(String* Query, int
Number)
{
SearchResults oResults;
oResults.NumberOfHits = Number;
oResults.Query = Query;
oResults.Test = 100;

//Create the session
KAppRepositorySession* pRepositorySession = new KAppRepositorySession();
if (pRepositorySession->OpenRepository("default") != 0)
{
//Can't connect to the db :(
MessageBox(NULL,"Unable to connect","KApp Repository Demo",MB_OK);
return FALSE;
}
else
{
HitArray data = new SearchHit __gc[Number];
if (Number > 0 && Number <= 10)
{
for (int i = 0; i < Number; i++)
{
data.Title = new String("Hit ");
data.Title->Concat(i.ToString());
data.ID = i;
}
}
oResults.Hits = data;
}
return oResults;
}

but I get all manner of linker errors when i compile this.

I had a hunt around and found out about consuming unmanaged code when its
just functions exported out of a DLL but couldn't find anything relating to
classes.

Any help would be greatly appreciated

Mike Marshall
 
Back
Top