Click here to Skip to main content
15,890,845 members
Home / Discussions / C#
   

C#

 
GeneralRe: Combobox displayMembers with .dbml objects Pin
phil.o2-Jun-11 22:05
professionalphil.o2-Jun-11 22:05 
QuestionHow to pass .net (C#) string to unmanaged C++ dll? Pin
Tesic Goran29-May-11 22:05
professionalTesic Goran29-May-11 22:05 
AnswerRe: How to pass .net (C#) string to unmanaged C++ dll? Pin
Luc Pattyn29-May-11 22:40
sitebuilderLuc Pattyn29-May-11 22:40 
GeneralRe: How to pass .net (C#) string to unmanaged C++ dll? [modified] Pin
Tesic Goran29-May-11 22:59
professionalTesic Goran29-May-11 22:59 
AnswerRe: How to pass .net (C#) string to unmanaged C++ dll? [modified] Pin
Luc Pattyn29-May-11 23:28
sitebuilderLuc Pattyn29-May-11 23:28 
GeneralRe: How to pass .net (C#) string to unmanaged C++ dll? Pin
Tesic Goran29-May-11 23:37
professionalTesic Goran29-May-11 23:37 
AnswerRe: How to pass .net (C#) string to unmanaged C++ dll? Pin
Luc Pattyn29-May-11 23:49
sitebuilderLuc Pattyn29-May-11 23:49 
GeneralRe: How to pass .net (C#) string to unmanaged C++ dll? [modified] Pin
Tesic Goran30-May-11 0:00
professionalTesic Goran30-May-11 0:00 
Ok. The whole code is here:

extern "C" __declspec(dllexport) void decode(char *encString, char *answer )
{
	// Initialize COM.
        HRESULT hr = CoInitialize(NULL);
	IDecoderPtr pIDec(__uuidof(UfoDecoder));

	BSTR k1 = bstr_t(encString);
	BSTR k2 = bstr_t(answer);

	pIDec->Decode(&k1,&k2);

	SysFreeString(k1);
	SysFreeString(k2);
}


int _tmain(int argc, _TCHAR* argv[])
{
	char *xml = (char*)malloc(5000000*sizeof(char));
	char* str = "Some encoded string";
        int length = strlen(str);

	decode(str, xml);

	printf("Decoded = %s",xml);
	
	int vol = strlen(xml);
	return 0;
}


[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("F4100FB3-75C5-4C4F-8034-9B836598DD1E")]
public interface IDecoder
{
    [return: MarshalAs(UnmanagedType.BStr)]
    string Decode([MarshalAs(UnmanagedType.BStr)] ref string encodedString);


[ComVisible(true)]
[Guid("85F2DFFB-5655-40DD-A779-94388A2773DC")]
[ProgId("UfoDecodeWrapper.UfoDecoder")]
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(IDecoder))]
public class UfoDecoder : IDecoder
{
    public string Decode(ref string encodedString)
    {
        byte[] dec64 = Base64Decode(encodedString);
        byte[] unzipped = CompressionUtility.Decompress(dec64);

        return BinToXml(unzipped);
    }


[ADDED]
If str variable in _tmain function in this line:

char* str = "Some encoded string";

is not so long we're getting Xml.

But, if str is very long, the error comes up.
[/ADDED]
modified on Monday, May 30, 2011 6:22 AM

AnswerRe: How to pass .net (C#) string to unmanaged C++ dll? Pin
Luc Pattyn30-May-11 0:22
sitebuilderLuc Pattyn30-May-11 0:22 
GeneralRe: How to pass .net (C#) string to unmanaged C++ dll? Pin
Tesic Goran30-May-11 0:26
professionalTesic Goran30-May-11 0:26 
GeneralRe: How to pass .net (C#) string to unmanaged C++ dll? Pin
Tesic Goran30-May-11 0:57
professionalTesic Goran30-May-11 0:57 
GeneralRe: How to pass .net (C#) string to unmanaged C++ dll? Pin
MicroVirus30-May-11 4:24
MicroVirus30-May-11 4:24 
AnswerRe: How to pass .net (C#) string to unmanaged C++ dll? Pin
DaveyM6929-May-11 22:58
professionalDaveyM6929-May-11 22:58 
GeneralRe: How to pass .net (C#) string to unmanaged C++ dll? Pin
Tesic Goran29-May-11 23:07
professionalTesic Goran29-May-11 23:07 
QuestionDefault datetime.now in datatable and bound datagridview Pin
LordZoster29-May-11 21:32
LordZoster29-May-11 21:32 
AnswerRe: Default datetime.now in datatable and bound datagridview Pin
Andy_L_J29-May-11 21:37
Andy_L_J29-May-11 21:37 
GeneralRe: Default datetime.now in datatable and bound datagridview Pin
LordZoster29-May-11 21:51
LordZoster29-May-11 21:51 
AnswerRe: Default datetime.now in datatable and bound datagridview Pin
Paramu197329-May-11 21:47
Paramu197329-May-11 21:47 
GeneralRe: Default datetime.now in datatable and bound datagridview Pin
LordZoster29-May-11 22:07
LordZoster29-May-11 22:07 
GeneralRe: Default datetime.now in datatable and bound datagridview Pin
Paramu197329-May-11 22:13
Paramu197329-May-11 22:13 
GeneralRe: Default datetime.now in datatable and bound datagridview Pin
LordZoster29-May-11 22:17
LordZoster29-May-11 22:17 
GeneralRe: Default datetime.now in datatable and bound datagridview Pin
LordZoster29-May-11 22:37
LordZoster29-May-11 22:37 
GeneralRe: Default datetime.now in datatable and bound datagridview Pin
Andy_L_J29-May-11 22:47
Andy_L_J29-May-11 22:47 
GeneralRe: Default datetime.now in datatable and bound datagridview Pin
Paramu197329-May-11 22:41
Paramu197329-May-11 22:41 
GeneralRe: Default datetime.now in datatable and bound datagridview Pin
LordZoster29-May-11 23:14
LordZoster29-May-11 23:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.