|
ToSchi98 wrote: I cannot debug the app because the only thing i get is this Microsoft Error
What's the exact error?
ToSchi98 wrote: it does not work in my OnClickButton-method where it has to do
Are you sure your click handler is getting called?
I guess getting it to run so you can debug it will help
find that out
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok Mark i finally found the error. Below there is code of the function which is called in the OnInit() method of the Dialog from which the call to the C# dll is triggered. So far so good. The final Software works on XP and Vista (both VS Studio 2008 installed) and "with this function". On Win2K with Framework 2.0 SP1 it doesn´t work. When i comment these method out it also works on Win2K. I don´t really know why this happens and i only get an error report i can send to MS with the hint that something crashes in the mswks dll. I did not spend attention to this method for a long time because nothing everything seems to be ok there was never a crash at this point.
Greetings Torben
PS: I am sorry but in the whole very big program inherited from a very nice guy not one line of documentation can be found
CString CSpliceCheckerDlg::GetVersionInfo()
{
CString csRet;
HMODULE hLib = AfxGetResourceHandle();
HRSRC hVersion = FindResource( hLib,
MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION );
if (hVersion != NULL)
{
HGLOBAL hGlobal = LoadResource( hLib, hVersion );
if ( hGlobal != NULL)
{
LPVOID versionInfo = LockResource(hGlobal);
if (versionInfo != NULL)
{
DWORD vLen;
BOOL retVal;
LPVOID retbuf=NULL;
static TCHAR fileEntry[256];
VS_FIXEDFILEINFO *pFixedValue;
_stprintf(fileEntry, _T("\\"));
retVal = VerQueryValue(versionInfo,fileEntry,&retbuf,(UINT *)&vLen);
if (retVal) {
pFixedValue = (VS_FIXEDFILEINFO *)retbuf;
int i1 = pFixedValue->dwFileVersionMS;
int i2 = pFixedValue->dwFileVersionLS>>16;
int i3 = (pFixedValue->dwFileVersionLS&0xffff);
if (!i3) {
csRet.Format(_T("%d.%d"), i1, i2);
}
else {
csRet.Format(_T("%d.%d.%d"), i1, i2, i3);
}
}
}
}
UnlockResource( hGlobal );
FreeResource( hGlobal );
}
return csRet;
}
modified on Thursday, September 25, 2008 2:57 AM
|
|
|
|
|
What is that code supposed to do? It doesn't even return anything.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Try this:
CString CSpliceCheckerDlg::GetVersionInfo()
{
CString csRet;
TCHAR szAppName[MAX_PATH];
TCHAR szSubBlockName[256];
DWORD FVHandle;
UINT nSize;
BYTE *pData = 0;
::GetModuleFileName(AfxGetResourceHandle(), szAppName, sizeof(szAppName) / sizeof(TCHAR));
DWORD dwSize = ::GetFileVersionInfoSize(szAppName, &FVHandle);
if (dwSize)
{
pData = new BYTE[dwSize];
if (::GetFileVersionInfo(szAppName, FVHandle, dwSize, pData))
{
VS_FIXEDFILEINFO *pFixedFileInfo;
_tcscpy_s(szSubBlockName,_T("\\"));
if (::VerQueryValue(pData, szSubBlockName, (void **)&pFixedFileInfo, &nSize))
{
int i1 = (pFixedFileInfo->dwFileVersionMS >> 16) & 0xFFFF;
int i2 = pFixedFileInfo->dwFileVersionMS & 0xFFFF;
int i3 = (pFixedFileInfo->dwFileVersionLS >> 16) & 0xFFFF;
int i4 = pFixedFileInfo->dwFileVersionLS & 0xFFFF;
csRet.Format(_T("%d.%d.%d.%d"), i1, i2, i3, i4);
}
}
delete[] pData;
}
return csRet;
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark
I tested the code you posted above an it works fine. The code you posted seems clearly to me and i think i understand the problem of the old method in general (not exactly the point of error) which was used before but this bug was very very hard to find for me because i did not search on the right place for a long time . i do not exactly know why this error occurs at the point when the .net app was started and why it does not occur with a normal .net form without any reportform. I would have expected this error when initialize this mfc dialog. However a big "thank you" from my side for the help and time you spent.
Greetings Torben
Edit: Sry i forgot the return value and the last bracket in my i postet before. Changed it.
|
|
|
|
|
Hi all,
How to create a C# control (using VC# 2008 .Net) which can be used in any language (mainly in VC++ 2008 .Net)?
Please guide me.
I appreciate any and all comments and suggestions.
Thanks in advance.
Regards,
Aniket A. Salunkhe
|
|
|
|
|
What is a C# control?
If you build a library using C#, then all public classes in
that library can be consumed by any of the .NET languages.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Thanks for reply.
Mark Salsbery wrote: consumed by any of the .NET languages.
I want to add my 'Windows Form Control Library' (i.e. VC#.Net 2008 ActiveX Control) in my MFC Application of VC++.Net 2008.
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
Aniket Salunkhe wrote: i.e. VC#.Net 2008 ActiveX Control
I don't know about ActiveX controls, but an ActiveX control
written in c# should work just like any other ActiveX control...
that's what they're designed to do
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Is there any way to design '.ocx' in VC#.net?
Because I can't register '.dll' VC# activeX control.
Thanks & Best Regards,
Aniket A. Salunkhe
|
|
|
|
|
Hi all,
I found something to work with MFC application,
http://msdn.microsoft.com/en-us/library/b1kyh79x.aspx[^]
Thanks for your support too.
Now I am trying to integrate it with my MFC Application & Control, as I want to add mutiple control dynamically in MFC Dialog.
But I appreciate any other better suggestions.
Thanks & Best Regards,
Aniket A. Salunkhe
|
|
|
|
|
I guess I'm confused - do you need an ActiveX control or a
Windows Forms control?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: ActiveX control or a
Windows Forms control
What is difference between these 2?
I want to create a UserControl in C#. eg Analog Clock Control in C# with some properties.
|
|
|
|
|
|
Any control you create in C#, or even VB.NET, can be used by the other .NET languages. You have to add a reference to the .dll containing your control.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi,
Thanks to you both for reply.
Paul Conrad wrote: can be used by the other .NET languages
I am using VC++.Net 2008, but I am doing MFC Application.
Paul Conrad wrote: add a reference to the .dll containing your control
How to add reference to .dll in MFC Application using VC++.Net 2008?
And even after adding reference in MFC Application, how to add/use custom ActiveX Control?
Scenario is,
ActiveX Control in VC#.Net 2008 as 'Windows Form Control Library'.
Application in VC++.Net 2008 as 'MFC Application' (as I am doing DirectShow programming in it).
When I try to add my ActiveX Control through 'Insert ActiveX Control', it doesn't show it in that list.
When I try to register the control using 'regsvr32.exe' it shows error as, DllRegisterServer Failed
Thanks & Regards,
Aniket A. Salunkhe
modified on Friday, September 19, 2008 3:32 AM
|
|
|
|
|
Aniket Salunkhe wrote:
How to add reference to .dll in MFC Application using VC++.Net 2008?
And even after adding reference in MFC Application, how to add/use custom ActiveX Control?
That's really fun. I suggest you google that one, it's involved and there's articles how to achieve it.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Loading a managed C++ dll from a non-managed executable works as expected when it is loaded from a local directory. However, when loading the same dll from the same executable over a network path a FileLoadException is thrown: "Failed to grant minimum premission requests". Is there a way to decrease the DLL's security or must the computer's settings be changed in order for things to work correctly?
Thanks!
Doug
|
|
|
|
|
As far as I know you can do this through the manifest file.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
The managed C++ dll is strongly named and the C++ program has a reference to it. I thought that should take care of any such issues. What else do I have to do?
Doug
|
|
|
|
|
I don't think strong naming it is enough. That will help the load time and allow you to register it in the GAC, but it doesn't affect the security policies about running from a network location. There is something you can add to the manifest file which says that it's safe to run from a network location, I just don't remember what it is offhand.
You can also try using fuslogvw (http://msdn.microsoft.com/en-us/library/e74a18c4.aspx[^]) to help identify what the loader is trying to do.
There is also some information here[^] that might help.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
I have some unmanaged code that invokes a callback function to display a series of bit map images in a picturebox in a managed GUI.
The unmanaged code is called from a worker thread, it loops, creating the bitmap images and passing the image address and a serial number as parameters to the callback routine. When all the images have been displayed the unmanaged code finishes, and the worker thread terminates.
The callback routine copies the bitmap to a stream and uses invoke to get the gui to display the image.
The images are set to display at 1/second.
I thought I had everything working nicely, but after about 30 seconds everything dies and a 'Buffer Overrun' message is generated.
The error is generated when/in/by calling the callback routine. If I don't invoke the callback all is ok. If I invoke the call back but do nothing except return immediately everything still goes wrong after about 30 seconds.
If I make the delay 10 sec everything runs happily for about 100 seconds, but then dies again.
I've reduced the code to a simple skeleton, but still get the crash.
The unmanaged code is called using a delegate, GCHandle, and Marshall::GetFunctionPointer.
I suspect something to do with garbage collection, or the lifetime of a thread, but I'm tearing my hasir out over this.
Can anyone suggest what I may have overlooked?
Bob Swan
|
|
|
|
|
Is the buffer overrun message because of an exception?
If so, what code is executing at the point the exception
is thrown?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
None that I can see.
Normally the error is flagged when the callback is returning to the unmanaged code. The .net code that does all the cleanup and overrun checks as part of the return statement detects that the marker bytes have been modified.
I have run the code with visual studio monitoring the memory locations, (a breakpoint that continues when triggered) I can see that the markers are being overwritten. I can see that the data corrupts, but not what is doing it. This occurs even when all I am doing is calling the callback from a loop, and that does nothing except return.
In the original unmanaged code there were number of cout statements
which tended to flag the error, especially if you piped several items to the output. But I believe that was just because they also ran code that performed clean up checks. They also don't appear in my simple system.
I have ruled out the hardware problems as this occurs under Windows XP + studio 2005 or Windows 200 +studio 2008 Express.
I feel sure its something stupidly obvious.
BoB Swan
|
|
|
|
|
Well I've found one stupid error that corrects my simple version of the program.
when declaring the callback function pointers I had failed to define the calling convention as _stdcall
See stupid, maybe not obvious.
Bob Swan
|
|
|
|