__declspec(dllexport) to return char but errors in VB6



I have a C# class that I wan't to be able to use in VB6 and VBA
applications. To do this I was trying to use a mixed managed VC++ dll and
export a function. Doing this I get an error "The memory could not be
"read"".

Can any one explain what I am doing wrong?

This is my Code.


..CPP

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace System::Collections;
using namespace WdCadTmInfo;
#define WDINFO_LINKAGE __declspec(dllexport)
#include "PlotAccounting-C.h"

__gc class ManagedObjects{
public:
};

BOOL APIENTRY
DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{

return TRUE;
}

extern "C"{
WDINFO_LINKAGE char* getWdInfo(char* Param){

wdCadTeamInfo* tmpInfo = new wdCadTeamInfo();

IntPtr ptr = Marshal::StringToHGlobalAnsi(tmpInfo->GetWdCadTmInfo(Param));
char __nogc* pStr = static_cast<char*>(ptr.ToPointer());

Marshal::FreeHGlobal(ptr);

return pStr;

}
}

..H

#ifndef WDINFO_LINKAGE
#define WDINFO_LINKAGE __declspec(dllimport)
#endif
extern "C"{
WDINFO_LINKAGE char* getWdInfo(char* Param);
}


.



Relevant Pages

  • RE: .NET Scripting IDE Integration
    ... namespaces you mentioned for compiling and running .NET code at runtime. ... We were able to integrate VBA into a .NET app to reproduce the current ... As for pure .NET runtime scripting support, ... > found the following namespace which contains some components and interfaces ...
    (microsoft.public.dotnet.general)
  • Re: [PATCH][RFC] Simple tamper-proof device filesystem.
    ... Some users have to continue using brain dead legacy applications ... are not always using the same namespace. ... If the daemon can't be contacted or doesn't want to do a mknod for you, ... But I think that the chance that any process needs to create device nodes ...
    (Linux-Kernel)
  • Re: The type or namespace name Windows does not exist in the class or namespace System (are you miss
    ... And why do you need this namespace for? ... It's meant to be used for Windows ... forms applications! ... > Ray Cheung ...
    (microsoft.public.dotnet.general)
  • Namespace Access
    ... I want to register my namespace so all applications on the server have access. ... I have it placed individualy in the bin folders and it is a pain to update all sites. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to color listbox items at runtime?
    ... You can't use classes from the System.Web.UI.WebControls namespace as ... those are for ASP.NET applications, not windows forms applications, as you ... The way to do this is to custom draw the item. ...
    (microsoft.public.dotnet.languages.csharp)

Loading