Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

saania khan

@saania khan
About
Posts
9
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • mutithreading, how to synchronize threads
    S saania khan

    Hi all. I have two threads ... one as a sender and the other a receiver for data sent over sockets. But the sockets are being created and handled in a dll ( a VC# dll which has a class named Class1). so when I call these threads I have to pass the object of the class in the dll because the sender and receiver use the same sockets right!!. Here is what I have in the sender and receiver threads... ( and I dont know a work around for the DoEvents thing, because I have to enforce the processor to do other tasks while the thread is in a while loop .... and I have removed the doevents completely as well and it doesnt make any difference. So the problem is not with doevents). DWORD WINAPI SenderThread(LPVOID iValue) { Mutex^ mut = gcnew Mutex(); mut->WaitOne(); Class1^ senderdll = *((Class1^*)iValue); mut->Close(); int returnval; DoEvents(); while(true) { returnval = senderdll->SenderEntryPoint(); if(returnval == 1) // sockets closed { break; //dynamic_cast(stateInfo)->Set(); } } return 0; } DWORD WINAPI ReceiverThread(LPVOID iValue) { Mutex^ mut = gcnew Mutex(); mut->WaitOne(); Class1^ receiverdll = *((Class1^*)iValue); mut->Close (); int returnval; DoEvents(); while(true) { returnval = receiverdll->ReceiverEntryPoint(); if(returnval == 1) // the sockets closed break; } return 0; } and here is how I am creating these threads. (The cmdListen_Click function creates the sockets.) Class1^ c = gcnew Class1(); c->cmdListen_Click(NewPosition);//call the dll function to create sockets ////Threads start DWORD dwGenericThread; hThread2 = CreateThread(NULL,0,SenderThread,&c,0,&dwGenericThread);//the sender thread if(hThread2 == NULL) { DWORD dwError = GetLastError(); return 0; } hThread3 = CreateThread(NULL,0,ReceiverThread,&c,0,&dwGenericThread);//the receiver thread if(hThread3 == NULL) { DWORD dwError = GetLastError(); return 0; } //////Threads end Now the two problems I am facing are: 1) How do I synchronize the threads? The AutoResetEvent (as given in http://msdn2.microsoft.com/en-us/library/system.threading.autoresetevent.aspx), uses a threadpool to create threads. My problem is if I use the threadpool instead of using the CreateThread how do I pass the Class1 object in the threads ? 2) My second problem is the AccessViolation error, which I am getting at the point where I create the instance of the Class in the thread. ( in b

    C / C++ / MFC help question csharp com tutorial

  • why VC++ 6.0 DLL works with VC# and the one in Visual Studio 2005 doesnt?
    S saania khan

    One of the things that I have been working on for the past couple of days is creating a DLL in VC++ 6.0 and using it in VC#, and it works..... but when I create the dll in VC++ Visual Studio 2005, it doesnt work with the VC# code.(in Visual Studio 2005)...... I get the error message that it could not find the fntest () function in TestDll.dll. Let me be more specific about how I created the DLL.....( and I followed the same steps for VC++ 6.0 and VC++ 2005). After following the steps in the link http://www.icynorth.com/development/createdlltutorial.html(I created a project that exports some symbols instead of a simple dll)I created a .def file, specified the test function as EXPORT. Then I went to build->configuration manager. and changed the configuration from debug to release. I then built the project, got the dll and copied it to the folder C:\WINDOWS\system32. Then I used PInvoke in VC# code and it worked fine for a VC++ 6.0 dll but not for a Visual Studio 2005 dll in VC++. I have a code ( written by someone else) in Visual Studio 2005. It has a lot of libs etc. specific to .NET, so I have to convert this code to a dll and then use it in my VC# program. I am desperately waiting for a response. Thanks,

    C / C++ / MFC csharp c++ html visual-studio com

  • problem using VC++ DLL in VC#
    S saania khan

    Thanks a lot Christian. I tried to follow the stuff explained in http://www.icynorth.com/development/createdlltutorial.html. My DLL did not work with my C# code (even though I had everything told in the article), but when I copied the DLL that came with the article, it worked fine with VC# project, by simply using PInvoke !!. I'll follow the setting in the given project more closely and see where I am going wrong. Thanks a lot for your time and help. Saania

    C# csharp c++ help question visual-studio

  • problem using VC++ DLL in VC#
    S saania khan

    Yeah thanks once again, I posted it in 2 different threads.... The point I didnot mention in the other reply is that I am using PInvoke in C#. That is where I started from, and when that didnt work I had to look into what other stuff could be wrong. I am using ... [System.Runtime.InteropServices.DllImport("testdll.dll")] static extern int fntest (); and in the main I am simply doing .... int x = fntest (); and this is where I get the error ... EntryPointNotFound exception. It says "unable to find entry point named "fntest" in DLL "testdll.dll". I even tried using System.Reflection.Assembly.Load Method, which throughs a TypeLoadException. Please help me out here. I would highly appreciate it. Thanks,

    C# csharp c++ help question visual-studio

  • problem using VC++ DLL in VC#
    S saania khan

    Thanks for the reply, but there is one problem still .... I am not creating a DLL from scratch. I have a project in VC++ (written by someone else) and I want to use it from my VC# code, so for that I first have to convert the VC++ project to a dll ~ right !! Or is there some other way I can use the project in my VC# code. Thanks once again.

    C / C++ / MFC csharp c++ help question visual-studio

  • connecting client to server
    S saania khan

    If you have the visual C++ 6.0 installed on your laptop as well, simply copy a chat server from the internet and run it. Get the IP of your laptop and ask the client to connect to the server using that IP.

    C / C++ / MFC c++ sysadmin tutorial question

  • RegSvr32 failed
    S saania khan

    Hi, I have Visual Studio 2005 and my regsvr32 also fails with the message "testdll.dll was loaded, but the DllRegisterServer was not found". I have copied it to the Windows/System32 folder as well. Kindly help me out here. Thanks

    COM help csharp visual-studio com question

  • problem using VC++ DLL in VC#
    S saania khan

    Hi, I am trying to create and then use a VC++ DLL in C#. I created the DLL in Visual Studio 2005. I just built the dll without adding any function of mine to it. That is, it is a dll that exports symbols and has the following pre-defined export symbols/functions. // This is an example of an exported variable TEST_API int ntest=0; // This is an example of an exported function. TEST_API int fntest(void) { return 42; } where, #define TEST_API __declspec(dllexport) Then I created a simple VC# empty project ( in Visual Studio 2005) and added the class "test" to it. When I add the VC++ dll as a reference I get this error .... "A reference to "../test.dll" could not be added. Please make sure that the file is accessible, that it is a valid assembly or COM component". Even though I dont think it needs a conversion from COM to COM+, I even tried doing "tlbimp". I went to the command prompt for Visual Studio 2005, followed the path to where my dll resides and used the tlbimp command. But I got the error that test.dll is not a valid type library. Someone told me that I need to register the dll using regsrv32 and it would show in my COM list when I am adding it as a reference. But that didnt work either. When I run the regsrv32, I get the error message as "..\test.dll was loaded, but the DLLRegisterServer entry point was not found" ... I just want to know that what is it that I am doing wrong? Is there something else that I should be doing ? All I did for creating the test.dll was ...... I went to File->New->Project. Under Visual C++ I selected Win32 and then Win32 Project. In the Application settings I selected the DLL and then checked the export symbol box. I simply built the project and was trying to use it. Thanks for your time. Saania

    C / C++ / MFC csharp c++ help question visual-studio

  • problem using VC++ DLL in VC#
    S saania khan

    Hi, I am trying to create and then use a VC++ DLL in C#. I created the DLL in Visual Studio 2005. I just built the dll without adding any function of mine to it. That is, it is a dll that exports symbols and has the following pre-defined export symbols/functions. // This is an example of an exported variable TEST_API int ntest=0; // This is an example of an exported function. TEST_API int fntest(void) { return 42; } where, #define TEST_API __declspec(dllexport) Then I created a simple VC# empty project ( in Visual Studio 2005) and added the class "test" to it. When I add the VC++ dll as a reference I get this error .... "A reference to "../test.dll" could not be added. Please make sure that the file is accessible, that it is a valid assembly or COM component". Even though I dont think it needs a conversion from COM to COM+, I even tried doing "tlbimp". I went to the command prompt for Visual Studio 2005, followed the path to where my dll resides and used the tlbimp command. But I got the error that test.dll is not a valid type library. Someone told me that I need to register the dll using regsrv32 and it would show in my COM list when I am adding it as a reference. But that didnt work either. When I run the regsrv32, I get the error message as "..\test.dll was loaded, but the DLLRegisterServer entry point was not found" ... I just want to know that what is it that I am doing wrong? Is there something else that I should be doing ? All I did for creating the test.dll was ...... I went to File->New->Project. Under Visual C++ I selected Win32 and then Win32 Project. In the Application settings I selected the DLL and then checked the export symbol box. I simply built the project and was trying to use it. Thanks for your time. Saania

    C# csharp c++ help question visual-studio
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups