|
He's doing a BSc and cannot even start to research his chosen subject!
The best things in life are not things.
|
|
|
|
|
Maybe he just needs a little push... 
|
|
|
|
|
Joking aside, I am constantly amazed at the number of people doing degrees who do not seem able to use the most basic bit of initiative to start investigating the subject they choose to do their dissertations on. How anyone can be doing a college/university course in computing and not know how to perform a simple Google search is quite worrying; how on earth are these people going to fare when working in the real world?
[edit]Yes, I know, this is not really the place for a rant.[/edit]
The best things in life are not things.
|
|
|
|
|
I do agree, quite surprising to see that many people ask questions without research... Maybe these are the people who never finish a degree or change major after a few courses.
|
|
|
|
|
A little help please.
Is there any reason why the following will not work in a managed C++/CLI project?
A vector of pairs of managed Strings.
cliext::vector<cliext::pair<System::String ^, System::String ^> > ^attributes;
When linking I receive the following error...
1>Linking...
1>Generating code
1>Finished generating code
1>gm_vcet_k010_dimension_exporter.obj : error LNK2020: unresolved token (060000EB) cliext.vector<cliext::pair<System::String ^,System::String ^> >::Clone
1>C:\Documents and Settings\zzmgd6\My Documents\nxopen\k010_vcet_dimension_reporter\Release\gm_vcet_k010_dimension_exporter.dll : fatal error LNK1120: 1 unresolved externals
Thanks for any help.
modified on Wednesday, July 20, 2011 9:27 PM
|
|
|
|
|
You don't need the ^ in front of attributes. Here's a working example:
#include "stdafx.h"
#include <cliext/vector>
#include <cliext/utility>
#include <cliext/algorithm>
using namespace System;
int main(array<System::String ^> ^args)
{
using namespace cliext;
vector<pair<System::String^, System::String^>> attributes;
attributes.push_back(make_pair(gcnew String("Background"), gcnew String("Red")));
attributes.push_back(make_pair(gcnew String("Visibility"), gcnew String("Collapsed")));
attributes.push_back(make_pair(gcnew String("Happy"), gcnew String("True")));
for_each(attributes.begin(), attributes.end(), [](pair<System::String^, System::String^> p){
Console::WriteLine(p.first + " = " + p.second );
});
return 0;
}
|
|
|
|
|
I developed Web Services program in WCF with VS 2008 C++/CLI on server side and deployed it. But I have no idea how to generate wsdl file. My template is Visual C++ CLR console application. So i can't see any wsdl file.
I need your advice! Thanks in advance.
Best Regards!
Joseph Hwang
|
|
|
|
|
Have you tried putting the service address in a browser and appending ?wsdl to the address?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
how to use crystal report in c++/clr?
is it possible to do so or i have to use other options?
i need to print some labels and a picture box, is it a good idea to use reporting or i should consider capturing the form screen and then print it.
|
|
|
|
|
|
Hi all
we have unmanaged C++ third party library which needs to be used in C# Environment. hence I am writing managed C++ wrapper on top
to use it in C# environment
I came across some of the situation put me into trouble.Can any one resolve my doubts
1) I was using the pin pointers to convert from managed string (String^) to unmanaged string(char * buffer)
is it safe? are there any performance issues with this ?
If then what is the best logic to do? please see the code snippet below i used
for converting from C# string to char * buffer(unmanaged string)
bool bRet = false;
pin_ptr<const wchar_t> w_string = PtrToStringChars(s);
size_t converted_chars = 0;
size_t size_bytes = ((s->Length + 1) * 2);
if ((size_bytes / 2) <= output_len)
{
memset(output, '\0', output_len);
if (!wcstombs_s(&converted_chars, output, output_len, w_string, size_bytes))
bRet = true;
}
return bRet;
2)Can i use System::Generic::Collections such as Dictionary and List for sending data from C# to managedC++
and viceversa?
I need to send collection of datasets from managed C++ to C# code. Can i use the List to do this.
if not are there any best practices to achieve this?
3)Is it necessary to use gc when i am creating any memory in managed C++
Waiting for ur reply
Thanks in advance
Sukumar
|
|
|
|
|
Hi,
1) I tend to use the msclr::interop::marshal_as templates for string conversions rather than pinning memory as they work in a nice tidy C++ RAII way, clearing up any temporary/locked memory when going out of scope. They handle stl, COM and straight const char * type conversions. See http://msdn.microsoft.com/en-us/library/bb384859.aspx[^]
2) Yes. Works just the same, except with C++/CLI syntax. You will need to do some translation (e.g. to copy into an stl data type) to send to purely native code though.
3) The general rule is if you are creating a managed object, use gcnew, otherwise use straight c++ new. The garbage collector will do the rest. You can still delete sooner if you want to.
Hope that helps.
|
|
|
|
|
Hi
Is it necessary to use delete when i am using gcnew to create an object
i got this code snippet from msdn deletes the context that was created by gcnew
is it correct?
marshal_context ^ context = gcnew marshal_context();
const char* str4 = context->marshal_as<const char*>(str);
puts(str4);
delete context;
|
|
|
|
|
The delete is not necessary as this is a references and the GC will collect that context object when there are no more outstanding references. The delete is probably just attempting to make it explicit and hope to clean up sooner from what I can tell.
|
|
|
|
|
Hi All,
Can any suggest me book that explains better for mangaged extenstions for VC++ for .Net Version 2.0 and above ?
|
|
|
|
|
Try Pro Visual C++/CLI for .Net 3.5 by Stephen Fraser from Apress
Ger
|
|
|
|
|
|
You do know that managed extensions has been deprecated for quite some time, and it's now C++/CLI, right?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You can do a lot worse than Nish's book, C++/CLI in action (see http://www.manning.com/sivakumar/[^] ). I found it a really good introduction to one of the better things to come out of Microsoft in recent years, C++/CLI. Highly recommended.
modified on Tuesday, July 5, 2011 4:33 AM
|
|
|
|
|
|
This maybe a common question, and maybe there are many articles and threads talking about the mixed coding.
But all the mixed coding seems prefer to using #pragram unmanaged/managed, and using dll import, something like this. I plan to make a winform program, and when I press some button, the program can call the unmanged function. So in that case, I should call the unamaged function in button click event, like this:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
// call the unmanaged function
CallUnmanaged();
}
However, I had compile error: 'CallUnmanaged': identifier not found. I tried to use extern the unmanged function in the managed codes, there are still many errors.
Anyone can tell me how to fix this without using dll import? just simpile function call. Thanks.
Best wishes
Joul
|
|
|
|
|
You must tell the compiler where to find the function typically by adding the appropriate include directive... or you somehow have to declare the function somewhere.
Is CallUnmanaged in another DLL? Is so, you have to properly export/import the function. If the function is in the same DLL then a simple declaration will do.
Typically function are declared in header files and header files then be included to use that function. If the function is uses across DLL, then it must be exported/imported as otherwise it would be visible from outside the original DLL.
Importing manged code is easier as we only have to add a reference to the DLL. For unmanaged function though, they mus be made visible to the compiler before being used by either including the file with the declaration or duplicating the declaration (normally not recommanded).
Philippe Mori
|
|
|
|
|
Thanks Mori, the CallUnmanaged function is defined by another .cpp native file of the project solution. That's I just want to call the CallUnmanaged function without through DLL. The compiler doesn't know the native function, that's the key problem. Maybe this is a simple question.
Joul
|
|
|
|
|
Well, generally all functions in a .cpp that are intended to be used from other files in the project should also be declared in the corresponding header. Then in the file where you want to call the unmanaged function, you just include that file.
In fact, this is the same for managed functions inside the project or any functions in standard librairies.
For this aspect C+/CLI works exactly as C++. The main difference with standard C++ is that when you add a reference to a managed DLL, all public symbols will be visible without any additionnal include to all file in that project. So for managed code outside the current project, C++/CLI behave more like C#.
ProjectA
unmanaged.h
void UnmanagedFunction();
unmanaged.cpp
#include "unmanaged.h"
void UnmanagedFunction()
{
}
other.cpp
#include "unmanaged.h"
void CallingFunction()
{
UnmanagedFunction();
}
Philippe Mori
|
|
|
|
|
Hi Mori,
Thanks for your kind help, I got your meanings and solved the problem. Many thanks
BW
Joul
|
|
|
|