Compiler Error CS1919
Visual Studio 2012
Unsafe type 'type name' cannot be used in object creation.
The new operator creates objects only on the managed heap. However, you can create objects in unmanaged memory indirectly by using the interoperability capabilities of the language to call native methods that return pointers.
To correct this error
-
Use a safe type in the new object creation expression. For example, use char or int instead of char* or int*.
-
If you must create objects in unmanaged memory, use a Win32 or COM method or else write your own function in C or C++ and call it from C#.