|
I'd need to see the call stack at the time of the exception...
Without it I could only guess.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How can I record the call stack at the time of the exception?
|
|
|
|
|
When debugging I saw the program stops at winmain.cpp below and the line if (!pThread->InitInstance())
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
#include "sal.h"
/////////////////////////////////////////////////////////////////////////////
// Standard WinMain implementation
// Can be replaced as long as 'AfxWinInit' is called first
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
__in LPTSTR lpCmdLine, int nCmdShow)
{
ASSERT(hPrevInstance == NULL);
int nReturnCode = -1;
CWinThread* pThread = AfxGetThread();
CWinApp* pApp = AfxGetApp();
// AFX internal initialization
if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
goto InitFailure;
// App global initializations (rare)
if (pApp != NULL && !pApp->InitApplication())
goto InitFailure;
// Perform specific initializations
if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL)
{
TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance();
goto InitFailure;
}
nReturnCode = pThread->Run();
InitFailure:
#ifdef _DEBUG
// Check for missing AfxLockTempMap calls
if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
{
TRACE(traceAppMsg, 0, "Warning: Temp map lock count non-zero (%ld).\n",
AfxGetModuleThreadState()->m_nTempMapLock);
}
AfxLockTempMaps();
AfxUnlockTempMaps(-1);
#endif
AfxWinTerm();
return nReturnCode;
}
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
Is the code you are using in your service tested? The actual operations of the service should be developed and tested in an environment external to the Service process before ever attempting to integrate and execute it in a Service process.
led mike
|
|
|
|
|
Yes, I want my Windows Service to use a dll created in Visual C++ 6.0.
This dll uses MFC to implement OLE Automation (reading data from a server application).
As I learned from It just works (using unmanaged C++ in C++/CLI), I copied dll and lib files to the windows service project, included header files and added lib file to additional dependence. When compiling I got error message, MFC should be set to MFC in a Shared DLL. After I did that I got error messages described at http://www.gregcons.com/KateBlog/DontCompileMFCAppsWithClrpure.aspx[^] when compiling. After I changed the setting to Common Language Runtime Support (/clr), the compile got successful, but as said I got problem to install this windows service.
I located the problem as I wrote in my first post. It seems to me if I set MFC in a Shared DLL
and Common Language Runtime Support (/clr), and include one MFC header file (without dll, lib and ohter header files), I will get this problem when intalling.
What do you think?
Thank You!
|
|
|
|
|
xuesyuan wrote: What do you think?
Well the first thing I think is that it does not sound like you tested as I asked you. If this was my project I would create a Win32 Console Project in VS2005 and attempt to use the Visual C++ 6 DLL from that project before I ever tried to create and run a Service.
Secondly
xuesyuan wrote: When debugging:
Unhandled exception at 0x78374588 (mfc80ud.dll) in myService.exe: 0xC0000005: Access Violation reading location 0x00000000.
xuesyuan wrote: Yes, I want my Windows Service to use a dll created in Visual C++ 6.0.
You used MFC version 8 to link to a DLL linked to MFC version 6. First off I wouldn't do that. However it may in fact work anyway if you have the old MFC DLLs installed on the machine you are trying to execute the DLL on. Do you? If not you should try that first. If the problem persists you should search MSDN (using Google) for information on using a MFC 6 DLL from a VS2005 application.
led mike
|
|
|
|
|
Thanks for your ideas and suggestion!
|
|
|
|
|
xuesyuan wrote: I want my Windows Service to use a dll created in Visual C++ 6.0.
As led mike mentioned, that's not going to work, except under
extremely controlled circumstances.
You'll have two MFC libraries and two CRT libraries running at the same
time. You won't be able to share objects between them without knowing exactly
what you're doing.
MFC is NOT supported in services, so it's up to you to study the source
code for all MFC classes you use and make sure they work in a service.
That means only simple wrapper classes, like CDatabase/CRecordset are.
If you can't upgrade the DLL to your current MFC version, your best bet
is to implement the service using Win32 APIs instead of C++/CLI, using VC6.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have 3 columns in my listview. i have tied the cloumn widths to change appropriately whenever the listview resizes.
However, when I resize the columns, an additional column appears on the right. How do I stop the additonal column from appearing, and be able to resize the 3 columns only.
|
|
|
|
|
I believe you can make the rightmost column automagically resize to
fill the remaining space by setting its width to -2. Then you'd
only need to resize the first two columns - the third will follow.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi All
Actually am C# developer.now i want to write the code in C++ for "writing XL sheet from C++".Using introp dll we can use in c#.it may be same in c++.but i dont know perfectly....please give me any link related this or code....its ver urgent...
Thanx in Advance
Mohan.T
Mohan t working for N.I.C
|
|
|
|
|
Microsoft::Office::Interop::Excel::Application^ exl = gcnew Microsoft::Office::Interop::Excel::ApplicationClass();
FileInfo^ file = gcnew FileInfo("c:\\leonigah.xls");
Workbook^ wb = exl->Workbooks->Open("c:\\leonigah.xls", 0, false, 5,"", "", true, Microsoft::Office::Interop::Excel::XlPlatform::xlWindows, "\t", false, false,0, true, true, 0);
Worksheet^ ws = static_cast<Worksheet^> (exl->ActiveSheet);
Range^ rn = (Range^)ws->Cells[2, 4];//2=row;4=column
rn->Value2 = "leonigah";
Nigah M Manzoor
modified on Wednesday, July 23, 2008 8:13 AM
|
|
|
|
|
Hi, I'm using Visual Studio 2005 C++/CLI. This should be an easy one. I have a textBox that has some number in it. When I press the (+) or (-) key on the far right keypad I can use ::Keys::Add and Keys::Subtract to recognize that those keys had been pressed and I can increment and decrement the number, and then put number.ToString() back in the textBox but the "+" or "-" character gets added to the textBox (and I don't want that). How do I restrict the characters that can be added to a textBox->Text String^?
Thanks,
Buck
|
|
|
|
|
|
Yes, I've read that documentation and as usual when it comes to Microsoft they assume you are a WINDOWS programmer (worst operating system ever invented). Notice how they don't show you how to do it they just tell you to do it. That being aside, I AM using an event handler for when the keys are pressed (that is how I can recognize when the (+) and (-) keys are pressed with Keys::Add and Keys::Subtract), the question is how do you keep it out of the textBox->Text String? I guess I just have to let the character get added to the text string and then search the text string for the character I just typed and then delete it from the string.
Buck
|
|
|
|
|
BuckBrown wrote: Yes, I've read that documentation and as usual when it comes to Microsoft they assume you are a WINDOWS programmer (worst operating system ever invented)
Your kidding right? Who do you write your technical documentation for, used car sales men?
So you have produced a better operating system? Give me a link to it and I will try to help you. Or even give me a link to your technical documentation you produced that is better than Microsofts, then I will help you.
Ooops, I forgot to check my CodeProject.AVOID list, you are already on it, never mind, my bad.
led mike
|
|
|
|
|
Fine Mike, you win. I wont bother picking your brain anymore. I dont understand why you insist on being such an a**hole.
|
|
|
|
|
BuckBrown wrote: (worst operating system ever invented)
Yeah, I'm sure you're right though, I'm the a**hole.
led mike
|
|
|
|
|
how in gods name did you get to be an MVP?
|
|
|
|
|
f*** off a**hole, go back to the soapbox
led mike
|
|
|
|
|
BuckBrown wrote: question is how do you keep it out of the textBox->Text String?
Does the sample code here do what you want?
KeyPressEventArgs::Handled Property[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey, gang!
So, I was fooling around with asynchronous socket communication, and I hit an interesting issue. I found some sample code that showed me the correct way to do what I was after, but I don't understand why it worked. That bothers me a bit, and I'd really appreciate it if one of you fine CPians would help me out.
I wanted a call to Socket::BeginReceive() to use an instance method of a class as its callback method. I was creating an AsyncCallback delegate to pass in, and first tried gcnew AsyncCallback(&this->ClassName::MethodName) . The compiler didn't like that, so I hunted around and learned that the proper way is gcnew AsyncCallback(this, &ClassName::MethodName) .
It did exactly what I wanted, but my question is this: Why was I allowed to do that? Both Intellisense and MSDN report that the only two overloads for that constructor are AsyncCallback(void) and AsyncCallback(const AsyncCallback & ) . Why did it accept a call with two arguments? I'm obviously missing something, and I'd like to know what.
Thanks very much for the insight!
|
|
|
|
|
Interesting...I get this on VS 2008:
error C3350: 'System::AsyncCallback' : a delegate constructor expects 1 argument(s)
?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Really? It compiles without complaint on my end, also with VS 2008. It executes properly, too.
Is it perhaps time to consider the possibility that I have finally lost my mind?
|
|
|
|