G
Guest
Hi,
I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid the usage of old style COM, my alternative is to expose my unmanaged interface through the CLI, to achieve that I have created a mixed mode DLL in which my unmanaged class are defined.
When referencing the DLL just described in another mixed mode EXE I can see the unmanaged methods through the 'Object browser' BUT, I can't reference them through code, the namespace of the DLL is not recognised....
When using a managed C# EXE to reference the unmanaged CLI assembly the namespace is identified BUT the contained objects are not...
Is it possible to expose unmanaged interface through the CLI??? is it possible to reference this type of interface through another mixed mode assembly? will VS2005 support this kind of functionality?
Bellow is a fragmet of the mixed mode ( unmanaged ) assembly I have created:
namespace Unmanaged
{
__nogc interface IBlockAllocator;
__nogc interface IDataBlock
{
virtual HRESULT Initialize(IBlockAllocator *pAlloc, const DWORD dwSize, void *pExArg) = 0;
virtual IBlockAllocator *Allocator()= 0;
virtual BYTE *Pointer()= 0;
virtual const DWORD Size()= 0;
virtual LONG AddRef() =0;
virtual LONG Release()= 0;
virtual void Dispose()= 0;
};
__nogc class CDataBlock : public IDataBlock
{
protected:
DWORD m_dwSize;
LONG m_lRefCount;
BYTE *m_pData;
IBlockAllocator *m_pAlloc;
public:
IBlockAllocator *Allocator() { return m_pAlloc;}
BYTE *Pointer() { return m_pData;}
const DWORD Size() { return m_dwSize;}
LONG AddRef() { return InterlockedIncrement(&m_lRefCount); }
LONG Release()
{
if(0 != InterlockedDecrement(&m_lRefCount))
return m_lRefCount;
m_pAlloc->ReturnToCache(this);
return 0;
}
void Dispose() { delete this; }
HRESULT Initialize(IBlockAllocator *pAlloc, const DWORD dwSize, void *pExArg = 0)
{
m_pAlloc = pAlloc;
m_dwSize = m_pAlloc->GetBlockSize();
m_pData = new BYTE[m_dwSize];
};
CDataBlock() : m_lRefCount(0)
{
}
~CDataBlock()
{
delete m_pData;
m_pData = 0;
m_pAlloc = 0;
}
};
};// Unmanaged
Nadav
http://www.ddevel.com
I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid the usage of old style COM, my alternative is to expose my unmanaged interface through the CLI, to achieve that I have created a mixed mode DLL in which my unmanaged class are defined.
When referencing the DLL just described in another mixed mode EXE I can see the unmanaged methods through the 'Object browser' BUT, I can't reference them through code, the namespace of the DLL is not recognised....
When using a managed C# EXE to reference the unmanaged CLI assembly the namespace is identified BUT the contained objects are not...
Is it possible to expose unmanaged interface through the CLI??? is it possible to reference this type of interface through another mixed mode assembly? will VS2005 support this kind of functionality?
Bellow is a fragmet of the mixed mode ( unmanaged ) assembly I have created:
namespace Unmanaged
{
__nogc interface IBlockAllocator;
__nogc interface IDataBlock
{
virtual HRESULT Initialize(IBlockAllocator *pAlloc, const DWORD dwSize, void *pExArg) = 0;
virtual IBlockAllocator *Allocator()= 0;
virtual BYTE *Pointer()= 0;
virtual const DWORD Size()= 0;
virtual LONG AddRef() =0;
virtual LONG Release()= 0;
virtual void Dispose()= 0;
};
__nogc class CDataBlock : public IDataBlock
{
protected:
DWORD m_dwSize;
LONG m_lRefCount;
BYTE *m_pData;
IBlockAllocator *m_pAlloc;
public:
IBlockAllocator *Allocator() { return m_pAlloc;}
BYTE *Pointer() { return m_pData;}
const DWORD Size() { return m_dwSize;}
LONG AddRef() { return InterlockedIncrement(&m_lRefCount); }
LONG Release()
{
if(0 != InterlockedDecrement(&m_lRefCount))
return m_lRefCount;
m_pAlloc->ReturnToCache(this);
return 0;
}
void Dispose() { delete this; }
HRESULT Initialize(IBlockAllocator *pAlloc, const DWORD dwSize, void *pExArg = 0)
{
m_pAlloc = pAlloc;
m_dwSize = m_pAlloc->GetBlockSize();
m_pData = new BYTE[m_dwSize];
};
CDataBlock() : m_lRefCount(0)
{
}
~CDataBlock()
{
delete m_pData;
m_pData = 0;
m_pAlloc = 0;
}
};
};// Unmanaged
Nadav
http://www.ddevel.com