|
Hmmmm... I will have to check on possibility of executing more than once concurrently (it is possible.) However, I tricked it by making a copy of the lParam, wParam variables and supply the copies to the second call to PostMessage().
Thanks for reply and help.
|
|
|
|
|
Hi folks!
This could become a bit lengthy, sorry in advance...
I have created a mixed-mode dll (managed+unmanaged C++, .NET 1.1) that implements a given (unmanaged) C++ interface.
Inside this dll I use some objects from C# assemblies located in the same path as the mixed-mode-dll.
So far, so good, everything works as expected when my dll is loaded into a 3rd-party-application from a local directory (using LoadLibrary() I guess. I can't look into the other app, but I don't see a different way...).
When I put the dll on a network share and have the 3rd-party-app load my dll from there, I get an error 1114 (A dynamic link library (DLL) initialization routine failed).
When I set CAS policies to FullTrust for the network share, the dll can be loaded correctly.
Because our customers usually forget to adjust CAS accordingly and wonder why the 3rd-party application shows an error trying to load our dll, I thought I'd include some security-related checks before trying anything fancy and show a nice info dialog telling the user to adjust CAS if any of these checks fail.
Now the problem is that I can't find a place to put these checks.
Even when I just put an AfxMessageBox() as the very first statement in the very first interface function that's getting called, this message box doesn't show but the 3rd-party-app still gives error 1114
It seems as if there's a problem with loading a depending dll/assembly, but I simply cannot find what's going on. There's nothing in the fusion log for this case, either. "Regular" C#-applications write to the fusion log, but when my dll is loaded, the fusion log seems to completely ignore the fact that assemblies have to be found - no entries whatsoever, even after setting ForceLog to true in the corresponding Fusion registry key.
Can anyone offer an idea why .NET behaves like that or what I could try to diagnose the problem?
Thanks in advance,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
mav.northwind wrote: Can anyone offer an idea why .NET behaves like that
Security
|
|
|
|
|
Yes, I know. Of course. That's what I wrote in the question.
But why exactly? I guess it must be a certain permission that's being denied.
CAS security has to kick in somewhere very early, but i completely fail to see which permission is not being granted so early in the process.
Since you can usually execute .NET code from a network share even with the default CAS policies in place, the general execution of managed code cannot be the reason.
But what else?
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hello and need help again,
Bros, what are the equivalent of the ff. function:
from Visual Basic:
Dim cancelDelegate As New DownloadCompleteSafe(AddressOf DownloadComplete)
Me.SaveFileDialog1.FileName = Me.txtFileName.Text.Split("/"c)(Me.txtFileName.Text.Split("/"c).Length - 1)
to Visual C++:
???
I got the snippet but its vb. i want it in c++.
Thanks in advance,
Jeof
******************************
I just want to
know everything
|
|
|
|
|
I'll take a stab at it, at least the string part... LOL
//dummy source string (Me.txtFileName.Text)
String ^PathStr = "C:\\TEST\\TEST.EXT";
array<string^> ^SplitStrings = PathStr->Split('\\');
// (Me.SaveFileDialog1.FileName)
String ^FileName = SplitStrings[SplitStrings->Length - 1];
I wonder if I'm even close!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Or, borrowing from the post below...
using namespace System::IO;
...
String^ PathName = "C:\\TEST\\TEST.EXT";
String ^FileName = Path::GetFileName(PathName);
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
(via Instant C++):
DownloadCompleteSafe ^cancelDelegate = gcnew DownloadCompleteSafe(DownloadComplete);
this->SaveFileDialog1->FileName = this->txtFileName->Text->Split('/')[this->txtFileName->Text->Split('/')->Length - 1];
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
C++ to VB Converter: converts C++ to VB
Instant C++: converts C# to C++/CLI and VB to C++/CLI
|
|
|
|
|
thank you very much.
Here`s another want to convert.
Dim theRequest As HttpWebRequest
theResponse = theRequest.GetResponse //theres no GetResponse in C++, what should I do?
Catch ex As Exception
Dim writeStream As New IO.FileStream(Me.whereToSave, IO.FileMode.Create)
Delegate Sub DownloadCompleteSafe(ByVal cancelled As Boolean) //where should i put this? in private or public
emailed you
thanks,
jeoffrey
******************************
I just want to
know everything
|
|
|
|
|
Hi,
I am using Visual Studio 2005 C++/CLI. So far so good. When I was using C++ with MFC I could modify my paths by using methods like Find, ReverseFind, etc. to be able to get my current directory and then remove the last directory in the path (make the path one directory higher). I can't seem to do the same kind of things with CLI. I want to be able to do something like "look for the second forward slash from the end of the string and then trim from that position to the end of the string. What CLI class methods are available to do path manipulation/modification?
Buck
|
|
|
|
|
Hi,
look at the Path and the String classes.
Especially String.LastIndexOf() may interest you (dont get fooled by the start argument,
it typically needs to be String.Length-1).
|
|
|
|
|
Hi,
Thanks for the reply. I see how I can use String.LastIndexOf will let me back up the path a directory at a time. MFC modified the existing CString, but it took me awhile to figure out that a second string variable is needed for modification.
String^ myString = "This is a test string"
String^ newString = myString->Remove(5);
results in newString having the value of "This "
This will allow me to proceed. Thanks again.
|
|
|
|
|
You are welcome.
Yes, in .NET strings are immutable: to get another value, you have to create another
string instance, most often by accepting the return result of some methods, such as
the ones in String class.
|
|
|
|
|
I am just adding to Luc's post. The mentioned Path class is in the System::IO namespace.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
i wonder somebody can help me to sort this program. all my hair already turn white
i'm trying to make dynamic array library which can expand, add, delete,..n sort of. actually this one is my programming class assignment. for some func i haven't got a clue how to do. here's details
template <typename t="">
class DArray
{
public:
DArray(); // create default obj which will have unitsize of 64
DArray(size_t); // create dynamic array
DArray(size_t, const T &); // darray which has logical size = input
DArray(const DArray &); // copy darray, right hand side
template <typename t2=""> // *don't know how to do this
DArray(const DArray<t2> &); //
~DArray(); // destructor
DArray& operator=(const DArray &); //?teacher said to throw bad_alloc. ??
template <typename t2=""> //*don't know this 1 either
DArray& operator=(const DArray<t2> &); //
T & operator[] (size_t); //throw (invalid index) this 1 also i dunno
const T & operator[] (size_t) const; // problem here 2
size_t size() const; // return the logical size of darray
void resize(size_t, const T & = T());//resize darray(logical)as user specify
void append(const T &); //add new data to darray
bool remove_last(); //remove last data from darray
void clear(); // not sure about this one
bool empty() const; // logical size empty or not
size_t capacity() const; //return the current buffer size
void reserve(size_t); //?get the buffer size as user want to. ??
private:
size_t arrSize;
size_t buffSize;
const unsigned unitSize;
unsigned char * myheap;
T * buffer;
};
template <typename t="">
DArray<t>::DArray() : arrSize(0), buffSize(0), buffer(NULL), myheap(NULL), unitSize(sizeof(T))
{
try { myheap = new unsigned char [unitSize * 32]
buffSize = 32;
buffer = reinterpret_cast<t*> (myheap); // dunno this one right or wrong
}
catch(std::bad_alloc &)
{
}
}
template <typename t="">
DArray<t>::DArray(size_t initSize) : arrSize(initSize), buffSize(initSize), buffer(NULL), myheap(NULL), unitSize(sizeof (T))
{
if( arrSize > 0 ){
if( arrSize < 32) buffSize = 32;
else buffSize = arrSize + 32;
myheap = new unsigned char [buffSize * unitSize];
buffer = new (myheap) T[arrSize];
}
}
template <typename t="">
DArray<t>::DArray(size_t initSize, const T & init_value) : arrSize(initSize), buffSize(initSize * 2), buffer(NULL), myheap(NULL), unitSize(sizeof(T))
{
if( arrSize > 0 ){
myheap = new unsigned char[buffsize * unitSize];
buffer = reinterpret_cast<t*> (myheap);
for (size_t i =0; i < arrSize; ++i)
new (buffer + i) T(init_value);
}
}
template <typename t="">
DArray<t>::DArray (const DArray & rhs) : arrSize(0), buffSize(0), buffer(NULL), myheap(NULL), unitSize(sizeof(T))
{
*this = rhs; // can i do something like this?
}
template <typename t2=""> // pls someone help don't know how to do this
DArray(const DArray<t2> &); //
template <typename t="">
DArray<t>::~DArray()
{
clear();
delete[] myheap;
}
template <typename t="">
DArray<t> & DArray<t>::operator= (const DArray<t> & rhs)
{
if( this == & rhs){
return * this;
}
else
{
clear();
arrSize = rhs.arrSize;
if( buffSize <= rhs.size()){
delete[] myheap;
buffSize = rhs.buffSize;
myheap = new unsigned char[buffSize * unitSize];
buffer = reinterpret_cast<t*> (myheap);
}
for( int i = 0; i < arrSize; i++){
new( buffer + i) T(rhs.buffer[i]);
}
}
return * this;
}
template <typename t2=""> //*don't know this 1 either
DArray& operator=(const DArray<t2> &);
template <typename t="">
T & operator[] (size_t); //
template <typename t="">
const T & operator[] (size_t) const;
template <typename t="">
size_t DArray<t>::size()const
{
return arrSize;
}
template <typename t=""> // hope this one correct
void DArray<t>::resize(size_t newSize, const T & = T())
{
if( newSize >= buffSize)
{
reverse ( newSize );
}
else arrSize = newSize;
}
template <typename t="">
void DArray<t>::append(const T & newItem) // need to used throw catch in this func ??
{
if( arrSize == buffSize){
size_t newCapacity = (buffSize + 1) * 2;
T * oldbuffer = buffer;
unsigned char * oldheap = myheap;
myheap = new unsigned char [buffSize * unitSize];
buffer = reinterpret_cast<t*> (myheap);
for( int i = 0; i < arrSize; ++i) {
new( buffer + i) T(oldbuffer[i]);
(&oldbuffer[i]) -> ~T(); // called destructor
}
delete[] oldheap;
buffSize = newCapacity;
}
reverse( newItem)
new (buffer + arrSize) T(newItem);
++arrsize;
}
template <typename t="">
void DArray<t>::clear()
{
for( size_t i = 0; i < arrSize; ++i)
( & buffer[i])-> ~T();
arrSize = 0;
}
template <typename t="">
bool DArray<t>::remove_last()
{
if ( empty()) return false;
--arrSize;
( & buffer[arrSize])->~T();
return true;
}
template <typename t="">
bool DArray<t>::empty() const throw()
{
if (arrSize == 0) return true;
else return false;
}
template <typename t="">
size_t DArray<t>::capacity() const
{
return buffSize;
}
template <typename t="">
void DArray<t>::reverse(size_t newSize)
{
//reverse to size which the user want
//help help
}
// pls correct me if i'm wrong
//thx in advance
|
|
|
|
|
This is the managed C++ board. You should post non-manage C++ questions on the
Visual C++/ MFC board[^].
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
hi everyone,
this is my problem:
I have a huge binary file.I have my application:"software",since which i want to import the binary file.
but the file is huge:4gig. so my application crashes when i try to import it.and i get an exception: outofmemory...
what can i do to split the file, and to load it piece by piece into memory.
PS:after i omport the file into memory i have to use its seismic data to do some 3D simuations.
someone has an idea?
thanks.
assia
hgfh
|
|
|
|
|
How are you importing the file? What functions/class(es) are you using?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Hi Mark,
Thanks for you answer.
I lived the office. I will send you the pieces of code tomorrow.
Thanks.
assia
hgfh
|
|
|
|
|
Hello everyone,
As I said I have 4 giga of memory and the file is 5 giga.I use windows Vista64.
and VStudio2005.
Does the serialization work in this case?
What to do to load the file piece by piece?
Is it possible de developp my own serializer ? if yes, can you give me an idea please about how to do it?
Here is my function:
Sine my main class I call this import for differents files, and it is ok when they are not huge.
Here is my function:
FileFormat::openImport(CFile &file, const CString& filename, bool is_binary) const {
FileFormat *self = (FileFormat *) this;
self->filename_ = filename;
self->in_import_ = true;
self->current_line_ = 0;
CFileException file_exception;
if (is_binary) {
if (!file.Open(filename, CFile::modeRead | CFile::typeBinary | CFile::shareDenyWrite, &file_exception))
return openError(file_exception, filename, name_);
}
else {
if (!file.Open(filename, CFile::modeRead | CFile::typeText | CFile::shareDenyWrite, &file_exception))
return openError(file_exception, filename, name_);
}
return true;
}
Thanks.
assia
hgfh
|
|
|
|
|
You may want to look into using a File Mapping[^] so you can access the
entire huge file without loading the entire file into memory at once.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
This link may or may not apply to your situation but it is interesting:
http://www.dansdata.com/askdan00015.htm[^]
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
hai
Can you please holp me reagarding where can i find the implementation of CRC12,CRC16 algorithms in pure c or c++.
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: where can i find the implementation of CRC12,CRC16 algorithms in pure c or c++.
You mean somewhere other than the internet?
|
|
|
|
|
I am recording to current time, and compare with the old time which stored in a file. but here t4 is always one digit less.
for example, when I check file end.txt and start.txt, t4 is 22284, and t3 is 21975, no problem.
but when I calculate and output differ, it shows 2228-21975=-19747. t4 is wrong! what is the problem here?
<br />
int differ=0;<br />
int t3=0;<br />
int t4=0;<br />
time_t t1,t2;<br />
FILE * pFile; <br />
<br />
(void) time(&t2);
t4=(int)t2;<br />
pFile = fopen ("/root/pclinq/end.txt","r+");<br />
fprintf (pFile, "%d",t4);
fclose (pFile);<br />
<br />
<br />
pFile = fopen ("/root/pclinq/start.txt","r+");<br />
fscanf (pFile, "%d", &t3);
fclose (pFile);<br />
<br />
differ=t4-t3;<br />
<br />
<br />
printf("differ is %d-%d=%d\n",t4,t3,differ);
(solved)it turns out the last digit was a remaining one, for example,2228 is the real number recorded this time
-- modified at 8:51 Tuesday 17th July, 2007
|
|
|
|
|