I have a WCF referencing a managed assembly in the project. The managed assembly inturn invokes an unmanaged assembly which is copied to the bin folder of the WCF. During runtime, calling any method in managed assembly throws exception "Attempted to read or write protected memory. This is often an indication that other memory is corrupt.". The stack trace looks like this.
at System.Runtime.InteropServices.Marshal.ReadByte(IntPtr ptr, Int32 ofs) at oi5kwsk4ohr1o5wkubkiw_tiky78.qld4y3ifhv(UInt64 a4cp1ga2, UInt32 m8l, UInt32 eaw89) at oi5kwsk4ohr1o5wkubkiw_tiky78.rky4uywx5x7y9oj4lrlc5() at MyManagedAssembly.Dosomething() at MyWebservice.Authenticate()
From the stack trace, it looks like the managed assembly is loaded into the memory and the methods are properly called till the ReadByte method is invoked which i believe is where the unmanaged code is invoked. When the WCF is pushlished on IIS, the managed code is getting copied and during runtime, gets copied to temp folder created by IIS. How about the unmanaged dependant assembly that sits next to the managed code? How to get it copied over along with the managed code?