Please explain this behaviour...

Well, my problem is that I have my code written in C# and it works perfectly, no bugs at all.
If I write the same code in C++ with C++ standards, the code works ...sometimes.
And this is the big issue that is eating my brains.
I'm writing a Dll for C# to protect my code.

Now, about how I do this:

I simply have a bunch of classes that are set up correctly using regular C++ standards (constructors and deconstructors to initialise variables and to clear the variables etc. etc.) Now the issue comes in like this:

When I first run the C# app that uses my DLL writen in C++ it sometimes runs and sometimes it crashes, it like has a mind of its own. The issue came in when I was about to switch out a placeholder code. The placeholder code worked fine, but my proper code is about the same as the placeholder but with some more variables. The big differences are that the new code is ina new class and there is a array to vector copying in the constructor.

I cant believe that a new class or a simple data movement is so hard on the dll that it crashes the C# program.

So my brains are fryed now and I'm asking for help & explanation on how to properly write C++ code in my case (DLL for C# application)
And why isnt C# to C++ code porting as straight forward as it looks like (compiler also has no issues with it, but the application itself has hard times dealing with the Dll)

Thanks!
What was your placeholder code written in?

Do you know what the differences among managed, unmanaged, and mixed-mode assemblies are? Are you familiar with P/Invoke?
closed account (o1vk4iN6)
I cant believe that a new class or a simple data movement is so hard on the dll that it crashes the C# program.

Well you are trying to use two very different implementations, under the bonnet, with each other. If you have no knowledge of how either of those work you are going to be shooting yourself in the foot by writing code that can work and be used in C++ but not C# and vice versa. Maybe someone can help spot such error if you post your code.
edit: it was the incorrect method of filling the vectors.
Last edited on
I switched from codeblocks+Mingw to visual c++2010. The error still remains, so it's clearly an issue of how I have done something wrong. the only thing is that I dont know what I've done wrong...
Topic archived. No new replies allowed.