Hello!
I'm trying to fix single quote bug in the code:
std::string Index;
connection->Open();
String^ sTableName = gcnew String(TableName.c_str());
String^ insertstring = String::Format("INSERT INTO {0} (idx, rec, date) VALUES (@idx, @rec, getdate())", sTableName);
SqlCommand^ command = gcnew SqlCommand(insertstring, connection);
St...
I am writing an application that required the development of an engine for handling data, but the engine had to be replaceable by another depending on the customers' need. Since each customer had very different needs, I wanted to make each engine separated from the others so we could only deliver the application with the engines the cust...
I have a test that I'm writing in MSTest, which is managed C++, and I'm trying to test an unmanaged class. Specifically, I'm trying to use the PrivateObject class to call a private method.
This is the code that I have so far:
CUnmanagedType foo;
PrivateObject privateFoo = gcnew PrivateObject( foo );
CString strFromFoo = privateFoo.Inv...
I'm new to managed C++.
I have two managed C++ projects in a single .sln, Project Lib and Project LibTest. LibTest makes use of Lib.
Lib compiles and links fine. The project is set as a .dll.
LibTest is also compiled as .dll, but when it goes into linking, I get "unresolved token" on all of the Lib::methods. Those methods definitions ...
Can someone please post a simple code that would convert
System::String^
to
C++ std::string
?
i.e I just want to assign the value of
String^ originalString;
to
std::string newString;
...
In the .net CLR Object is the base for all class objects, but not basic types (e.g. int, float etc). How can I use basic types like Object?
I.e. Like Boost.Variant?
E.g. like :-
object intValue( int(27) );
if (intValue is Int32)
...
object varArray[3];
varArray[0] = float(3.141593);
varArray[1] = int(-1005);
varArray[2] = string("...
I'm trying to write an application in Managed C++, but I cannot work out how to declare an array of strings.
String^ linet[];
throws an error
'System::String ^' : a native array cannot contain this managed type
So I suppose there's a different way to do this for managed data types. What exactly is it?
...
I'm a little confused on creating a DependencyProperty for properties that depend on external sources. For example, in an ultrasound application I'm writing, I currently have the following in a Managed C++ wrapper (translated to C# for simplicity on here, implementing INotifyPropertyChanged):
public int Gain
{
get { return ultrasoun...
Bit of a history lesson here. I'm working on a legacy C++/MFC application and am trying to start a incremental modernization by pushing components written in C# (WinForms and later WPF).
I'm stucking using .Net/1.1 and VS/2003 for many reasons which are impossible to resolve in the near future.
Currently, as a proof of concept, someth...
Hi
We have native Win32 C++ code and a set of C# assemblies which we wish to call from the C++ code. I summaries our optios as:
Use COM. The C# code would need to be decorated with additional attributes (GUID, COMVisible). The C# assemblies would need to be registered regasm and would then be available to the native C++ code via CO...
Hi,
I'm getting the following exception when I run my application in Release mode from Visual C++.
Unhandled Exception:
System.AccessViolationException:
Attempted to read or write protected
memory. This is often an indication
that other memory is corrupt. at
_cexit() at .LanguageSupport._UninitializeDefaultDomain(Vo...
Hello,
Working on a VisStudio 2008 addin, using managed C++ (C++/CLR in the New Project wizard).
In the OnConnection() function, I want to add a handler to the WindowEvents collection.
When I do this:
// Hook up events
EnvDTE::Events ^ events = _applicationObject->Events;
EnvDTE::WindowEvents ^winEvents = events->WindowEve...
I need to get up to speed with C++ quite quickly (I've never used it previously) - is learning through Visual Studio (i.e. Managed C++) going to be any use? Or will I end up learning the extensions and idiosyncracies of C++ in VS, rather then the language itself?
If learning in VS is not recommended, what platform / IDE do you guys sugg...
Try as I might, I cannot convert this Managed C++ code to C++/CLI. Can someone give a pointer (pun intended)?
static String *ignoreStrings[];
Later in the code, an Add(string) method is called on it. Elsewhere, in some C# code,
new String[]{"foo", "bar"}
is passed into a function that is somehow cast into the type of ignoreStrin...
Since .NET Value types (managed C++ structs) are stored on the Stack why is it (or, alternatively is it actually) necessary to pin_ptr them in order to pass a pointer to an unmanaged function?
Eg. BYTE b[100];
If I pass &b to an unmanaged function without first pinning it, may the stack become corrupted?
Is the CLR stack subject to c...
I remember seeing somewhere there "^" operator is used as a pointer operator in Managed C++ code. Hence "^" should be equivalent to "*" operator right??
Assuming my understanding is right, when I started understanding .Net and coded a few example programs, I came across some code like this:
String ^username; //my understanding is you ...
This is a question about what defining a class as public or private does.
Right now, I have various classes defined inside of a namespace and I only want some of those classes to be visible/usable to the outside world.
So, for example, if the classes below were the only ones in the program, I would want main.cpp to only be able to see/...
In VS2008, I can specify that a C# assembly should target only the x86 platform by going to the project properties, clicking the "Build" section, and then setting the "Platform target" box.
What is the equivalent for an assembly written in C++?
...
I have an application that consists of managed and unmanaged
DLLs. My managed DLL is a C++/CLR DLL that is used to access
a native C++ DLL. When code crosses from managed to native
the logic is wrapped in a try/catch statement. The purpose
is to log any exceptions before we rethrow them.
C++/CLR code calling into native code.
try
...
I'm trying to pass this structure:
#pragma unmanaged
typedef struct
{
void* data;
unsigned nlen;
unsigned int type;
} PARAMETER;
To this class static method:
#pragma managed
private class __gc GlobalFunctions
{
static void WriteField(Object* object, PARAMTER& par, unsigned dec)
{
switch (par.type)
{
...