1

I want to use the Point Cloud Library PCL in C#. In order to do it I am writing a wrapper in C++/CLI that would have a managed class exposing the functions. However I encounter the following problem. When I use a "pure" dll with C# console application, it works nicely. However, when I link my dll (in C++/CLI) with PCL (by adding include and library folders to linker, VC++, and C++ in project properties and dependencies) and build it (with the exact same code, without even including the PCL files to the code, and then run the C# console app (which uses the wrapper) then, although it builds, it crashes when run with the following error: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt.". Like I said, the thing that causes it is simply linking the dll used in my project. Oh, and it's also worth noting that this happens only if I make an instance of a class from the wrapper in my C# code. Any idea why this happens and how to fix it? EDIT: it is not a duplicate of this one as it has nothing to do with Nvidia Manager, and is when I link a library. I see no similarities


EDIT2: I have narrowed down the error causing library to one of the libboost-xxx.lib not sure which one (since they mutually require each other to compile. Not sure how to solve it since PCL requires it, but the error clearly is with the boost libraries

Community
  • 1
  • 1
Spidy
  • 11
  • 3
  • 1
    Possible duplicate of [Attempted to read or write protected memory. This is often an indication that other memory is corrupt](http://stackoverflow.com/questions/4074585/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-ot) – Danieboy Jul 29 '16 at 11:07
  • 1
    I cannot possibly understand (no offence) how this could be a duplicate. My error is caused by something else, it is thrown always at the same time (when starting the program) and has a lot to do with linking with a library. The simple fact that the exception thrown is the same doesn't make it the same issue. – Spidy Jul 29 '16 at 11:11
  • Are any of the included header files setting packing / alignment options or something via a pragma which is effecting your code? – GazTheDestroyer Jul 29 '16 at 11:29
  • I am using '#pragma once' in my wrapper (in C++/CLI) indeed. But commenting it out doesn't solve the problem – Spidy Jul 29 '16 at 11:32
  • no I mean in the PCL headers that I assume you are including in your wrapper project? If you comment out the #includes does it still crash? – GazTheDestroyer Jul 29 '16 at 11:39
  • Yes, like I said I DON'T have any includes (currently) from the PCL. The only code I have is one managed class with a simple addition function (since it's a test). And the thing I have in my C# code is making an instance of the class: ManagedClass testClass = new ManagedClass(); – Spidy Jul 29 '16 at 11:46

0 Answers0