|
I was wondering if someone could be so kind as to explain or recommend an article/ book that could help explain this for me.
I have a question about Handles. What happens to the underlying object when there are no more handles pointing to it?
Is it lost in memory somewhere or does it get deleted and cleaned up for you?
here is an example.
<br />
ref class A {<br />
public:<br />
property Int32 i;<br />
};<br />
<br />
int main(array<System::String ^> ^args) {<br />
A^ foo = gcnew A();<br />
foo->i = 5;<br />
A^ bar = gcnew A();<br />
bar->i = 13;<br />
<br />
foo = bar;<br />
<br />
return 0;<br />
}
What happens to the first object that has a value of 5?
Since, I no longer have a handle to it, will it still be floating around in memory somewhere?
Thank you,
|
|
|
|
|
If you call gcnew, you're asking for a managed object which means it will be garbage collected for you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi
i have to implement a neural network but unfortunately i have no experince or idea how to implement or start implementing a artificial neural network. if anyone could please guide me how to start implementing or show an example of implementing any simple artificial neural network or any evolutionary algorithm it will be a great help.
|
|
|
|
|
Hmm... maybe you can start by checking out pseudonym67's article here: Neural Net Part 1 and then continue with pt 2 and 3. Also I remember reading an article about OCR using neural nets that was also implemented using .NET. You may want to do a search... maybe narrow your search a little after you learn a bit about what you're actually searching for.
good luck!
|
|
|
|
|
Hi, I'm new to managed C++ and I was wondering how could I use fopen from managed C++
I have to call a legacy function that uses FILE but when i try to compile my code I get the following errors
fatal error LNK1120: 2 unresolved externals
error LNK2020: unresolved token (0A00002C) delete
error LNK2020: unresolved token (0A000018) _CxxThrowException
the code looks something like this
#pragma once
using namespace System;
//using namespace System::IO;
using namespace System::Runtime::InteropServices;
#include <openssl rsa.h="">
#include <iostream>
namespace OpenSSLWrapper
{
public __gc class RSAWrapper
{
public:
int RSAEncryption()
{
RSA *privateKey;
FILE *keyFile = fopen("C:\\Documents and Settings\\isaac\\Desktop\\Factura\\.key", "r");
if (keyFile == NULL)
return -1;
fclose(keyFile);
Byte sourceArray[] = __gc new Byte[2];
Byte encryptedArray[] = __gc new Byte[5000];
{
unsigned char __pin *source = &sourceArray[0];
unsigned char __pin *encrypted = &encryptedArray[0];
sourceArray[0] = 7;
sourceArray[1] = 5;
}
return 0;
}
};
}
Thanks in advance
Isaac B
|
|
|
|
|
How you have created this project?
I've tested your code, with project created in VC++ project--> console Application(.Net) and didn't get any error.
|
|
|
|
|
I've got a little problem with some code :
My program is in C, doesnt'use use any custom or foreign libraries !
No compile errors are noticied and it works as i want when VS start the app in release and debug mode. But when i try to execute outside (without VS), simply doubleclicking on the exe; my program hang ! They hang not at the same point during the execution.
My program use a lot of pointers, and malloc, which are freed without memory leaks !
Please help !
Thanks for incoming answers !
|
|
|
|
|
Hi,
Do you have any large arrays statically allocated?
I take it that if you have no errors, there are no warning either?
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
You do not use any foriegn libraries, but the C run time library used is different in debug/release builds and heap management is quite different in debug/release builds. Debug takes care of when you overwrite array bound etc..
but release doesnt..there are differences like this.
|
|
|
|
|
hai guys
difference dynamic & static in window programming.
b.raju
|
|
|
|
|
static will have all the MFC in your exe no need for MFC dll`s a very large file
dynamic will have mfc in separate dll`s ...
NG
|
|
|
|
|
convert interbase database file into sql server database
My question is that through interbase database i have text file and again i want to convert that file in sql server database or any ms-access database is it possible so what r the steps.....
plz reply soon..
brijesh
convert interbase database file into sql server database
My question is that through interbase database i have text file and again i want to convert that file in sql server database or any ms-access database is it possible so what r the steps.....
plz reply soon..
brijesh
|
|
|
|
|
I've been working on a .NET component for some time and I recently ran into an issue I could'n find any documentation for so far. Basically the .NET assembly should compile into a mix-mode DLL. That is, the assembly contains a managed class that wraps up a __nogc class that performs some time-sensitive operations on the serial port. The __nogc class spawns a thread that monitors the serial port and that writes to a buffer. In order to make sure that the rest of the program, that sits in a different thread, doesn't conflict with the monitor thread when competing for access to the buffer, I'm using the InterlockedExchange64 and InterlockedExchangeAdd64 functions in the unmanaged class. That seems to prevent the assembly from further beeing accessible to c# .NET applications. When open in the Object Explorer, the assembly shows up fine but when included in the project and instantiated a System.IO.FileLoadException is thrown by the system. It almost looks like there is a permission issue with the asssembly. But that is not the case, I've made sure that all the security policies are reset to default and tried loading the assembly in the "Evaluate Assembly" tool. That didn't work. The "Evaluate Assembly" tool shows an error message saying that the assembly could not be loaded.
So, I'd like to know what is the reason that I can't use Interlocked methods in the unmanaged class or if there is a way around that. Keep in mind that i'm trying to optimize for speed.
Feel free to ask for more details.
|
|
|
|
|
Well... it seems that not a lot of people took interest in this post, nonetheless have I got an answer. Anyway, I found the answer on another forum and thought to complete this post with the explanation and some thoughts.
Basically, the problem was using the InterlockedExchange64 instead of the regular InterlockedExchange. Some say that the InterlockedExchange64 is designed for 64bit OSes and that's the reason it was making my assembly not load. That sounds interesting, but what's even more interesting is that the DLL was compiling without problems with the 64bit version of the function. It's a mistery. Also it's interesting that the IntelliSense is picking up InterlockedExchange64 but not the regular one... definetly something odd.
Enough said, I can now load the assembly in the Evaluate Tool and it looks good so I'm on to further testing it.
|
|
|
|
|
I am using UDP asynchronous in VC.NET.
this is my ReadCallback
IPEndPoint* sender = new IPEndPoint(IPAddress::Any , 0);
EndPoint* tempRemoteEP = __try_cast<ipendpoint *="">(sender);
StateObject *state = static_cast<stateobject *="">(ar->AsyncState);
Socket *handler;
try
{
String *content;
handler = state->workSocket;
// Read data from the client socket.
int bytesRead = handler->EndReceiveFrom (ar,&tempRemoteEP);
Console::WriteLine("ip from {0}",tempRemoteEP->ToString() );
My Problem is this first time it shows correct IP, second times it shows 0.0.0.0 third times its fine but fourth time again 0.0.0.0 and so on. whats problem with this.
|
|
|
|
|
I'm just learning ADO Recordsets with C++ and am have encountered a problem I can't figure out.
cout << setw(width) << setiosflags(ios::left) << "Player ID" << setw(width) << "Player Name" << endl;
while(!recordset->ADOEOF)
{
// Display the value stored in field "screen_name"
_variant_t name;
_variant_t id;
name = recordset->Fields->GetItem(L"screen_name")->GetValue();
id = recordset->Fields->GetItem(L"player_id")->GetValue();
cout << setw(width) << static_cast<char *="">(_bstr_t(id.bstrVal));
cout << setw(width) << static_cast<char *="">(_bstr_t(name.bstrVal)) << endl;
recordset->MoveNext();
};
recordset->Close();
I can display the data fine, if I remove the line that displays the "player_id". player_id is the primary key. The name field displays fine. However, if I try and query another field and store that in a variable, it gives me an error as well.
Is there a problem with using the recordset->FieldsGetItem()->GetValue() syntax more than once in a row?
I can't seem to find a decent tutorial on working with the recordset.
Also, is there a method for retrieving all the fields and storing them in an array?
Thanks.
|
|
|
|
|
Hi Everyone,
I've been a member for sometime now and have been reading a few things on this forum. This is the first time that I'm posting a request. Hope you all gurus will respond.
I want to read/write MS excel sheets on Unix/solaris platform using C++.
I did go through the article posted by Alexander Mikula on how to use ODBC and read excel sheets using CRecordset.
But I'm not sure how to use ODBC connection in Unix/solaris.
Please tell me ways to do it unix using C++.
Thanks.
Tanz.
|
|
|
|
|
I'm an intermediate type C++ programmer, with little experience in MFC and no experience integrating C++ applications with databases; though I have done this in a Web Environment using PHP and mySQL.
I'm wondering where to start! I've been looking for a good manual as a start place, but can't seem to find any.
I don't know what COM/ADO/OLE/OLE DB are, though I keep seeing these terms everywhere - I think they may be some kind of drivers for interfacing with a database?
Let me explain what I'm trying to learn how to do, very quickly:
I have users at their home PC's, all with the same ACCESS database, containing completely different data. These databases are updated very quickly, with thousands to tens of thousands of new records per day.
I want to build an application which can query/update these databases, and synchronize them with eachother. I'm thinking that the synchronization will be difficult and probably involve the use of MS SQL Server 2003.
So my problem is this: I'm not quite sure where to start. I've started by creating lots of applications in MFC, following examples and have gotten myself a bit more familiar with this, but I can't seem to find any tutorials on interfacing with an ACCESS database. ACCESS of course supports SQL.
Anyone have any suggestions?
Thank you.
|
|
|
|
|
I have no link for a manual but I can share some of my experience with this topic. I have been writing database applications in VC6 since it has been on the market. I started out using DAO but after running into several problems related to limitations in DAO, I decided to convert to ADO. I believe this was 4 to 5 years ago and at this time there was no C++ docs at all everything was in VB which made things a little difficult because of the differences between the languages. But now I know MSFT does have docs for VC++ also. I was still using access as a database but then I found the need to use stored procedures and other things that access did not have so I moved on to use MSDE as my database. If you are not familiar with MSDE it is a free version of SQL server that has a few limitations (2GB of data max and 10 simultaneous connections). One thing with MSDE is that the ADO and SQL is exactly the same as SQL server so if you need to scale up it will not be difficult at all.
Below is a link to a class that will make ADO programming soo much simpler:
http://www.codeproject.com/database/caaadoclass1.asp[^]
John
|
|
|
|
|
So I shouldn't bother learning DAO, I should start with ADO. I'm not sure what ADO is, or how it relates to the .NET framework.
Any links to beginner articles on this?
I'm not familiar with MSDE, but I just looked up the website, started the download, and I'm sure it'll be easy enough to figure out. Just another SQL server. 2GB of data and 10 simultaneous connections seems like it should handle what I'm doing.
I checked out your link, looks like a .lib file for making my life easier using ADO, right?
I've never used a .lib file before - any links on basic information about using libraries?
Sorry to trouble you so much. Your previous is help is already appreciated.
|
|
|
|
|
I'm sorry I have to be very short with my answers. I am very busy at the moment...
budidharma wrote:
So I shouldn't bother learning DAO, I should start with ADO.
Yes. I believe ADO is your best bet of all the ways to use databases with VC++. COM/ OLE-DB ... are lower level / harder to use than ADO.
budidharma wrote:
2GB of data and 10 simultaneous connections seems like it should handle what I'm doing.
That was enough for all the tasks I needed.
Here is a link to a tool that I find very helpfull with my MSDE databases: http://gpoulose.home.att.net/[^]
I will try to help with your other questions later today if I can.
John
|
|
|
|
|
Another quick question: I assume ADO allows you to interface with an SQL server. What if the database I want to query isn't running on a server? Can I use ADO to load an access database file just sitting in it's folder, and perform SQL queries against it?
|
|
|
|
|
Yes. You do this with the connection string.
Below is the example of this I took from the link I gave you:
CADODatabase* pAdoDb = new CADODatabase();
CString strConnection = _T("");
strConnection = _T("Provider=Microsoft.Jet.OLEDB.4.0;"
"Data Source=C:\\VCProjects\\ADO\\Test\\dbTest.mdb");
pAdoDb->SetConnectionString(strConnection);
John
|
|
|
|
|
Thank you. That's very helpful.
I'm using Microsoft Visual Studio 2003.NET. Does ADO come with this IDE, or is ADO something I need to install separately. I found a beginning ADO tutorial in the articles, and attempted to start it, by inserting the following code into a console project:
#import "msado15.dll" \
no_namespace \
rename( "EOF", "adoEOF" )
The tutorial I'm using is here: http://www.codeproject.com/database/simpleado.asp
And attempted to compile, with the following error:
c:\XXX\My Documents\Visual Studio Projects\MS Database\stdafx.h(14) : fatal error C1083: Cannot open type library file: 'msado15.dll': No such file or directory
I'm assuming this means that ADO is either not installed, or configured correctly. I do not know how to check if it is installed. I went to the MS Site on ADO:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdconreferencingadolibrariesinvc.asp
And it gave me the same instructions, did not say anything about installing ADO, so I assume it should be installed?
Sorry, like I said this is my first time trying to work with a database, and I've never touched ADO before.
Thanks for bearing with me.
|
|
|
|
|
budidharma wrote:
c:\XXX\My Documents\Visual Studio Projects\MS Database\stdafx.h(14) : fatal error C1083: Cannot open type library file: 'msado15.dll': No such file or directory
Try this:
#import "C:\program files\common files\system\ado\msado15.dll" \
no_namespace \
rename( "EOF", "adoEOF" )
budidharma wrote:
Does ADO come with this IDE,
No ADO/MSDE does not have an IDE. I use ACCESS and AdoQuery tool (link below) to work with my MSDE databases.
http://gpoulose.home.att.net/[^]
John
|
|
|
|