Hi folks,

I have a strange problem, seems to be Garbage Collector in managed memory. There is an unmanaged dll which makes a call to my managed dll with giving a structure as a parameter. Managed dll takes this param and sets the values in the struct. when debugging on the managed side, all the values in the struct are meaningfull but when i pas back to unmanaged dll side, some values in the struct became huge or meaningles.

I have played arround marshalling, pinned pointers etc. but when the DVRSET param is passed to unmanaged c++ dll, values of the struct became abnormal...

Thanks for your further help...

Here is the code
structure defined in both sides...
Code:
struct DVRSET
	{

		//Top Values
		bool	DoRender;

		//Global Switches
		bool	GS_Geo_Displacement;
		bool	GS_Geo_ForceBackFaceCulling;
		
		bool	GS_Lighting_Lights;
		bool	GS_Lighting_DefaultLights;
		bool	GS_Lighting_HiddenLights;
		bool	GS_Lighting_Shadows;
		bool	GS_Lighting_ShowGIOnly;
		
		bool	GS_Materials_ReflectionRefraction;
		bool	GS_Materials_MaxDepth;
		int		GS_Materials_MaxDepthValue;
		bool	GS_Materials_Maps;
		bool	GS_Materials_FilterMaps;
		bool	GS_Materials_FilterMapsForGUI;
		int		GS_Materials_MaxTrunspLevel;
		float	GS_Materials_TrunspCutOff;
		
		float	GS_RayTracing_SecondaryRayBias;
		
		bool	GS_IndirectIllumination_DontRenderFinalImage;
		
		//Environment Settings
		int		ES_BGColorR;
		int		ES_BGColorG;
		int		ES_BGColorB;

		int		ES_ReflectColorR;
		int		ES_ReflectColorG;
		int		ES_ReflectColorB;

		int		ES_RefractColorR;
		int		ES_RefractColorG;
		int		ES_RefractColorB;

		int		ES_GIColorR;
		int		ES_GIColorG;
		int		ES_GIColorB;

		float	ES_BGTexMultiplier;
        float	ES_ReflectTexMultiplier;
        float	ES_RefractTexMultiplier;
        float	ES_GITexMultiplier;


		//Color Mapping
		int		CM_Type;
		float	CM_DarkMultiplier;
		float	CM_BrightMultiplier;
		float	CM_Gama;
		float	CM_ClampLevel;
		bool	CM_SubPixelMapping;
		bool	CM_ClampOutput;
		bool	CM_AdaptationOnly;

		//Indirect Illumination (GI)
		bool	GI_On;
		bool	GI_ReflectCaustics;
        bool	GI_RefractCaustics;
        float	GI_Saturation;
        float	GI_Contrast;
        float	GI_ContrastBase;
		float	GI_PrimaryMultiplier;
        float	GI_SecondaryMultiplier;
        int		GI_PrimaryEngine;
        int		GI_SecondaryEngine;

		//Irradiance Map
		int		IM_MinRate;
		int		IM_MaxRate;
		int		IM_SubDivs;
		int		IM_InterpSamples;
		int		IM_InterpFrames;
		float	IM_ColorThreshold;
		float	IM_NormalThreshold;
		float	IM_DistanceThreshold;
		bool	IM_DetailEnhancement;
		float	IM_DetailRadius;
		float	IM_DetailSubdivsMulti;
		int		IM_DetailScale;
		int		IM_InterpolationMode;
		int		IM_LookupMode;
		bool	IM_Multipass;
		bool	IM_RandomizeSamples;
		bool	IM_CheckSampleVisibility;
        bool	IM_ShowCalcPhase;
        bool	IM_ShowDirectLight;
        bool	IM_ShowSamples;
		int		IM_Mode;
		//Light Cache
		int		LC_SubDivs;
		float	LC_SampleSize;
		int		LC_FilterType;
		int		LC_FilterSamples;
		float	LC_FilterSize;
		bool	LC_PreFilter;
		int		LC_PreFilterSamples;
		int		LC_Depth;
		bool	LC_ShowCalcPhase;
		bool	LC_StoreDirectLight;
		bool	LC_WorldScale;
		int		LC_Mode;
		bool	LC_UseForGlossyRays;
		bool	LC_AdaptiveSampling;
		int		LC_NumPasses;
		//Region Size
		int		RG_XC;
		int		RG_YC;
		//Output Settings
		int OS_ImageSize;
	};
the managed code
Code:
extern "C"
{
	__declspec(dllexport) bool __cdecl SetStruct(DVRSET* settings) 
	{
		bool retVal = false;
		DinoVRay::TestForm frm;
		frm.Settings = settings;
		if(frm.ShowDialog() == System::Windows::Forms::DialogResult::OK)
			retVal = true;
		else
			retVal = false;
		settings = frm.Settings;
		return retVal;
	}
}
unmanaged side
Code:
	//.NET DLL Bridge cagiriliyor....
	HINSTANCE hBridgeDLL = LoadLibrary("DinoVRay.dll");
	FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hBridgeDLL), "SetStruct");
	typedef void (__cdecl * pICFUNC)(DVRSET*);
	pICFUNC MyFunction;
    MyFunction = pICFUNC(lpfnGetProcessID);
	
	DVRSET vrset;
	
	MyFunction(&vrset); //-> Get The Form Ula