c++-cli

Value Class in C++/CLI

ε祈祈猫儿з 提交于 2019-12-18 15:09:16
问题 What are the benifits of using a value class in C++/CLI.Can the value class contain member functions? 回答1: a value class is a ValueType - that means, whenever you assign it to another variable of the same type, the whole object gets copied into the other variable, leaving you with two separate copies. Examples of this are basic numeric data types like int , bool or double . ValueTypes are sealed, which means you cannot derive from them. A ref class is a reference type - if you assign it to

What is the difference between ANSI/ISO C++ and C++/CLI?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 13:36:47
问题 Created by Microsoft as the foundation of its .NET technology, the Common Language Infrastructure (CLI) is an ECMA standard (ECMA-335) that allows applications to be written in a variety of high-level programming languages and executed in different system environments . Programming languages that conform to the CLI have access to the same base class library and are capable of being compiled into the same intermediate language (IL) and metadata. IL is then further compiled into native code

What is the difference between Managed C++ and C++/CLI?

你离开我真会死。 提交于 2019-12-18 12:07:23
问题 What is exactly the difference between the "old" Managed C++ and the "new" C++/CLI? 回答1: Managed C++ is the version in VS2002 and VS2003. It had race conditions and other serious bugs, as well as being confusing. It's no longer supported. In VS2005, Microsoft introduced C++/CLI, which has also been accepted as an ISO standard. It's also supported in VS2008 and the upcoming VS2010. Both of them had the same goal, which is to create .NET assemblies using the C++ language. The syntax is

C++ Interop: How do I call a C# class from native C++, with the twist the class is non-static?

北慕城南 提交于 2019-12-18 11:44:19
问题 I have a large application written in native C++. I also have a class in C# that I need to call. If the C# class was static, then it would be trivial (there's lots of examples on the web) - just write the mixed C++/CLI wrapper, export the interfaces, and you're done. However, the C# class is non-static, and can't be changed to static as it has an interface (the compiler will generate an error if you attempt to make the C# class static). Has anyone run into this problem before - how do I

Including headers from an unmanaged C++ code inside C++/CLI code

五迷三道 提交于 2019-12-18 09:45:16
问题 I'm writing a CLR wrapper for an unmanaged C++ library. There are two files I'm including from the unmanaged lib: //MyCLIWrapper.h #include "C:\PATH\TO\UNMANAGED\Header.h" #include "C:\PATH\TO\UNMANAGED\Body.cpp" Then I'm writing CLI implementations for the unmanaged library functions: //MyCLIWrapper.h // includes ... void MyCLIWrapper::ManagedFunction() { UnmanagedFunction(); // this function is called successfuly } However, if my Unmanaged function contains calls to other functions that are

System.Transactions.Diagnostics.DiagnosticTrace throwing TypeInitializationException

五迷三道 提交于 2019-12-18 09:14:49
问题 Seems related to Strange exception coming out of OdbcConnection.Open() but I'm not sure. I recently switched over to Win8 and hadn't run this app since. I'm using VS2012, but the projects have not been upgraded. The dump of the exception looks like this: Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to

VC2008, how to turn CLR flag off for individual files in C++/CLI project

雨燕双飞 提交于 2019-12-18 07:16:07
问题 This post says that it is possible to turn off the CLR flag for an individual .cpp file. From the post: You can set /CLR on or off in each .cpp file individually. Turn it on for the whole project,. as you have done, then turn it off for the files containing only native (unmanaged) code. When you have the VC++ procject properties dialog open, you can still click on files/projects in the solution explorer to change the scope that you're working on. Click on the unmanaged .cpp file to set

make c++ class in a native dll to use in C#

那年仲夏 提交于 2019-12-18 07:15:36
问题 I spent about 3 days reading about this topic... I am totally lost now thanks to the many tutorials and answered questions about how to create a native DLL. If you have some time to spare please care to explain a little about the topic and help me - if you don't have time then just go to the simple form of my question down there... Here is what I know about the topic so far: 1) I need to use a macro defined as __declspec(ddlexport) and __declspec(ddlimport) before class name to export all the

make c++ class in a native dll to use in C#

巧了我就是萌 提交于 2019-12-18 07:15:21
问题 I spent about 3 days reading about this topic... I am totally lost now thanks to the many tutorials and answered questions about how to create a native DLL. If you have some time to spare please care to explain a little about the topic and help me - if you don't have time then just go to the simple form of my question down there... Here is what I know about the topic so far: 1) I need to use a macro defined as __declspec(ddlexport) and __declspec(ddlimport) before class name to export all the

SQL Server: “CREATE ASSEMBLY for assembly 'Test' failed because assembly 'Test' is malformed or not a pure .NET assembly.”

人走茶凉 提交于 2019-12-18 06:58:05
问题 I get this error when I attempt to load a mixed mode C++/CLI assembly into SQL Server 2012: CREATE ASSEMBLY [Test] AUTHORIZATION [dbo] from 'H:\test.dll' WITH PERMISSION_SET = SAFE Msg 6544, Level 16, State 1, Line 1 CREATE ASSEMBLY for assembly 'Test' failed because assembly 'Test.dll' is malformed or not a pure .NET assembly. Unverifiable PE Header/native stub. 回答1: Mixed-mode Assemblies are not allowed in SQLCLR Assemblies; only pure MSIL Assemblies are allowed. This is implied in the MSDN