|
You have stored the return from your call to WindowsIdentity::GetCurrent() as an object reference. You are then sending that object reference to the WindowsPrincipal() constructor, which expects a WindowsIdentity reference as documented here[^]. The compiler is complaining because it does not feel able to promote an object reference to a higher level. Save your WindowsIdentity object as a WindowsIdentity reference.
|
|
|
|
|
thank you
|
|
|
|
|
|
Hi all,
Hoping you can help me out. I've been trying to track down a handle leak in our product for the last few days, and I've gotten to the point where I suspect something is happening outside of our code. It seems that everytime my application calls _beginthread, there is 5 handles that leak. This happens to be our Server application, which receives many requests and calls to _beginthread, so after a period of time, this gets ugly.
This application is compiled with /clr to use code written in a .DLL for LDAP Authentication. But regardless of whether nor not any C#/DLL code gets ran, we're still leaking. I commented EVERYTHING out, except a call to _beginthread. Inside the thread proc, all I do is call _endthread... And the problem still occurs - 5 handles on every call.. This is verified using Process Explorer and the WinDbg tool.
If I turn off the /clr flag, and the problem goes away...
I did a !htrace in WinDbg, and this is what its showing me..
Outstanding handles opened since the previous snapshot:
--------------------------------------
Handle = 0x00000240 - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b21575: mscorwks!Thread::AllocHandles+0x0000009b
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x0000023c - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b21569: mscorwks!Thread::AllocHandles+0x0000008f
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x00000238 - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b2155d: mscorwks!Thread::AllocHandles+0x00000083
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x00000234 - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b21551: mscorwks!Thread::AllocHandles+0x00000077
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x0000022c - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4680: ntdll!ZwDuplicateObject+0x0000000c
0x77963d92: KERNEL32!DuplicateHandle+0x0000012b
0x72b2365f: mscorwks!Thread::InitThread+0x00000174
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
0x77c916c3: ntdll!__RtlUserThreadStart+0x00000023
0x77c91696: ntdll!_RtlUserThreadStart+0x0000001b
--------------------------------------
I've exhausted everything I can - have you seen this before? What do you recommend in further debugging the problem? I'm using VS.2008. I don't believe you can specify in the C++ Project the .NET version (thought perhaps it was fixed in a later version) ..
Any help and or suggestions you may have would be greatly appreciated, thanks.
Mike
|
|
|
|
|
hi,
I have an aplication whose view is based in TabControl. It has three tab and one of them have a Edit control. I'd like show text in this edit control when I press a button. I thought do a global variable that keep a valor, for example 1, and in the method, to do a control that show text only if the variable have valor 1.
But my problem is after press button, don't happen something. I think that I must to update the view with the method onUpdate or something like that.. but I dont know how.
What do you think?
This is my aplication:
http://i54.tinypic.com/1e9qtx.png
This is code :
http://www.megaupload.com/?d=1QT43LOQ[^]
|
|
|
|
|
|
In C++ on VS 2005 , createfile API fails with Invalid file handle error in below scenrio.
1.Consider user A and user B are both part of administrator group and i logged in to machine as user A and started one service application with user B. This program creates files on mapped network drive.
so i started this program with user B then below createfile API fails with invalid handle error when i try to create a file on mapped network drive ,though user A and B both part of administrator group on windows.
This happens on windows server 2003 and 2008 also.
In Win 2008 i turned off UAC but same behaviour.
Any other setting need to be done while creating mapped network drive ?
Usre who is creating a mapped network drive is the only one who can write file to it ?
While creating a network drive i logged in as user A, but file is created on this drive by user B , but since both are part of administrator why user B is NOT allowed to create a file on mapped network drive ?
Thanks.
//code i tried
DWORD dwAccess = CREATE_NEW;
HANDLE hFile = CreateFile(sTempFile, GENERIC_WRITE,
0, NULL, dwAccess, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD errCode = GetLastError();
|
|
|
|
|
I have following header file and library. using this header file and library i want create DLL in VC++. then this DLL I can use in vb.net. I added this header file and library file in my vc++ project but at the time of create build it gating error.
i think I need _declspec(dllexport) int capture_data(unsigned char ** raw_image, unsigned char **
fmr_data, int templateLen[]) this function Please suggest me how can i Add this function.
1. MORPHO_Types.h
2. MORPHO_TemplateList.h
3. MORPHO_FieldList.h
4. MORPHO_User.h
5. MORPHO_UserList.h
6. MORPHO_FieldDescriptor.h
7. MORPHO_Database.h
8. MORPHO_Device.h
9. MORPHO_Errors.h
10. MORPHO_Image.h
11. MORPHO_Interface.h
1 MORPHO_SDK.lib (functions that communicate with device)
2.MORPHO_SDK_Image.lib (functions that display images from device)
my mail id is ravi.ranadive@gmail.com
|
|
|
|
|
Just asking an interview question.
In Windows perspective what is the difference between a user dump and kernel dump?
|
|
|
|
|
Consider: what is the difference between user space and kernel space?
Also consider whether this really has anything at all to do with Managed C++/CLI.
|
|
|
|
|
Pls, check my codes. I added app.config file into project. codes are
<configuration>
<connectionStrings>
<add name ="SQLConnection" providerName="Oracle.DataAccess.Client"
connectionString="Data Source=localhost:1521/orcl; user id=scott; password=tiger"/>
</connectionStrings>
</configuration>
In C++/CLI file I tried to connect Oracle DB but failed. Codes are like below
#include "stdafx.h"
using namespace System;
using namespace System::Data;
using namespace System::Data::Common;
using namespace System::Configuration;
using namespace Oracle::DataAccess::Client;
int main(array ^args)
{
try{
String^ provider = ConfigurationManager::ConnectionStrings["SQLConnection"]->ProviderName;
DbProviderFactory^ factory = DbProviderFactories::GetFactory(provider);
DbConnection^ conn = factory->CreateConnection();
String^ connection = ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString;
conn->ConnectionString = connection;
conn->Open(); //Exception Occurs!
}
catch (Exception^ e) {
Console::WriteLine(e->Message);
}
return 0;
}
Exception is ora-12541 No Listener. But "tnsping orcl" is done well. and I executed "lsnrctl start".
I need your advice. Thanks in advance.
Best Regards.
Joseph Hwang
|
|
|
|
|
hello.
how do i realize the interaction between managed and unmanaged code inside a mixed assembly dll? assume the dll exposes an unmanaged API and shall be callable from unmanaged client code.
I understand that by using delegates I can rout unmanaged functions to managed functions, however I need to create managed objects first.
how can the creation or initialization of managed objects be achieved if user entrypoints may only contain unmanaged code and automated entry-points should be deactivated due to the dll load bug?
thanx for any advice
modified on Friday, September 9, 2011 6:13 AM
|
|
|
|
|
It's not clear what you're asking. Can you restate the question in one sentence?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
I want to connect through proxy server, so i need to hook the send function and want to change the sending buffer (data) with my few addition .How can i do that.. i am using detours for hooking
|
|
|
|
|
Hello all,
I have a problem I just can't solve.
I have a c++ dll that returns a VARIANT of type VT_ARRAY|VT_BYREF|VT_BSTR.
following what was explained in Step by Step: Calling C++ DLLs from VC++ and VB - Part 3[^]. I turned my whole C++ process into a class.
On the vb side, I have a string array that receives the info back from the C++ dll
it is declared at a form level as private myarray() as string
The problem is that the first time I use it, it works perfectly. But if I push the button a second time, the whole process works until the dll reaches the point where it returns the variant and it just fails.
I don't understand. I'm pretty sure the class is destroyed the first time and so any value contained in the variant is deleted.
Also in vb if I unload and reload the dll every time, then it works well. So it's not an array problem on vb part (and I tried redim and erase and all). But I don't really want to load and unload every time, seems like bad programming and it creates other problems anyway.
So to summarise:
From vb6:
1-call C++ dll to create class
2-call class function to return array
3-call C++ dll to destroy class
first time works without a glinch, second time gets an error when returning the array.
Please help, it's driving me crazy.
Oh and as you might have guessed I'm a noob with C++
Many thanks
|
|
|
|
|
It might help if you reveal the exact error that causes the process to fail.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi, thank you for helping.
If I'm in vb it just crashes so not helpful and in vc the debugger gives me:
Unhandled exception in project.exe (OLEAUT32.DLL): 0xC0000005: Access Violation.
Then it stops at:
77154281 push dword ptr [eax]
So I didn't think it would be that helpful. But as I said, I'm going crazy so thanks again for helping.
|
|
|
|
|
You should attach your debugger to the application and step through the code in your DLL. Obviously something is not being tidied up properly on your first call which is causing it to crash the second time round. Also the stack trace at the time of the crash should point you back to the function in your C++ class that made the fatal call.
|
|
|
|
|
Hello,
thank you for your answer. Actually I reached the same conclusion, I think I am not properly releasing the variant array that's returned to the vb app.
But I don't know what I'm doing wrong.
inside the class it is declared:
static VARIANT pVal;
then it is initialized outside the class with:
VARIANT MYCLASS::pVal;
in my code I do
VariantInit(&pVal);
pVal.vt= VT_ARRAY|VT_BYREF|VT_BSTR;
pVal.pparray = &pSA;
return pVal;
If I'm not mistaken, the return pval; is where the problem occurs.
My deconstructor is:
MYCLASS::~MYCLASS()
{
SafeArrayDestroy(pSA);
if (pVal.vt & VT_BYREF) {
if (*pVal.pbstrVal != 0) {
::SysFreeString(*pVal.pbstrVal);
}
if (pVal.bstrVal != 0) {
::SysFreeString(pVal.bstrVal);
}
}
VariantClear(&pVal);
}
I step throught it in the debugger everything in the deconstructor is used so I really assumed it was all ok. But obviously something is still hanging around. I read that "If the variant was used to explicitly pass a pointer, i.e. (vt & VT_BYREF != 0), then free the memory pointed to." I think that's what I'm doing.
Anyway, once again, I'm so lost.
Thanks again for helping
|
|
|
|
|
I have not used VARIANT types for some years but are you sure that the VariantClear() call in your destructor is required?
|
|
|
|
|
I am 95% sure it is needed. It works with it (the first time) and deleting it doesn't solve my problem.
Actually with or without the whole cleaning up code in the deconstructor, I get the same error.
|
|
|
|
|
lenourien wrote: with or without the whole cleaning up code in the deconstructor, I get the same error.
Looks like the problem is elsewhere then; back to the debugger I'm afraid.
|
|
|
|
|
I really think there is a resource I am not freeing. The problem still happens the second time I return the variant to the vb app. When I go step by step this is were the problem occur. I just can't figure out what is it that I'm not freeing in that variant.
|
|
|
|
|
I found the problem and I am even more confused.
The problem comes from the fact that all my variables and my arrays keep the values put into them during the first run even after I delete the class. So when I do the second run, the values for the first run are still there.
Why?????!!!!!! I thought each new instance of the class will start with fresh variables and arrays...
Why isn't it happening?
|
|
|
|
|
Normally, that is true, but I have the feeling you are using 'static' for most of your variables? In that case, the variables are not bound to a single instance and thus persist as instances are created and destroyed.
Also, I think your code has problems when instantiating more than 1 instance at a time, as the static variables will be 'shared' between instances.
You should consider making pVal and pSA proper members (i.e. non-static), unless you have very good reason to. I'm guessing the caller (VB6) will need the passed string-arrays to persist even if the class instance is destroyed? In that case, making them non-static won't work.
The conclusion is, I think, that you need to seriously reconsider your class design and the lifecycle of your data. It'd help if you'd share your code, so we can assist.
Also, see my other post, about the destructor/clean-up code.
|
|
|
|