my application is in C++ and I need to call a method from application that is in C#
I use Visual Studio 2012 and I am completely new to this.
I tried some of the examples on this site but am frustrated by failure all the time.
I created a C++/CLR project
and used the example at following link, but can't get it to I don't know why it thinks I'm using unmanaged code while I checked the commandline options in my project and there is /clr in it. Is this related VS 2012? please help
With what? All you have done is tell us that you can't get it to work. You need to provide specific details of the failures and include extracts of the code that is giving the problem. If you are having a problem with the code of an article then you should use the forum at the end of that article to discuss with the author.
I would like to make a GUI, for sensor configuration purpose, with the style of MFC Application Wizard. Basically, I'd like
1. Multiple property sheets, each of which can interact with user inputs.
2. There is a browsing tree to list all the property sheets.
3. One can navigate through the property sheet by "Previous" and "Next" buttons; or, one may select a property sheet by clicking it in the browsing tree.
I program mainly in C++, and know well of VB. I wonder what tool and option would do the trick.
C# string becomes array<String^>^ in C++.
List<string> becomes List<String^>^.
Remember you need to allocate managed types with gcnew in C++. (The regular new is for unmanaged types.) The conversion is done automatically on function call. In fact it isn't even a real conversion, as the meaning/memory layout is the same, just the expression looks different. So you declare a function taking a array<String^>^ and pass in a string or the other way araound.
Keep in mind, you can't have C# and C++ in the same module (exe/dll) so you need to separate the code into different ones.
Freak30's answer is good and thinking about it I realize you may want to get the string value to native C++ code instead of just to C++/CLI. If that's the case, you'll want to look into the marshal_as templates.
I'll answer my own question for future visitors. Yes, adding the VERSIONINFO resource was necessary. And, it was easier than I thought - just right-click on Resource Files folder in Solution Explorer, Add > Resource... and select VERSIONINFO.
so I'm using VC++ 2008 and I've got a large solution made up of several different interconnected projects, some of which are DLL's (no CLR). In one of these DLL's I'm trying to import an EXTERNAL Visual Basic dll using the command #import "C:\path\to\my\DLL\file.dll" . If I use this command in one of my .cpp files, it works. If on the other hand, I use it in one of my .h files, I then get the following compile errors in the files ocidl.h and comdefsp.h. I noticed that the .tlh and .tli files generated by the #import command include the file comdef.h. There are other files in my project that include the file comdef.h. Could this be the reason for the conflict?
Error1236"solution_name"error C2872: 'IDropTarget' : ambiguous symbol C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\ocidl.h 3949Error1237"solution_name"error C2872: 'IServiceProvider' : ambiguous symbol C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\ocidl.h 6238Error1238"solution_name"error C2872: 'IDataObject' : ambiguous symbol c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h 216Error1239"solution_name"error C2872: 'IDataObject' : ambiguous symbol c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h 216Error1240"solution_name"error C2872: 'IDropTarget' : ambiguous symbol c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h 246Error1242"solution_name"error C2872: 'IMessageFilter' : ambiguous symbol c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h 771Error1243"solution_name"error C2872: 'IMessageFilter' : ambiguous symbol c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h 771Error1244"solution_name"error C2872: 'IServiceProvider' : ambiguous symbol c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h 1041Error1245"solution_name"error C2872: 'IServiceProvider' : ambiguous
since IDropTarget is a type, and it is referenced in ocidl.h, 'ambiguous' implies two definitions for the same, one must not disclude that the two definitions ARE the same and this would point to the common error of an include file, including itself.
An include file should never include itself! But include files are notorious for including themselves vis-à-vis other include files. While it is of poor craftsmanship, it IS promoted in K&R C manual itself when they proscribe something akin to:
your h file: 'thisfile'
If this is not the case, kindly submit the result of this search complete solution
Also, there is a switch you can throw that will indicate the include files as they are included. That would be helpful.
Getting Access Violation Exception when trying to convert unmanaged array of structures into managed in Vb.Net(VS2010,4.0 framework) in Windows 7 -64 bit mode.
Sample Source Code
<structlayout(layoutkind.sequential, charset:="CharSet.Ansi)"> _
Public Class vb_menu_dotnet
Public level As Short
Public menu_id As String
Public short_desc As String
Public parent_id As String
Public access As Short
Public flag As Short
Public menu_desc As String
Dim current As IntPtr
Dim outArray As IntPtr
Dim manArray(100) As vb_menu_dotnet
vb_dotnet_get_menu_hierarchy(p_menu_handle, p_apl_id, outArray) //C API call
current = outArray
Dim j As Integer
For j = 1 To 100
manArray(j) = New vb_menu_dotnet()
Marshal.PtrToStructure(current, manArray(j)) //Access Violation Exception